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

Compile command does not work on OS X #6

Open
cosmikwolf opened this issue Apr 23, 2024 · 2 comments
Open

Compile command does not work on OS X #6

cosmikwolf opened this issue Apr 23, 2024 · 2 comments

Comments

@cosmikwolf
Copy link

The standard compile command that was provided in the readme attempts to use the built in OS X version of clangd, which fails:

[44/44] Linking CXX executable xsca
FAILED: xsca 
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -fno-exceptions -fno-rtti -pthread -no-pie -O0 -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/xsca.dir/cc1_main.cpp.o CMakeFiles/xsca.dir/driver.cpp.o CMakeFiles/xsca.dir/xsca_gen.cpp.o CMakeFiles/xsca.dir/xsca_link.cpp.o -o xsca -L/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib -Wl,-rpath,/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib  core/libxscaCore.a  rules/libxscaRule.a  -Wl,--start-group  -lclangAnalysis  -lclangAST  -lclangBasic  -lclangDriver  -lclangEdit  -lclangFrontend  -lclangFrontendTool  -lclangLex  -lclangParse  -lclangRewrite  -lclangRewriteFrontend  -lclangSema  -lclangSerialization  -lclangTooling  -lLLVMBinaryFormat  -lLLVMBitReader  -lLLVMBitstreamReader  -lLLVMCore  -lLLVMDemangle  -lLLVMFrontendOpenMP  -lLLVMMC  -lLLVMMCParser  -lLLVMOption  -lLLVMProfileData  -lLLVMRemarks  -lLLVMSupport  -Wl,--end-group  -lm  -ldl  -lrt  -lpthread  rules/GJB5369/libxscaGJB5369Rule.a  rules/GJB8114/libxscaGJB8114Rule.a  rules/MISRA/libxscaMISRARule.a  rules/CERT/libxscaCERTRule.a  rules/AUTOSAR/libxscaAUTOSARRule.a  rules/libxscaRule.a  rules/GJB5369/libxscaGJB5369Rule.a  rules/GJB8114/libxscaGJB8114Rule.a  rules/MISRA/libxscaMISRARule.a  rules/CERT/libxscaCERTRule.a  rules/AUTOSAR/libxscaAUTOSARRule.a  core/libxscaCore.a && :
clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
ld: unknown options: --start-group --end-group 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

In order to use the homebrew installed version, I had to use the following command:

fsh ❯ cmake -G Ninja -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ ../src

And then it compiled properly

@cosmikwolf
Copy link
Author

scratch that, it still doesn't compile properly. still troubleshooting...

@cosmikwolf
Copy link
Author

cosmikwolf commented Apr 23, 2024

It seems like this was the original issue, since the mac os system /usr/bin/ld doesn't support start-group and end-group
https://stackoverflow.com/questions/10286850/using-llvm-linker-when-using-clang-cmake

but I was able to seemingly get it to use the homebrew version of lld with this:

cmake -G Ninja -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ -DCMAKE_C_FLAGS="-B /opt/homebrew/opt/llvm/bin" -DCMAKE_CXX_FLAGS="-B /opt/homebrew/opt/llvm/bin" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld"  ../src

but it still fails:

[44/44] Linking CXX executable xsca
FAILED: xsca 
: && /opt/homebrew/opt/llvm/bin/clang++ -B /opt/homebrew/opt/llvm/bin -fno-exceptions -fno-rtti -pthread -no-pie -O0 -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -mmacosx-version-min=14.3 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -fuse-ld=lld CMakeFiles/xsca.dir/cc1_main.cpp.o CMakeFiles/xsca.dir/driver.cpp.o CMakeFiles/xsca.dir/xsca_gen.cpp.o CMakeFiles/xsca.dir/xsca_link.cpp.o -o xsca -L/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib -Wl,-rpath,/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib  core/libxscaCore.a  rules/libxscaRule.a  -Wl,--start-group  -lclangAnalysis  -lclangAST  -lclangBasic  -lclangDriver  -lclangEdit  -lclangFrontend  -lclangFrontendTool  -lclangLex  -lclangParse  -lclangRewrite  -lclangRewriteFrontend  -lclangSema  -lclangSerialization  -lclangTooling  -lLLVMBinaryFormat  -lLLVMBitReader  -lLLVMBitstreamReader  -lLLVMCore  -lLLVMDemangle  -lLLVMFrontendOpenMP  -lLLVMMC  -lLLVMMCParser  -lLLVMOption  -lLLVMProfileData  -lLLVMRemarks  -lLLVMSupport  -Wl,--end-group  -lm  -ldl  -lrt  -lpthread  rules/GJB5369/libxscaGJB5369Rule.a  rules/GJB8114/libxscaGJB8114Rule.a  rules/MISRA/libxscaMISRARule.a  rules/CERT/libxscaCERTRule.a  rules/AUTOSAR/libxscaAUTOSARRule.a  rules/libxscaRule.a  rules/GJB5369/libxscaGJB5369Rule.a  rules/GJB8114/libxscaGJB8114Rule.a  rules/MISRA/libxscaMISRARule.a  rules/CERT/libxscaCERTRule.a  rules/AUTOSAR/libxscaAUTOSARRule.a  core/libxscaCore.a && :
clang++: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
ld64.lld: error: unknown argument '--start-group'
ld64.lld: error: unknown argument '--end-group'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

