Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ newly added module import not being found #5663

Open
ilobilo opened this issue Sep 25, 2024 · 5 comments
Open

C++ newly added module import not being found #5663

ilobilo opened this issue Sep 25, 2024 · 5 comments
Labels

Comments

@ilobilo
Copy link

ilobilo commented Sep 25, 2024

Xmake Version

2.9.5

Operating System Version and Architecture

Fedora KDE 40

Describe Bug

I have an issue when newly imported C++ modules are not being found (so adding import existing_module; to a source file). but if I do a clean rebuild with xmake clean --all and xmake build, no errors are thrown

Expected Behavior

finds the available modules

Project Configuration

compiles modules normally, nothing special

Additional Information and Error Logs

nope

@ilobilo ilobilo added the bug label Sep 25, 2024
@waruqi
Copy link
Member

waruqi commented Sep 26, 2024

Can you provide an example? and logs?

@ilobilo
Copy link
Author

ilobilo commented Sep 26, 2024

let's say that the following compiles fine:
main.cpp

import one;
import two;

int main()
{
    onefunc();
    twofunc();
    return 0;
}

one.cppm

export module one;
export void onefunc() { }

two.cppm

export module two;
export void twofunc() { }

now, if I modify two.cppm to this:

export module two;
import one;
export void twofunc() { onefunc(); }

I get an error about module one not being found. If I run xmake clean --all and xmake build, then it compiles. I believe Arthapz in the discord server said that this was a known issue.

error: two.cppm:2:8: fatal error: module 'one' not found
2 | import one;
| ~~~~~~~^~~~~~
1 error generated.

@waruqi
Copy link
Member

waruqi commented Sep 29, 2024

it works for me.

ruki-2:test ruki$ xmake f --toolchain=llvm -c
checking for platform ... macosx
checking for architecture ... x86_64
checking for Xcode directory ... /Applications/Xcode.app
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
ruki-2:test ruki$ xmake -rv
checking for flags (clang_print_library_module_manifest_path) ... no
[  0%]: <hello> generating.module.deps src/main.cpp
[  0%]: <hello> generating.module.deps src/one.cppm
[  0%]: <hello> generating.module.deps src/two.cppm
[  0%]: <hello> generating.module.deps /usr/local/Cellar/llvm/18.1.5/bin/../lib/c++/../../share/l
ibc++/v1/std.cppm
[  0%]: <hello> generating.module.deps /usr/local/Cellar/llvm/18.1.5/bin/../lib/c++/../../share/l
ibc++/v1/std.compat.cppm
checking for /usr/local/Cellar/llvm/18.1.5/bin/clang-scan-deps ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-std=c++20) ... ok
checking for flags (-DNDEBUG) ... ok
/usr/local/Cellar/llvm/18.1.5/bin/clang-scan-deps --format=p1689 -- /usr/local/Cellar/llvm/18.1.5
/bin/clang -x c++ -c src/main.cpp -o build/.objs/hello/macosx/x86_64/release/src/main.cpp.o -Qunu
sed-arguments -m64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -DN
DEBUG
/usr/local/Cellar/llvm/18.1.5/bin/clang-scan-deps --format=p1689 -- /usr/local/Cellar/llvm/18.1.5
/bin/clang -x c++ -c src/two.cppm -o build/.objs/hello/macosx/x86_64/release/src/two.cppm.o -Qunu
sed-arguments -m64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -DN
DEBUG
/usr/local/Cellar/llvm/18.1.5/bin/clang-scan-deps --format=p1689 -- /usr/local/Cellar/llvm/18.1.5
/bin/clang -x c++ -c /usr/local/Cellar/llvm/18.1.5/bin/../lib/c++/../../share/libc++/v1/std.cppm
-o build/.objs/hello/macosx/x86_64/release/usr/local/Cellar/llvm/18.1.5/bin/__/lib/c++/__/__/shar
e/libc++/v1/std.cppm.o -Qunused-arguments -m64 -isysroot /Applications/Xcode.app/Contents/Develop
er/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -fvisibility-inlin
es-hidden -O3 -std=c++20 -DNDEBUG
/usr/local/Cellar/llvm/18.1.5/bin/clang-scan-deps --format=p1689 -- /usr/local/Cellar/llvm/18.1.5
/bin/clang -x c++ -c /usr/local/Cellar/llvm/18.1.5/bin/../lib/c++/../../share/libc++/v1/std.compa
t.cppm -o build/.objs/hello/macosx/x86_64/release/usr/local/Cellar/llvm/18.1.5/bin/__/lib/c++/__/
__/share/libc++/v1/std.compat.cppm.o -Qunused-arguments -m64 -isysroot /Applications/Xcode.app/Co
ntents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -fvi
sibility-inlines-hidden -O3 -std=c++20 -DNDEBUG
/usr/local/Cellar/llvm/18.1.5/bin/clang-scan-deps --format=p1689 -- /usr/local/Cellar/llvm/18.1.5
/bin/clang -x c++ -c src/one.cppm -o build/.objs/hello/macosx/x86_64/release/src/one.cppm.o -Qunu
sed-arguments -m64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++20 -DN
DEBUG
[ 37%]: <hello> compiling.module.release two
[ 50%]: <hello> compiling.module.release one
checking for flags (clang_module_output) ... ok
/usr/local/Cellar/llvm/18.1.5/bin/clang -c -Qunused-arguments -m64 -isysroot /Applications/Xcode.
app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidde
n -fvisibility-inlines-hidden -O3 -std=c++20 -DNDEBUG -x c++-module -fmodule-output=build/.gens/h
ello/macosx/x86_64/release/rules/bmi/cache/modules/c83caa2b/two.pcm -o build/.objs/hello/macosx/x
86_64/release/src/two.cppm.o src/two.cppm
checking for flags (-fdiagnostics-color=always) ... ok
/usr/local/Cellar/llvm/18.1.5/bin/clang -c -Qunused-arguments -m64 -isysroot /Applications/Xcode.
app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidde
n -fvisibility-inlines-hidden -O3 -std=c++20 -DNDEBUG -x c++-module -fmodule-output=build/.gens/h
ello/macosx/x86_64/release/rules/bmi/cache/modules/c83caa2b/one.pcm -o build/.objs/hello/macosx/x
86_64/release/src/one.cppm.o src/one.cppm
checking for flags (clang_module_file) ... ok
[ 75%]: compiling.release src/main.cpp
/usr/local/Cellar/llvm/18.1.5/bin/clang -c -Qunused-arguments -m64 -isysroot /Applications/Xcode.
app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidde
n -fvisibility-inlines-hidden -O3 -std=c++20 -DNDEBUG -fmodule-file=one=build/.gens/hello/macosx/
x86_64/release/rules/bmi/cache/modules/c83caa2b/one.pcm -fmodule-file=two=build/.gens/hello/macos
x/x86_64/release/rules/bmi/cache/modules/c83caa2b/two.pcm -o build/.objs/hello/macosx/x86_64/rele
ase/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for clang++ ... /usr/local/Cellar/llvm/18.1.5/bin/clang++
checking for the linker (ld) ... clang++
checking for /usr/local/Cellar/llvm/18.1.5/bin/clang++ ... ok
checking for flags (-fPIC) ... ok
[ 87%]: linking.release hello
/usr/local/Cellar/llvm/18.1.5/bin/clang++ -o build/macosx/x86_64/release/hello build/.objs/hello/
macosx/x86_64/release/src/main.cpp.o build/.objs/hello/macosx/x86_64/release/src/one.cppm.o build
/.objs/hello/macosx/x86_64/release/src/two.cppm.o -m64 -isysroot /Applications/Xcode.app/Contents
/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -Wl,-x -Wl,-dead_strip
[100%]: build ok, spent 3.792s
ruki-2:test ruki$ vim ./src/two.cppm

ruki-2:test ruki$ cat ./src/two.cppm
export module two;
import one;
export void twofunc() { onefunc(); }

ruki-2:test ruki$ xmake
[  0%]: <hello> generating.module.deps src/two.cppm
[ 50%]: <hello> compiling.module.release two
[ 75%]: compiling.release src/main.cpp
[ 87%]: linking.release hello
[100%]: build ok, spent 0.86s
ruki-2:test ruki$ xmake clean --all
ruki-2:test ruki$ xmake
checking for platform ... macosx
checking for architecture ... x86_64
checking for Xcode directory ... /Applications/Xcode.app
checking for Codesign Identity of Xcode ... Apple Development: [email protected] (T3NA4MRVPU)
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.0
[  0%]: <hello> generating.module.deps src/main.cpp
[  0%]: <hello> generating.module.deps src/one.cppm
[  0%]: <hello> generating.module.deps src/two.cppm
[ 37%]: <hello> compiling.module.release one
[ 50%]: <hello> compiling.module.release two
[ 75%]: compiling.release src/main.cpp
[ 87%]: linking.release hello
[100%]: build ok, spent 2.228s
warning: std and std.compat modules not found ! disabling them for the build, maybe try to add --
sdk=<PATH/TO/LLVM>
warning: add -v for getting more warnings ..

@ilobilo
Copy link
Author

ilobilo commented Sep 29, 2024

I don't know why that is, I'm having this issue constantly, on almost every added import. And not on a single project, but on others as well. On at least 2 distros (Ubuntu and Fedora) and both clang 18 and 19

@ilobilo
Copy link
Author

ilobilo commented Sep 29, 2024

newly added import system.memory.virt; line here
image
modules and source files are compiled in different targets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants