xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.82k stars 775 forks source link

compiler(gcc) does not support c++ module #5191

Closed paulross80 closed 3 months ago

paulross80 commented 3 months ago

Xmake Version

xmake v2.9.2+20240525

Operating System Version and Architecture

Fedora 40 KDE x86_64

Describe Bug

Copied almost exactly the hello modules example, got gcc not supporting modules message

Expected Behavior

Expected to compile

Project Configuration

add_rules("mode.release", "mode.debug")
set_languages("c++23")

target("hello")
    set_kind("binary")
    add_files("cpp/*.cpp", "cpp/*.mpp")

Additional Information and Error Logs

gcc --version gcc (GCC) 14.1.1 20240522 (Red Hat 14.1.1-4)

xmake -v checking for platform ... linux checking for architecture ... x86_64 checking for gcc ... /usr/bin/gcc checking for zig ... no checking for zig ... no checking for nim ... no checking for nim ... no checking for gcc ... /usr/bin/gcc checking for the c++ compiler (cxx) ... gcc checking for /usr/bin/gcc ... ok checking for flags (-fPIC) ... no checking for flags (gcc_modules_ts) ... no error: compiler(gcc): does not support c++ module!

waruqi commented 3 months ago

It works for me on my fedora.

bash-5.2$ gcc --version
gcc (GCC) 14.0.1 20240411 (Red Hat 14.0.1-0)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bash-5.2$ xmake f -cvD
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
> gcc "-fPIC" "-m64"
checking for flags (gcc_modules_ts) ... ok
> gcc "-fmodules-ts" "-m64"
configure
{
    ccache = true
    kind = static
    clean = true
    host = linux
    mode = release
    arch = x86_64
    ndk_stdcxx = true
    buildir = build
    plat = linux
}
bash-5.2$ xmake -rv
checking for flags (gcc_deps_format) ... ok
checking for flags (gcc_deps_file) ... ok
checking for flags (gcc_deps_output) ... ok
[  0%]: <hello> generating.module.deps src/main.cpp
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-std=c++20) ... ok
checking for flags (-D_GLIBCXX_USE_CXX11_ABI=0) ... ok
checking for flags (-DNDEBUG) ... ok
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ src/main.cpp -MT build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/main.cpp.json -MD -MF build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/main.cpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/main.cpp.json -fdeps-target=build/.objs/hello/linux/x86_64/release/src/main.cpp.o -o build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/main.cpp.i
[  0%]: <hello> generating.module.deps src/hello.mpp
/usr/bin/gcc -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -E -x c++ src/hello.mpp -MT build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/hello.mpp.json -MD -MF build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/hello.mpp.d -fdeps-format=p1689r5 -fdeps-file=build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/hello.mpp.json -fdeps-target=build/.objs/hello/linux/x86_64/release/src/hello.mpp.o -o build/.gens/hello/linux/x86_64/release/rules/bmi/cache/modules/2d9b7c0b/hello.mpp.i
checking for flags (gcc_module_mapper) ... ok
[ 42%]: <hello> compiling.module.release hello
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake995/240605/hello/src/hello.mpp -x c++ -o build/.objs/hello/linux/x86_64/release/src/hello.mpp.o src/hello.mpp
checking for flags (-fdiagnostics-color=always) ... ok
[ 71%]: compiling.release src/main.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -fmodules-ts -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -fmodule-mapper=/tmp/.xmake995/240605/hello/src/main.cpp -o build/.objs/hello/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
checking for /usr/bin/g++ ... ok
checking for flags (-fPIC) ... ok
[ 85%]: linking.release hello
/usr/bin/g++ -o build/linux/x86_64/release/hello build/.objs/hello/linux/x86_64/release/src/main.cpp.o build/.objs/hello/linux/x86_64/release/src/hello.mpp.o -m64 -s
[100%]: build ok, spent 1.339s
waruqi commented 3 months ago

checking for flags (gcc_modules_ts) ... no

check -fmodules-ts failed. please run xmake f -cvD; xmake -rvD and give me a full logs again.

paulross80 commented 3 months ago

$ xmake f -cvD

checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... no
> gcc "-fPIC" "-m64"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: gcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or directory
compilation terminated.

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
    [@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
checking for flags (gcc_modules_ts) ... no
> gcc "-fmodules-ts" "-m64"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: gcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or directory
compilation terminated.

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
    [@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
error: @programdir/core/main.lua:329: @programdir/rules/c++/modules/modules_support/gcc/compiler_support.lua:149: compiler(gcc): does not support c++ module!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]: in function 'raiselevel'
    [@programdir/core/sandbox/modules/utils.lua:143]: in function 'assert'
    [@programdir/rules/c++/modules/modules_support/gcc/compiler_support.lua:149]: in function 'get_modulesflag'
    [@programdir/rules/c++/modules/modules_support/gcc/compiler_support.lua:55]: in function 'load'
    [@programdir/rules/c++/modules/modules_support/compiler_support.lua:64]: in function 'load'
    [@programdir/rules/c++/modules/xmake.lua:51]: in function 'on_config'
    [@programdir/core/sandbox/modules/import/core/project/project.lua:133]: in function '_config_target'
    [@programdir/core/sandbox/modules/import/core/project/project.lua:157]: in function '_config_targets'
    [@programdir/core/sandbox/modules/import/core/project/project.lua:208]: in function 'load_targets'
    [@programdir/actions/config/main.lua:407]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/main.lua:327]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:973: in function 'os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:329: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>

xmake -rvD

checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... no
> gcc "-fPIC" "-m64"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: gcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or directory
compilation terminated.

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
    [@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
checking for flags (gcc_modules_ts) ... no
> gcc "-fmodules-ts" "-m64"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: gcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or directory
compilation terminated.

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]:
    [@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
    [@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/import/core/base/task.lua:65: @programdir/rules/c++/modules/modules_support/gcc/compiler_support.lua:149: compiler(gcc): does not support c++ module!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:973]: in function 'raiselevel'
    [@programdir/core/sandbox/modules/utils.lua:143]: in function 'assert'
    [@programdir/rules/c++/modules/modules_support/gcc/compiler_support.lua:149]: in function 'get_modulesflag'
    [@programdir/rules/c++/modules/modules_support/gcc/compiler_support.lua:55]: in function 'load'
    [@programdir/rules/c++/modules/modules_support/compiler_support.lua:64]: in function 'load'
    [@programdir/rules/c++/modules/xmake.lua:51]: in function 'on_config'
    [@programdir/core/sandbox/modules/import/core/project/project.lua:133]: in function '_config_target'
    [@programdir/core/sandbox/modules/import/core/project/project.lua:157]: in function '_config_targets'
    [@programdir/core/sandbox/modules/import/core/project/project.lua:208]: in function 'load_targets'
    [@programdir/actions/config/main.lua:407]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/sandbox/modules/import/core/base/task.lua:63]: in function 'run'
    [@programdir/actions/build/main.lua:191]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:275]:
    [@programdir/core/base/task.lua:491]: in function 'run'
    [@programdir/core/main.lua:327]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:973: in function 'os.raiselevel'
        (...tail calls...)
        @programdir/core/main.lua:329: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>
waruqi commented 3 months ago

checkinfo: @programdir/core/sandbox/modules/os.lua:273: gcc: fatal error: cannot execute ‘cc1plus’: posix_spawnp: No such file or directory compilation terminated.

Did you install g++?

paulross80 commented 3 months ago

I've just installed gcc before, now it works, thanks!