running the clang++ command manually in verbose mode reveals it is using homebrew llvm for linking:

fsh ❯ /opt/homebrew/opt/llvm/bin/clang++ -B /opt/homebrew/opt/llvm/bin -fno-exceptions -fno-rtti -pthread -no-pie -O0 -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -mmacosx-version-min=14.3 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -fuse-ld=lld CMakeFiles/xsca.dir/cc1_main.cpp.o CMakeFiles/xsca.dir/driver.cpp.o CMakeFiles/xsca.dir/xsca_gen.cpp.o CMakeFiles/xsca.dir/xsca_link.cpp.o -o xsca -L/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib -Wl,-rpath,/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib  core/libxscaCore.a  rules/libxscaRule.a  -Wl,--start-group  -lclangAnalysis  -lclangAST  -lclangBasic  -lclangDriver  -lclangEdit  -lclangFrontend  -lclangFrontendTool  -lclangLex  -lclangParse  -lclangRewrite  -lclangRewriteFrontend  -lclangSema  -lclangSerialization  -lclangTooling  -lLLVMBinaryFormat  -lLLVMBitReader  -lLLVMBitstreamReader  -lLLVMCore  -lLLVMDemangle  -lLLVMFrontendOpenMP  -lLLVMMC  -lLLVMMCParser  -lLLVMOption  -lLLVMProfileData  -lLLVMRemarks  -lLLVMSupport  -Wl,--end-group  -lm  -ldl  -lrt  -lpthread  rules/GJB5369/libxscaGJB5369Rule.a  rules/GJB8114/libxscaGJB8114Rule.a  rules/MISRA/libxscaMISRARule.a  rules/CERT/libxscaCERTRule.a  rules/AUTOSAR/libxscaAUTOSARRule.a  rules/libxscaRule.a  rules/GJB5369/libxscaGJB5369Rule.a  rules/GJB8114/libxscaGJB8114Rule.a  rules/MISRA/libxscaMISRARule.a  rules/CERT/libxscaCERTRule.a  rules/AUTOSAR/libxscaAUTOSARRule.a  core/libxscaCore.a -v
Homebrew clang version 17.0.6
Target: arm64-apple-darwin23.3.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
clang++: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
 "/opt/homebrew/opt/llvm/bin/ld64.lld" -demangle -no_deduplicate -dynamic -arch arm64 -platform_version macos 14.3.0 14.4 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -o xsca -L/Users/tenkai/Development/language_servers/clang-prebuilt/release/lib -search_paths_first -headerpad_max_install_names CMakeFiles/xsca.dir/cc1_main.cpp.o CMakeFiles/xsca.dir/driver.cpp.o CMakeFiles/xsca.dir/xsca_gen.cpp.o CMakeFiles/xsca.dir/xsca_link.cpp.o -rpath /Users/tenkai/Development/language_servers/clang-prebuilt/release/lib core/libxscaCore.a rules/libxscaRule.a --start-group -lclangAnalysis -lclangAST -lclangBasic -lclangDriver -lclangEdit -lclangFrontend -lclangFrontendTool -lclangLex -lclangParse -lclangRewrite -lclangRewriteFrontend -lclangSema -lclangSerialization -lclangTooling -lLLVMBinaryFormat -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMDemangle -lLLVMFrontendOpenMP -lLLVMMC -lLLVMMCParser -lLLVMOption -lLLVMProfileData -lLLVMRemarks -lLLVMSupport --end-group -lm -ldl -lrt -lpthread rules/GJB5369/libxscaGJB5369Rule.a rules/GJB8114/libxscaGJB8114Rule.a rules/MISRA/libxscaMISRARule.a rules/CERT/libxscaCERTRule.a rules/AUTOSAR/libxscaAUTOSARRule.a rules/libxscaRule.a rules/GJB5369/libxscaGJB5369Rule.a rules/GJB8114/libxscaGJB8114Rule.a rules/MISRA/libxscaMISRARule.a rules/CERT/libxscaCERTRule.a rules/AUTOSAR/libxscaAUTOSARRule.a core/libxscaCore.a -lc++ -lSystem /opt/homebrew/Cellar/llvm/17.0.6_1/lib/clang/17/lib/darwin/libclang_rt.osx.a
ld64.lld: error: unknown argument '--start-group'
ld64.lld: error: unknown argument '--end-group'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

this is the version of ld:

labrador/build on  master [!?] via △ v3.29.2 on ☁️  (us-west-1) 
fsh ❯ /opt/homebrew/opt/llvm/bin/ld64.lld --version
Homebrew LLD 17.0.6

so, I am out of ideas :D I might try again later today

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

1 participant