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

Segfault when using clang 7 #1352

Closed
karjonas opened this issue Oct 28, 2018 · 7 comments
Closed

Segfault when using clang 7 #1352

karjonas opened this issue Oct 28, 2018 · 7 comments

Comments

@karjonas
Copy link

Hi,

It seems like compiling ispc with clang version 7 is giving a segmentation fault. This is the stack trace I get:

Starting program: /home/jonas/Coding/ispc/build/ispc 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Warning: No output file or header file name specified. Program will be compiled and warnings/errors will be issued, but no output will be generated. 
Warning: No --target specified on command-line. Using default system target "avx1-i32x8". 

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5368dea in ?? () from /usr/lib/libLLVM-7.so
(gdb) bt
#0  0x00007ffff5368dea in ?? () from /usr/lib/libLLVM-7.so
#1  0x00005555556a7dab in llvm::Target::createTargetMachine (this=0x7ffff69ebcc0, TT=..., CPU=..., Features=..., Options=..., RM=..., CM=..., 
    OL=llvm::CodeGenOpt::Default, JIT=false) at /usr/include/llvm/Support/TargetRegistry.h:397
#2  0x00005555556a32ff in Target::Target (this=0x555555f0f840, arch=0x55555576c555 "x86-64", cpu=0x555555f14420 "corei7-avx", isa=0x55555576c16b "avx1-i32x8", 
    pic=false, printTarget=false, genericAsSmth=...) at /home/jonas/Coding/ispc/src/ispc.cpp:1118
#3  0x00005555556ca0d2 in Module::CompileAndOutput (srcFile=0x0, arch=0x0, cpu=0x0, target=0x0, outputFlags=Module::NoFlags, outputType=Module::Object, 
    outFileName=0x0, headerFileName=0x0, includeFileName=0x0, depsFileName=0x0, depsTargetName=0x0, hostStubFileName=0x0, devStubFileName=0x0)
    at /home/jonas/Coding/ispc/src/module.cpp:3187
#4  0x00005555556bcccb in main (Argc=1, Argv=0x7fffffffe8c8) at /home/jonas/Coding/ispc/src/main.cpp:799

If I compile it using gcc it works fine though. I do not know what clang is doing differently. Let me know if you need more information from me.

Regards, Jonas

@dbabokin
Copy link
Collaborator

LLVM 7.0 works well for me, except several known fails. Could you provide more details? How to do build LLVM? (this seems to be the key in this case).

@karjonas
Copy link
Author

I tried building using CMake, and I tried building using the pkgbuild from arch https://www.archlinux.org/packages/community/x86_64/ispc/ and they both fail if I use clang as the compiler but work fine with gcc. I also made a ticket in the arch linux bug tracker https://bugs.archlinux.org/task/60340?project=5&cat%5B0%5D=33&string=crash. Maybe this issue is specific to Arch, I don't know.

@dbabokin
Copy link
Collaborator

dbabokin commented Nov 1, 2018

I was able to reproduce it. This is reproduced if (1) LLVM 7.0 is used, (2) LLVM is built by gcc, (3) ISPC is built by clang.

This is something new, but we already had a case, when using different compilers for LLVM and ISPC builds caused link problems. So we follow the rule to build LLVM and ISPC with the same compiler. Preferably to clang for that. I.e. if you are building using "alloy.py", you need to use "--selfbuild" switch. When configuring with cmake, define CC and CXX, i.e. run "CC=clang CXX=clang++ cmake ..".

I have no bandwidth to investigate this, so I'm closing the issue. If someone is brave enough to investigate it and report to LLVM, I would applaud.

@dbabokin dbabokin closed this as completed Nov 1, 2018
@ArchangeGabriel
Copy link

Upstream is aware (e.g. https://groups.google.com/forum/#!msg/llvm-dev/8Tcz49kTNCw/NI0l_MiZAwAJ), and the issue is more general: “In short, building your project with clang and linking against LLVM libraries built with GCC causes a SEGFAULT because of an ABI incompatibility.”.

@dbabokin
Copy link
Collaborator

dbabokin commented Nov 2, 2018

Thanks for the link! Though it's not clear when they are going to address that. And looks like there's no hope for fixing it in 7.0

@ArchangeGabriel
Copy link

Seems this was fixed in 8.0. I’m building ispc against clang again.

@dbabokin
Copy link
Collaborator

Thanks for the update!

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

3 participants