MPS issue job001945

TitleMPS buildsys CONFIG_PF_* does not select a platform, is not checked by mpstd.h
Statusclosed
Priorityessential
Assigned userRichard Kistruck
OrganizationRavenbrook
DescriptionMPS buildsys CONFIG_PF_* does not select a platform, is not checked by mpstd.h

Related jobs:
job001944 "MPS lacks separate w3i3m9 platform for building with VC9 (Microsoft Visual C++ 9.0)"
(desires checking)

RHSK 2008-10-22
See notes in mpstd.h:
  //info.ravenbrook.com/project/mps/branch/2008-08-14/vc9/code/mpstd.h#3
MPS buildsystems know the platform. Also, file "mpstd.h" detects
the platform. The CONFIG_PF_* preprocessor symbol is intended to
be used by the buildsystem to control / override / augment the
detection in mpstd.h.

It fails to do so, because if mpstd.h detects the characteristic
preprocessor symbols set by a particular compiler that happens to
occur earlier in mpstd.h's list of platforms, this will take effect,
and the CONFIG_PF_* that is attempting to select a later platfrom
will be ignored.

It would be much more useful for mpstd.h to always determine the
platform (by looking for the characteristic preprocessor symbols),
and then check that the answer reached matches the CONFIG_PF_*
specified by the buildsys (if the buildsys does specify it; not all
do). But mpstd.h does not do this.
AnalysisRHSK 2008-10-22
CONFIG_PF_* does not reliably select a platform, as described above.

C preprocessor is limited: no string comparisons or wildcards.

While it would be possible allow CONFIG_PF_* to override, this
would require running through every possible platform twice, once
for CONFIG_PF_* and then looking for the characteristic preprocessor
symbols. It's not worth it.

There's no need to override. mpstd.h *has* to work without
buildsystem support anyway, when included by client code.

However, a check would be very useful, and CONFIG_PF_* can be used
for this: this is how the buildsys tells mpstd.h what platform it is
trying to build.

Because there is no wildcard matching, the easiest way for the
buildsys to tell mpstd.h that it has set a particular CONFIG_PF_*
is for it to also set another symbol. I have chosen
CONFIG_PF_STRING. The string value is not currently used; the
presence of CONFIG_PF_STRING is merely a flag.

Now, for platforms that set BOTH CONFIG_PF_* and CONFIG_PF_STRING,
mpstd.h halts if there is a mismatch with the platform it determines.

This enables checking that the right version of the compiler is in
use: see job001944.
How foundunknown
Evidencenone
Observed in1.108.2
Created byRichard Kistruck
Created on2008-10-22 17:53:16
Last modified byRichard Kistruck
Last modified on2008-10-22 18:00:38
History2008-10-22 RHSK Created.

Fixes

Change Effect Date User Description
166513 closed 2008-10-21 18:32:26 Richard Kistruck MPS br/vc9: mpstd.h: (for all remaining platforms)
- fix broken behaviour if CONFIG_PF_* is set (result depends on
  order of the various platform elifs!); change it to always use
  platform detection by looking at preprocessor symbols, and
  then (if CONFIG_PF_STRING *and* CONFIG_PF_* are set) check
  that CONFIG and detection match;
xcppgc.gmk: define both CONFIG_PF_STRING and CONFIG_PF_*.
166512 open 2008-10-21 17:44:17 Richard Kistruck MPS br/vc9: mpstd.h:
  - fix broken behaviour if CONFIG_PF_* is set (result depends on
    order of the various platform elifs!); change it to always use
    platform detection by looking at preprocessor symbols, and
    then (if CONFIG_PF_STRING *and* CONFIG_PF_* are set) check
    that CONFIG and detection match;
  - write design notes about interaction of CONFIG_PF_* and
    platform detection.
w3i3m[v9].nmk: define both CONFIG_PF_STRING and CONFIG_PF_*.