Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Missing lib dependence between libTarget and libCodeGen at -O0 #13679

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR13632
Status REOPENED
Importance P enhancement
Reported by Sebastian Pop (sebpop.llvm@gmail.com)
Reported on 2012-08-17 16:37:50 -0700
Last modified on 2012-11-19 22:35:52 -0800
Version trunk
Hardware PC Linux
CC benny.kra@gmail.com, chandlerc@gmail.com, geek4civic@gmail.com, jonathan.anderson@mun.ca, llvm-bugs@lists.llvm.org, nadav256@gmail.com, rafael@espindo.la
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
There is a missing dependence between libLLVMTarget.so and libLLVMCodeGen.so
when compiling llvm with gcc-4.7.1 or gcc-4.6.1 at -O0:

# cmake -G Ninja -D BUILD_SHARED_LIBS:BOOL=ON -D LLVM_ENABLE_PIC:BOOL=OFF -D
CMAKE_INSTALL_PREFIX:PATH=~/s/tip/x86-usr/ -D LLVM_ENABLE_ASSERTIONS:BOOL=ON -D
LLVM_ENABLE_WARNINGS:BOOL=ON -D CMAKE_CXX_FLAGS:STRING="-O0 -g" ..

# ninja
FAILED: : && /usr/bin/c++   -O0 -g -fno-rtti -fPIC   tools/llvm-
dis/CMakeFiles/llvm-dis.dir/llvm-dis.cpp.o  -o bin/llvm-dis -rdynamic
lib/libLLVMBitReader.so lib/libLLVMAnalysis.so lib/libLLVMTarget.so
lib/libLLVMCore.so lib/libLLVMMC.so lib/libLLVMObject.so lib/libLLVMSupport.so -
ldl -lpthread -Wl,-rpath,/usr2/spop/s/tip/x86-ninja/lib: && :
lib/libLLVMTarget.so: undefined reference to
`llvm::MachineInstr::hasPropertyInBundle(unsigned int,
llvm::MachineInstr::QueryType) const'
collect2: error: ld returned 1 exit status

This passes when compiled at -O1 and above.
At -O0 gcc does not inline hasPropertyInBundle and leaves unresolved calls to
this function in libTarget.

Adding CodeGen to the libs dependences in lib/Target/LLVMBuild.txt:

required_libraries = Core MC Support CodeGen

does not work as this creates circular dependences between these libs:

CMake Error at CMakeLists.txt:335 (message):
  Unexpected failure executing llvm-build: llvm-build: fatal error: found
  cycle to 'Target' after following: 'X86Info' (required library) -> 'Target'
  (required library) -> 'CodeGen' (required library) -> 'Analysis' (required
  library) -> Target
Quuxplusone commented 12 years ago

I can confirm that this happens with Debug+Asserts, Asserts or even Release build types.

Quuxplusone commented 12 years ago
I can confirm that this happens with Debug+Asserts, Asserts or even Release
build types.

I'm using:
cmake 2.8.8
recent ninja (version "git" at the command line, unhelpfully)
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Quuxplusone commented 11 years ago

Worked around in r168173.

Quuxplusone commented 11 years ago

Reopening per Chandler's request. There still is a layering violation around but it doesn't cause linker errors anymore.