-
Notifications
You must be signed in to change notification settings - Fork 9
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
LLVM ERROR: inconsistency in registered CommandLine options / undefined reference to `backtrace' #71
Comments
Hello! Which operating system are you using and how did you install LLVM? |
I just pushed an LLVM 12 upgrade commit to main. I doubt it will fix your error but you could give it a try just in case. |
I,ve tried master again and I still get the same error. I am running my own custom musl based Linux distribution similar to Void Linux and Alpine Linux.
backtrace:
|
According to ziglang/zig#67, when using a dylib build of LLVM, you need to link to the single LLVM dylib instead of the component libs, like so: diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65cea2a3..c50b6b4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,7 +66,11 @@ file(GLOB_RECURSE CX_SOURCES src/*.h src/*.cpp)
add_executable(cx ${CX_SOURCES})
target_precompile_headers(cx PRIVATE src/pch.h)
-llvm_map_components_to_libnames(LLVM_LIBS core native linker support)
+if (LLVM_LINK_LLVM_DYLIB)
+ set(LLVM_LIBS LLVM)
+else()
+ llvm_map_components_to_libnames(LLVM_LIBS core native linker support)
+endif()
list(APPEND LLVM_LIBS clangAST clangBasic clangFrontend clangLex clangParse clangSema)
target_link_libraries(cx ${LLVM_LIBS}) Does the above patch (or something along those lines) help? This matches what is being done e.g. in flang: https://github.com/llvm/llvm-project/blob/062644bb399bd05fd0aeb3cb9d52fa0014db0bdd/flang/unittests/Runtime/CMakeLists.txt#L11-L15 |
Thanks for the patch! It worked great :) Now I have an usable cx binary! |
I try to compile a simple example:
and I get this error:
if I try to add --fpic option I get this error:
update: I've added libexecinfo package to cover the backtrace error but didn't help that much. update2: I've managed to run the example by removing some content of std/os/gnu.cx file for now. I'm very excited to explare the language further. Thanks for all the help I got! update3: I cloned the master again and I am able to run everything without any patch or changes to the code. Good work! |
I added a commit to change the compiler to emit position-independent code by default, that should fix the first error without having to use --fpic. For the second error: there was a similar issue a while back: #48. Musl libc doesn't have execinfo.h, but in your case the compiler still finds execinfo.h on your system (source). Maybe the compiler finds some other execinfo.h from another libc? Can you check if this is the case? The relevant code is in parse.cpp: Lines 1426 to 1432 in ee51593
|
As I mentioned before I am fully able to build and run cx wıth the hello example. I'll only have musl libc so I'll check if that is the case. update: You were right about it. I seem to have .../zig/libc/include/generic-glibc/execinfo.h as well. update2: I removed the execinfo.h from the system by uninstalling zig and libexecinfo package. And I have fully working cx that compiles fine. Great! |
Oh great! I'll close this issue then and rename it to more accurately reflect the underlying problem. Also would be nice if the compiler supported having multiple libc's side by side without finding the wrong header. I created an issue for this: #72. But it isn't critical yet since you got the issue figured out by other means, so this can be implemented later. Thanks for reporting the issues! |
hello I love the idea of this programming language and I would like to try it out, right now I am running on llvm 12 and I managed to set CMakeLists.txt to search for newer version of llvm and compiled it successfully. However it gives me error when running the cx executable. Something to do with invalid arguments:
The text was updated successfully, but these errors were encountered: