-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
LLJIT running error "Segmentation fault: 11", while linking c++ standard libraries. #84
Comments
Why does it fail? When you step through your program, do you get to |
Probably best to build with debug info (-g) and with assertions enabled (including the LLVM libraries you're using - they should be built with both as well) - that's likely to produce a more informative error message. |
@dwblaikie LLVM was built by |
CMAKE will add -g when CMAKE_BUILD_TYPE=Debug.
Run ninja -v to see what is actually passed to each target.
hth...
don
…On Thu, Jan 2, 2020 at 3:29 AM vifird ***@***.***> wrote:
@dwblaikie <https://github.com/dwblaikie> LLVM was built by cmake -G
"Ninja" -DLLVM_ENABLE_PROJECTS="clang;" -DCMAKE_BUILD_TYPE=Debug
-DLLVM_ENABLE_ASSERTIONS=Yes ../llvm, this will include assertions.
And how to use -g?
This is all the error info now, there is no more.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#84?email_source=notifications&email_token=AAQVGNXOK7BZ5XJBMUARCIDQ3XF3HA5CNFSM4KBKJVLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH6EWFA#issuecomment-570182420>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQVGNS3ZKV4IAN62I7MTCDQ3XF3HANCNFSM4KBKJVLA>
.
|
Hi Vifird. I am not able to reproduce this locally. How are you building build/ffi? |
@lhames Thanks for concerning. It's built by |
Are you building build/ffi with the same libc++ that you’re using to build LLVM? Or are you using the built clang++ / libc++ to build build/ffi? It’s possible that this error is due an ABI incompatibility between libc++ versions. Side note:
By convention relocatable objects should have a “.o” extension, so “-c -o build/ffi.o”. You won’t fundamentally break anything by not using the suffix (to my knowledge), but it might be confusing for some tools, or when others look at your project. :) |
@lhames Thanks a lot. I didn't install llvm's libc++, and i think they ( build/main & build/ffi.o ) are using the same libc++, see below output: ➜ jit git:(master) ✗ otool -L build/main
build/main:
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)
➜ jit git:(master) ✗ otool -L build/ffi
build/ffi:
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.7.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
➜ I had changed my # LLVM
export PATH="/Users/vifird/C/compile/llvm-project/build/bin:$PATH"
export CC="/Users/vifird/C/compile/llvm-project/build/bin/clang"
export CXX="/Users/vifird/C/compile/llvm-project/build/bin/clang++"
export LDFLAGS="-L/Users/vifird/C/compile/llvm-project/build/lib"
export CPPFLAGS="-I/Users/vifird/C/compile/llvm-project/build/include:/Users/vifird/C/compile/llvm-project/llvm/include"
export CPLUS_INCLUDE_PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" ffi.cpp #include <iostream>
#include <vector>
extern "C" int add(int a, int b) {
std::vector<int> vc;
vc.push_back(1);
return a + b;
}
int main() {
printf(">>main run\n");
return add(1, 2);
} |
@lhames I had create a demo project to show this error in minimum code: https://github.com/vifird/jit. And i had tested it in two new MacBooks(MacOSX 10.15), those both displayed this error, so i think it may not be a problem of libc++. |
@vifird: Is build/ffi an executable? You shouldn’t be able to load that into the JIT at all. But if it’s a relocatable object it shouldn’t show anything listed for otool -L. I would be inclined to get hold of the preprocessed source for both main and ffi and compare the definition of their vector classes: The most likely explanation here is a difference in the vector definition being used by main and ffi. I’m out on vacation this week so I may not get a chance to reply further. Please ping me next week though and I can take another look. |
@lhames |
@lhames I had resolved this problem, by added auto jit =
ExitOnErr(LLJITBuilder()
.setJITTargetMachineBuilder(std::move(JTMB))
.setObjectLinkingLayerCreator([&](ExecutionSession &ES, const Triple &TT) {
return make_unique<ObjectLinkingLayer>(
ES, make_unique<jitlink::InProcessMemoryManager>());
})
.create()); Thanks a lot. This problem blocked me for a month. |
Hi @vifird. Sorry I was not able to get back to you sooner: I have been busy with other bugs. I am glad you were able to resolve this! Now that I have this extra information (that JITLink worked, but RuntimeDyld did not) I can see the bug by inspection. Your original code contained this line, which I did not notice the first time I read it: JTMB.setCodeModel(CodeModel::Small); Using small code model is only valid if you are using JITLink. If you are using RuntimeDyld (the default linking layer) then you must use the large code model, which is the default for the JIT. Sorry to only be giving you an explanation after you solve it, but hopefully it helps explain why your change worked. |
@lhames It's really helpful, i didn't know why my change worked before. Thanks a lot, i need to learn more about JITLink and RuntimeDyld. |
@vifird 把配置写进PROJECT就没事了,写进TARGE我也报你说的错 |
@zhfeng20108 感谢。不过问题点好像不太一样,你这个应该是Xcode应用开发,我遇到的问题是用LLVM的JIT引擎时遇到的问题。 |
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
…s of loops, specifically, loop blocks terminated by unreachable. This patch addresses issue llvm#84.
[llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (llvm#84…
…/121526866 Revert "[llvm] Include LLVM_REPOSITORY and LLVM_REVISION in tool version (llvm#84…"
I was using custom c++ functions, and it includes
c++ standard libraries
.While i using
c++ standard libraries
, error occured:Codes:
main.cpp
ffi.cpp, which will build and output
build/ffi
file.When
vc.push_back(1);
was included inffi.cpp
, error occoured, when delete this line , it runs ok.Here is my environment
Here is my cmake file
The text was updated successfully, but these errors were encountered: