xmake-io / xmake

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

With set_toolchains("@cosmocc") : fatal error: string: No such file or directory #5263

Open raphael10-collab opened 2 months ago

raphael10-collab commented 2 months ago

Xmake Version

v2.9.3+20240626

Operating System Version and Architecture

Ubuntu 23.10

Describe Bug

With this xmake.lua file :

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

add_requires("cosmocc")

target("isdigits")
    set_kind("binary")
    add_files("/home/raphy/isdigits/src/*.cpp")
    --set_toolchains("@cosmocc")

It works fine :

raphy@raohy:~$ xmake f -o /home/raphy/isdigits/builddir

raphy@raohy:~$ xmake
[ 50%]: cache compiling.release isdigits/src/isdigits.cpp
[ 75%]: linking.release isdigits
[100%]: build ok, spent 0,482s

raphy@raohy:~$ ./isdigits/builddir/linux/x86_64/release/isdigits 
Only digits

Alpha Numerical

If I activate this line : set_toolchains("@cosmocc") :

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

add_requires("cosmocc")

target("isdigits")
    set_kind("binary")
    add_files("/home/raphy/isdigits/src/*.cpp")
    set_toolchains("@cosmocc")

I get that error :

raphy@raohy:~$ xmake
[ 50%]: cache compiling.release isdigits/src/isdigits.cpp
error: isdigits/src/isdigits.cpp:3:10: fatal error: string: No such file or directory
    3 | #include <string>
      |          ^~~~~~~~
compilation terminated.
  > in isdigits/src/isdigits.cpp

Output of xmake -v :

raphy@raohy:~$ xmake -v
[ 50%]: cache compiling.release isdigits/src/isdigits.cpp
/home/raphy/.xmake/packages/c/cosmocc/3.4.0/7e5513266cda47b5b64419a0b92403ee/bin/cosmocc -c -fvisibility=hidden -DNDEBUG -o isdigits/builddir/.objs/isdigits/linux/x86_64/release/isdigits/src/isdigits.cpp.o isdigits/src/isdigits.cpp
error: isdigits/src/isdigits.cpp:3:10: fatal error: string: No such file or directory
    3 | #include <string>
      |          ^~~~~~~~
compilation terminated.

Expected Behavior

No errors

Project Configuration

raphy@raohy:~$ nano xmake.lua : 

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

add_requires("cosmocc")

target("isdigits")
    set_kind("binary")
    add_files("/home/raphy/isdigits/src/*.cpp")
    set_toolchains("@cosmocc")

Minimal Reproducible Example Project :

https://github.com/raphael10-collab/isdigits.git

Additional Information and Error Logs

raphy@raohy:~$ xmake -vD
[ 50%]: cache compiling.release isdigits/src/isdigits.cpp
/home/raphy/.xmake/packages/c/cosmocc/3.4.0/7e5513266cda47b5b64419a0b92403ee/bin/cosmocc -c -fvisibility=hidden -DNDEBUG -o isdigits/builddir/.objs/isdigits/linux/x86_64/release/isdigits/src/isdigits.cpp.o isdigits/src/isdigits.cpp
error: ./.local/share/xmake/core/main.lua:329: ./.local/share/xmake/actions/build/main.lua:148: ./.local/share/xmake/modules/async/runjobs.lua:325: ...ocal/share/xmake/modules/private/action/build/object.lua:91: ./.local/share/xmake/modules/core/tools/gcc.lua:916: isdigits/src/isdigits.cpp:3:10: fatal error: string: No such file or directory
    3 | #include <string>
      |          ^~~~~~~~
compilation terminated.
stack traceback:
    [C]: in function 'error'
    [./.local/share/xmake/core/base/os.lua:973]:
    [./.local/share/xmake/modules/core/tools/gcc.lua:916]: in function 'catch'
    [./.local/share/xmake/core/sandbox/modules/try.lua:123]: in function 'try'
    [./.local/share/xmake/modules/core/tools/gcc.lua:857]:
    [C]: in function 'xpcall'
    [./.local/share/xmake/core/base/utils.lua:275]:
    [./.local/share/xmake/core/tool/compiler.lua:278]: in function 'compile'
    [...ocal/share/xmake/modules/private/action/build/object.lua:91]: in function 'script'
    [...ocal/share/xmake/modules/private/action/build/object.lua:122]: in function 'build_object'
    [...ocal/share/xmake/modules/private/action/build/object.lua:147]: in function 'jobfunc'
    [./.local/share/xmake/modules/async/runjobs.lua:241]:
    [C]: in function 'xpcall'
    [./.local/share/xmake/core/base/utils.lua:275]: in function 'trycall'
    [./.local/share/xmake/core/sandbox/modules/try.lua:117]: in function 'try'
    [./.local/share/xmake/modules/async/runjobs.lua:223]: in function 'cotask'
    [./.local/share/xmake/core/base/scheduler.lua:406]:

stack traceback:
    [C]: in function 'error'
    ./.local/share/xmake/core/base/os.lua:973: in function 'os.raiselevel'
    (...tail calls...)
    ./.local/share/xmake/core/main.lua:329: in upvalue 'cotask'
    ./.local/share/xmake/core/base/scheduler.lua:406: in function <./.local/share/xmake/core/base/scheduler.lua:399>
raphy@raohy:~$ 
waruqi commented 2 months ago

duplicate https://github.com/xmake-io/xmake/discussions/5262#discussioncomment-9890986