llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29k stars 11.95k forks source link

clang [built from source] on Mageia v6/Cauldron x86-64 fails with an error on the Hello World program #27664

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 27290
Version 3.8
OS Linux
Attachments The clang strace output as compressed by xz
Reporter LLVM Bugzilla Contributor

Extended Description

Hi all,

I previously reported a similar bug (with the Mageia Linux packages) here - https://bugs.mageia.org/show_bug.cgi?id=18138 . Anyway, building llvm and then clang from source using this bash script:

!/bin/bash

b='/opt/llvm' export PATH="$b/bin:$PATH" export PKG_CONFIG_PATH="$b/lib64/pkgconfig:$b/lib/pkgconfig:$PKG_CONFIG_PATH" cmake -DCMAKE_BUILD_TYPE="release" -DCMAKE_INSTALL_PREFIX="$b" "$@"

And doing "make -j4 ; make -j4 check ; make -j4 install" and then running clang from /opt/llvm on the hello world program results in an error (at least here on Mageia Linux x86-64 v6):

< SHELL > shlomif@telaviv1 C/snippets/shlomif-c-snippets $ cat hello_world.c /*

int main(void) { printf ("%s\n", "Hello World!");

return 0;

} shlomif@telaviv1 C/snippets/shlomif-c-snippets $ /opt/llvm/bin/clang hello_world.c /..//bin/ld: cannot find crtbegin.o: No such file or directory /..//bin/ld: cannot find -lgcc clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation) shlomif@telaviv1 C/snippets/shlomif-c-snippets $ < / SHELL >

I'll attach the strace output of clang soon.

llvmbot commented 8 years ago

Hi all,

copying from the Mageia bug tracker:

One workaround I found for this bug today (thanks in part to this stackoverflow thread - http://stackoverflow.com/questions/4160262/clang-linker-problem#4160340 ) is to set these environment variables (e.g: by sourcing the code from Bash):

« export COMPILER_PATH=/usr/lib/gcc/x86_64-mageia-linux-gnu/5.3.1/ export LIBRARY_PATH="$COMPILER_PATH" »

after doing that, the Hello World program compiles and I was able to get Freecell Solver to build and pass its tests' suite using /usr/bin/clang.

llvmbot commented 8 years ago

Today I built llvm and clang from their 3.8.0 sources under /opt/llvm using the same build scripts - on a Debian Jessie x86-64 VM - and /opt/llvm/bin/clang compiled the Hello World perfectly fine.