You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The order of compilation is not correct when building a multi-target C++20 project with modules. The likely culprit is the wrong handling of parallelization across targets. Here are the files to reproduce:
The build should go through and the static library should be built before the binary. Note that we can force this to happen by uncommenting the line set_policy("build.across_targets_in_parallel", false). If we manually do this, the build goes through. The expected behavior is that xmake should automatically enforce this when necessary.
Error output
checking for gcc-11 ... /usr/local/bin/gcc-11
checking for the c++ compiler (cxx) ... gcc-11
checking for /usr/local/bin/gcc-11 ... ok
checking for flags (-fmodules-ts) ... ok
generating.moduledeps mod.mpp
checking for g++-11 ... /usr/local/bin/g++-11
checking for the linker (ld) ... g++-11
checking for flags (-std=c++20) ... ok
checking for flags (-fmodules-ts) ... ok
checking for ccache ... no
[ 22%]: compiling.release main.cpp
/usr/local/bin/gcc-11 -c -m64 -std=c++20 -fmodules-ts -o build/.objs/main/macosx/x86_64/release/main.cpp.o main.cpp
[ 22%]: compiling.release mod.mpp
/usr/local/bin/gcc-11 -c -m64 -std=c++20 -fmodules-ts -x c++ -o build/.objs/mod/macosx/x86_64/release/mod.mpp.o mod.mpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
error: In module imported at main.cpp:1:1:
mod: error: failed to read compiled module: No such file or directory
mod: note: compiled module file is 'gcm.cache/mod.gcm'
mod: note: imports must be built before being imported
mod: fatal error: returning to the gate for a mechanical issue
compilation terminated.
Related Environment
xmake version: v2.5.9+202110311547
os: macOS Big Sur v11.6.1
target platform: x86_64
The text was updated successfully, but these errors were encountered:
BTW, the same example also doesn't work with clang. This time, there are two simultaneous reasons. The first reason is this bug. The second reason is that xmake forgets to append the -fmodules-cache-path flag when compiling the binary target. Obviously, it should have added the flag because the binary depends on the static library, which is declared with the add_deps call in the make file. Please consider this as another distinct bug report. I am not opening a separate issue for this second bug, since the minimal example to reproduce is the same and I don't want to clutter your issues list. We can discuss both here. Thanks!
Describe the bug
The order of compilation is not correct when building a multi-target C++20 project with modules. The likely culprit is the wrong handling of parallelization across targets. Here are the files to reproduce:
To reliably reproduce, use:
Expected behavior
The build should go through and the static library should be built before the binary. Note that we can force this to happen by uncommenting the line
set_policy("build.across_targets_in_parallel", false)
. If we manually do this, the build goes through. The expected behavior is that xmake should automatically enforce this when necessary.Error output
Related Environment
The text was updated successfully, but these errors were encountered: