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

[clang_delta] Link against LLVMSupport to fix missing APInt methods #125

Merged
merged 1 commit into from
Nov 22, 2016
Merged

[clang_delta] Link against LLVMSupport to fix missing APInt methods #125

merged 1 commit into from
Nov 22, 2016

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Oct 30, 2016

Link clang_delta against LLVMSupport in order to fix the following link
failure:

/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/clang_delta.dir/ReplaceArrayIndexVar.cpp.o: undefined reference to symbol '_ZN4llvm5APInt12initSlowCaseERKS0_'
/usr/lib64/libLLVMSupport.so.40: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Link clang_delta against LLVMSupport in order to fix the following link
failure:

  /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/clang_delta.dir/ReplaceArrayIndexVar.cpp.o: undefined reference to symbol '_ZN4llvm5APInt12initSlowCaseERKS0_'
  /usr/lib64/libLLVMSupport.so.40: error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status
@eeide
Copy link
Member

eeide commented Oct 30, 2016

Hi! Thank you for this pull request.

Your pull request doesn't say what version of LLVM you are linking against, what OS you are using, etc. Can you tell me these things?

Note that the master branch of C-Reduce is intended to link with the current release version of LLVM, currently 3.9.0. We generally have a separate branch for linking against development versions of LLVM. (We don't currently have that separate branch, but we will recreate it after the upcoming release of C-Reduce.)

Thanks!

@eeide eeide self-assigned this Oct 30, 2016
@eeide eeide added the bug label Oct 30, 2016
@mgorny
Copy link
Contributor Author

mgorny commented Oct 30, 2016

Well, the LLVM version is in the linker error. It's git from 2-3 days ago.

$ clang --version
clang version 4.0.0 (8b3778092fe6f8e5473f6af79bd798e8d25a315a) (7117050551ff233fd2fa7d8688bb50e50a6c1f85)

Distribution is Gentoo, with all LLVM parts built as shared libraries. I think I've had some issues building against 3.9.0 but didn't downgrade to confirm. I've assumed that linking against LLVMSupport will always be safe.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 30, 2016

Note that most systems won't notice this since they're either using single-shared-library model or static libraries. With the first, the Support code will be in the shared library anyway. With the second, it will be pulled in as a dependency of other libraries.

@mgorny
Copy link
Contributor Author

mgorny commented Nov 1, 2016

Ok, here's a little update. I've tested more and it seems that nobody reported this before because Gentoo was using autotools so far, and autotools link to the support library correctly (or rather AFAICS they just link to all LLVM libraries). I can reproduce the issue when using CMake on Gentoo LLVM 3.9.0.

@eeide
Copy link
Member

eeide commented Nov 1, 2016

Thanks for the investigation! I will try to reproduce this before making the upcoming C-Reduce release.

I'm assuming that you compiled LLVM 3.9.0 for yourself. Can you give me the exact options that you used to compile LLVM 3.9.0? This will help me to reproduce the problem and test your fix.

@mgorny
Copy link
Contributor Author

mgorny commented Nov 1, 2016

I'm assuming that you compiled LLVM 3.9.0 for yourself.

No, I've used the standard Gentoo ebuild.

Can you give me the exact options that you used to compile LLVM 3.9.0? This will help me to reproduce the problem and test your fix.

Sure. Here they are:

cmake -C /var/tmp/portage/sys-devel/llvm-3.9.0/work/llvm-3.9.0.src-abi_x86_64.amd64/gentoo_common_config.cmake \
   -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DLLVM_LIBDIR_SUFFIX=64 \
   -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD=Hexagon;Sparc;AMDGPU;BPF;PowerPC;Mips;AArch64;NVPTX;MSP430;XCore;SystemZ;ARM;X86 \
   -DLLVM_BUILD_TESTS=no -DLLVM_ENABLE_FFI=yes -DLLVM_ENABLE_TERMINFO=yes \
   -DLLVM_ENABLE_ASSERTIONS=no -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON \
   -DWITH_POLLY=OFF -DLLVM_HOST_TRIPLE=x86_64-pc-linux-gnu \
   -DFFI_INCLUDE_DIR=/usr/lib64/libffi-3.2.1/include -DFFI_LIBRARY_DIR=/usr/lib64/../lib64 \
   -DHAVE_HISTEDIT_H=yes -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=no \
   -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp -DCLANG_DEFAULT_CXX_STDLIB= \
   -DCLANG_DEFAULT_RTLIB= -DCOMPILER_RT_BUILD_SANITIZERS=yes \
   -DCOMPILER_RT_INCLUDE_TESTS=yes -DOCAMLFIND=NO \
   -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND -DLLVM_BUILD_DOCS=no \
   -DLLVM_ENABLE_SPHINX=no -DLLVM_ENABLE_DOXYGEN=OFF \
   -DLLVM_INSTALL_HTML=/usr/share/doc/llvm-3.9.0/html \
   -DSPHINX_WARNINGS_AS_ERRORS=OFF -DLLVM_INSTALL_UTILS=ON \
   -DCLANG_INSTALL_HTML=/usr/share/doc/llvm-3.9.0/clang \
   -DLLVM_BINUTILS_INCDIR=/usr/include -DCLANG_ENABLE_ARCMT=yes \
   -DCLANG_ENABLE_STATIC_ANALYZER=yes -DCLANG_LIBDIR_SUFFIX=64 \
   -DCMAKE_BUILD_TYPE=Gentoo \
   -DCMAKE_USER_MAKE_RULES_OVERRIDE=/var/tmp/portage/sys-devel/llvm-3.9.0/work/llvm-3.9.0.src-abi_x86_64.amd64/gentoo_rules.cmake \
   -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/sys-devel/llvm-3.9.0/work/llvm-3.9.0.src-abi_x86_64.amd64/gentoo_toolchain.cmake \
    /var/tmp/portage/sys-devel/llvm-3.9.0/work/llvm-3.9.0.src

I've added some random line wrapping to attempt to make them readable on GitHub. Note that some of them may require Gentoo patches but they shouldn't be relevant here.

However, I think the only really relevant flag here is -DBUILD_SHARED_LIBS=ON.

@eeide
Copy link
Member

eeide commented Nov 2, 2016

Thanks!

(I am hoping to reproduce the problem on something other than Gentoo, because I don't have a Gentoo box handy. We will see how it goes!)

@mgorny
Copy link
Contributor Author

mgorny commented Nov 15, 2016

Gentle ping. Any success?

@eeide
Copy link
Member

eeide commented Nov 15, 2016

I'm sorry, but I haven't had time to look at this yet.

@eeide
Copy link
Member

eeide commented Nov 22, 2016

I reproduced the problem tonight on Ubuntu 14.04 with

  • LLVM 3.9.0 release built with cmake ../llvm-3.9.0.src -DBUILD_SHARED_LIBS=ON
  • C-Reduce master (608a71f) built with cmake ../creduce.

I confirmed that your patch fixes the problem. Thanks you again!

I also checked the configure-based build of the same C-Reduce tree. It builds and compiles without problem—so no patch is needed for that path. I did not dig into the details of the differences between the clang_delta link command lines.

@eeide eeide merged commit 1e7b6e2 into csmith-project:master Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants