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

bbl-translate fails to #include babble when compiled on macOS #11

Open
expenses opened this issue Jan 30, 2024 · 6 comments
Open

bbl-translate fails to #include babble when compiled on macOS #11

expenses opened this issue Jan 30, 2024 · 6 comments

Comments

@expenses
Copy link

expenses commented Jan 30, 2024

I'm trying to build babble on mac (#10 branch). I'm compiling with the homebrew-installed llvm and zig cc as a compiler as it uses its own toolchain and avoids some of the problems I've been having with native/homebrew clang. The full build script is
CC=zig-cc CXX=zig-c++ cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=install -DLLVM_DIR=/usr/local/Cellar/llvm/17.0.6_1/lib/cmake/llvm/ && cmake --build build

(zig-cc and zig-c++ are just files installed in ~/.local/bin containing zig c++ $@ etc.).

I'm getting this issue with the tests where bbl-translate is run:

[13/31] Linking CXX static library test/stdfunction/libstdfunction-bind-dummy.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: test/stdfunction/libstdfunction-bind-dummy.a(bind.cpp.o) has no symbols
[16/31] Generating smartptr-c.cpp
FAILED: test/smartptr/smartptr-c.cpp /Users/ashley/babble/build/test/smartptr/smartptr-c.cpp
cd /Users/ashley/babble/build/test/smartptr && /Users/ashley/babble/build/bbl/bbl-translate /Users/ashley/babble/test/smartptr/bind.cpp -- -std=c++17 -fsyntax-only -fno-spell-checking -I/usr/local/opt/llvm/lib/clang/17/include -I/Users/ashley/babble/bbl/include -I/Users/ashley/babble/test/smartptr -- smartptr -o /Users/ashley/babble/build/test/smartptr
/Users/ashley/babble/test/smartptr/bind.cpp:1:10: fatal error: cannot open file '/Users/ashley/babble/test/smartptr/babble': No such file or directory
    1 | #include "babble"
      |          ^
[2024-01-30 16:13:10.335] [info] [cpp_context.cpp:2872] ASTs built in 1.0951439109999999s
[2024-01-30 16:13:10.340] [error] [api_cpp_context.cpp:45] /Users/ashley/babble/bbl/src/cpp_context.cpp:2885 compilation generated 3045 errors. Cannot continue
[2024-01-30 16:13:10.341] [error] [bbl-translate.cpp:491] extraction failed after 1.1113919739999998s

I don't really know what to make of it.

@anderslanglands
Copy link
Owner

Assuming that babble is indeed in Users/ashley/babble/bbl/include, what happens if you change

#include "babble"

to

#include <babble>

in the smartptr bindfile?

@expenses
Copy link
Author

expenses commented Feb 2, 2024

Changing to

#include <babble>

results in a different but similar error message:
/Users/ashley/babble/build/bbl/bbl-translate /Users/ashley/babble/test/stdfunction/bind.cpp -- -std=c++17 -fsyntax-only -fno-spell-checking -I/usr/local/opt /llvm/lib/clang/17/include -I/Users/ashley/babble/bbl/include -I/Users/ashley/babble/test/stdfunction -- stdfunction -o /Users/ashley/babble/build/test/stdfunction

/Users/ashley/babble/test/stdfunction/bind.cpp:1:10: fatal error: cannot open file '/usr/local/opt/llvm/lib/clang/17/include/babble': No such file or directory

    1 | #include <babble>
      |          ^

If I remove the first include from the bbl-translate invocation (-I/usr/local/opt/llvm/lib/clang/17/include) then I get a different error:
/Users/ashley/babble/build/bbl/bbl-translate /Users/ashley/babble/test/stdfunction/bind.cpp -- -std=c++17 -fsyntax-only -fno-spell-checking -I/Users/ashley/babble/bbl/include -I/Users/ashley/babble/test/stdfunction -- stdfunction -o /Users/ashley/babble/build/test/stdfunction

/Users/ashley/babble/bbl/include/babble:4:10: fatal error: cannot open file '/Users/ashley/babble/bbl/include/type_traits': No such file or directory

I get the same error if I just reorder the includes to this:
/Users/ashley/babble/build/bbl/bbl-translate /Users/ashley/babble/test/stdfunction/bind.cpp -- -std=c++17 -fsyntax-only -fno-spell-checking -I/Users/ashley/babble/bbl/include -I/usr/local/opt/llvm/lib/clang/17/include -I/Users/ashley/babble/test/stdfunction -- stdfunction -o /Users/ashley/babble/build/test/stdfunction

It seems like only the first -I flag is being registered for whatever reason.

@expenses
Copy link
Author

expenses commented Feb 2, 2024

Actually even with
/Users/ashley/babble/build/bbl/bbl-translate /Users/ashley/babble/test/stdfunction/bind.cpp -- -std=c++17 -fsyntax-only -fno-spell-checking -I/Users/ashley/babble/bbl/include ...
I still get
/Users/ashley/babble/test/stdfunction/bind.cpp:1:10: fatal error: cannot open file '/Users/ashley/babble/test/stdfunction/babble': No such file or directory
so I'm not really sure my hypothesis holds up. Something is definitely funky with how the -I flags are handled though.

@anderslanglands
Copy link
Owner

anderslanglands commented Feb 2, 2024 via email

@expenses
Copy link
Author

expenses commented Feb 2, 2024

The <type_traits> error I know the cause and can hopefully provide a fix soon.

Okay great, I've had a bit more success compiling in a nix shell with nix-shell -p llvm libclang and that's the next error to fix.

@anderslanglands
Copy link
Owner

Just following up on this, the type_traits error should now be fixed

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

No branches or pull requests

2 participants