What happens
With cxx_runtime = "host-coupled" in [build], the project's TUs are compiled
/MD but the std module interface they import was built /MT. cl warns and
then fails for real:
warning C5050: Possible incompatible environment while importing module 'std':
_MSVC_MT is defined in module command line and not in current command line
warning C5050: Possible incompatible environment while importing module 'std':
_MSVC_MD is defined in current command line and not in module command line
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_malloc.h(89):
error C2375: 'free': redefinition; different linkage
Why it is not a stale artifact
I first assumed the CI cache. It is not:
- the cache key changed and there are no
restore-keys, so ~/.mcpp came in cold
- the build log contains no command that builds
std.ifc at all — it is
served from mcpp's own global std cache
- the project TU command line does carry
/MD, so cxx_runtime reached the
project; it just did not reach std
So the std module is built with mcpp's default runtime regardless of what the
manifest asks for, and a host-coupled project can never agree with it on MSVC.
Expected
cxx_runtime is described as a contract for the produced artifact, and on MSVC
the runtime selection is an ABI-level property that the std module has to share
with everything importing it. Either the std module build should honour
cxx_runtime, or the std cache should be keyed by it so the two cannot diverge
silently.
Environment
Workaround in use
Setting cxx_runtime = "self-contained" — mcpp's own default, /MT on MSVC —
puts the project on the same runtime as the std module it is handed. That is
what this project does today, at the cost of differing from its xmake build,
which uses set_runtimes("MD").
What happens
With
cxx_runtime = "host-coupled"in[build], the project's TUs are compiled/MDbut thestdmodule interface they import was built/MT. cl warns andthen fails for real:
Why it is not a stale artifact
I first assumed the CI cache. It is not:
restore-keys, so~/.mcppcame in coldstd.ifcat all — it isserved from mcpp's own global std cache
/MD, socxx_runtimereached theproject; it just did not reach std
So the std module is built with mcpp's default runtime regardless of what the
manifest asks for, and a
host-coupledproject can never agree with it on MSVC.Expected
cxx_runtimeis described as a contract for the produced artifact, and on MSVCthe runtime selection is an ABI-level property that the std module has to share
with everything importing it. Either the std module build should honour
cxx_runtime, or the std cache should be keyed by it so the two cannot divergesilently.
Environment
xlings install mcpp)msvc@system)(
[build] cxx_runtime = "host-coupled", cold cache)Workaround in use
Setting
cxx_runtime = "self-contained"— mcpp's own default,/MTon MSVC —puts the project on the same runtime as the std module it is handed. That is
what this project does today, at the cost of differing from its xmake build,
which uses
set_runtimes("MD").