[llvm-dev] Undefined symbols in llvm-objdump linkage on x86_64-apple-darwin15

Jack Howarth via llvm-dev llvm-dev at lists.llvm.org
Tue May 24 12:15:04 PDT 2016


On Tue, May 24, 2016 at 3:03 PM, Jack Howarth
<howarth.mailing.lists at gmail.com> wrote:
> On Tue, May 24, 2016 at 2:37 PM, Jack Howarth
> <howarth.mailing.lists at gmail.com> wrote:
>> On Tue, May 24, 2016 at 2:28 PM, Chris Bieneman <beanz at apple.com> wrote:
>>> Jack,
>>>
>>> What version of CMake are you using?
>>>
>>> -Chris
>>
>> Chris,
>>       I am using cmake 3.5.2. My read of this problem is as follows.
>> While libLLVM.dylib is being linked against -lxar when
>> -DLLVM_LINK_LLVM_DYLIB:BOOL=ON is passed to cmake, the libLLVM.dylib
>> is created with -Wl,-dead_strip such that any symbols from libxar not
>> explicitly used with in the object files of libLLVM.dylib are stripped
>> out. This means that those additional symbols used by llvm-objdump
>> aren't accessible from libLLVM.dylib's linkage on libxar and an
>> additional explicit linkage on libxar is required in the
>> tools/llvm-objdump/CMakeLists.txt when HAVE_LIBXAR and
>> LLVM_LINK_LLVM_DYLIB are set.
>>         Jack
>
> Also note that this issue doesn't arise for the cmake build with
> -DBUILD_SHARED_LIBS:BOOL=ON because the resulting
> lib/Object/CMakeFiles/LLVMObject.dir/link.txt contains...
>
> /sw/src/fink.build/llvm39-3.9.0-1/opt-bin/ccclang++  -fno-common -fPIC
> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter
> -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
> -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
> -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -O3 -dynamiclib
> -Wl,-headerpad_max_install_names  -Wl,-dead_strip  -L/sw/lib -o
> ../libLLVMObject.dylib -install_name @rpath/libLLVMObject.dylib
> CMakeFiles/LLVMObject.dir/Archive.cpp.o
> CMakeFiles/LLVMObject.dir/ArchiveWriter.cpp.o
> CMakeFiles/LLVMObject.dir/Binary.cpp.o
> CMakeFiles/LLVMObject.dir/COFFObjectFile.cpp.o
> CMakeFiles/LLVMObject.dir/ELF.cpp.o
> CMakeFiles/LLVMObject.dir/ELFObjectFile.cpp.o
> CMakeFiles/LLVMObject.dir/Error.cpp.o
> CMakeFiles/LLVMObject.dir/IRObjectFile.cpp.o
> CMakeFiles/LLVMObject.dir/MachOObjectFile.cpp.o
> CMakeFiles/LLVMObject.dir/MachOUniversal.cpp.o
> CMakeFiles/LLVMObject.dir/ModuleSummaryIndexObjectFile.cpp.o
> CMakeFiles/LLVMObject.dir/Object.cpp.o
> CMakeFiles/LLVMObject.dir/ObjectFile.cpp.o
> CMakeFiles/LLVMObject.dir/RecordStreamer.cpp.o
> CMakeFiles/LLVMObject.dir/SymbolicFile.cpp.o
> CMakeFiles/LLVMObject.dir/SymbolSize.cpp.o -lxar
> ../libLLVMBitReader.dylib ../libLLVMCore.dylib ../libLLVMMC.dylib
> ../libLLVMMCParser.dylib ../libLLVMSupport.dylib
> -Wl,-rpath, at executable_path/../lib
>
> and thus the linkage for  llvm-objdump is directly linked against
> libxar as in the default static lib build. Only the
> -DLLVM_LINK_LLVM_DYLIB:BOOL=ON build attempts to resolve the symbols
> from libxar using an indirect linkage on libxar in libLLVM.dylib.
>                Jack
>

Ignore that last comment. It does appear that
-DBUILD_SHARED_LIBS:BOOL=ON  produces the same error...

[ 98%] Linking CXX executable ../../bin/llvm-objdump
cd /sw/src/fink.build/llvm39-3.9.0-1/build/stage1/tools/llvm-objdump
&& /sw/bin/cmake -E cmake_link_script
CMakeFiles/llvm-objdump.dir/link.txt --verbose=1
/sw/src/fink.build/llvm39-3.9.0-1/opt-bin/ccclang++   -fno-common
-fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -O3
-Wl,-search_paths_first -Wl,-headerpad_max_install_names  -L/sw/lib
-Wl,-dead_strip CMakeFiles/llvm-objdump.dir/llvm-objdump.cpp.o
CMakeFiles/llvm-objdump.dir/COFFDump.cpp.o
CMakeFiles/llvm-objdump.dir/ELFDump.cpp.o
CMakeFiles/llvm-objdump.dir/MachODump.cpp.o  -o ../../bin/llvm-objdump
 ../../lib/libLLVMX86AsmPrinter.dylib
../../lib/libLLVMPowerPCAsmPrinter.dylib
../../lib/libLLVMARMAsmPrinter.dylib ../../lib/libLLVMX86Desc.dylib
../../lib/libLLVMPowerPCDesc.dylib ../../lib/libLLVMARMDesc.dylib
../../lib/libLLVMX86Disassembler.dylib
../../lib/libLLVMPowerPCDisassembler.dylib
../../lib/libLLVMARMDisassembler.dylib ../../lib/libLLVMX86Info.dylib
../../lib/libLLVMPowerPCInfo.dylib ../../lib/libLLVMARMInfo.dylib
../../lib/libLLVMCodeGen.dylib ../../lib/libLLVMDebugInfoDWARF.dylib
../../lib/libLLVMMC.dylib ../../lib/libLLVMMCDisassembler.dylib
../../lib/libLLVMObject.dylib ../../lib/libLLVMSupport.dylib
-Wl,-rpath, at executable_path/../lib
Undefined symbols for architecture x86_64:
  "_xar_serialize", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_file_first", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_iter_new", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_prop_first", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_extract_tobuffersz", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_open", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_prop_get", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_close", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_prop_next", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_iter_free", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
  "_xar_file_next", referenced from:
      DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
unsigned int, bool, bool, bool, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >) in
MachODump.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/build.make:190: recipe
for target 'bin/llvm-objdump' failed
make[2]: *** [bin/llvm-objdump] Error 1
make[2]: Leaving directory '/sw/src/fink.build/llvm39-3.9.0-1/build/stage1'
CMakeFiles/Makefile2:22545: recipe for target
'tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/all' failed
make[1]: *** [tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/all] Error 2
make[1]: Leaving directory '/sw/src/fink.build/llvm39-3.9.0-1/build/stage1'
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

for the same reason. Appending -lxar to
tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/link.txt likewise
eliminates the linkage error.
         Jack

>>>
>>>> On May 24, 2016, at 11:00 AM, Jack Howarth <howarth.mailing.lists at gmail.com> wrote:
>>>>
>>>> On Tue, May 24, 2016 at 1:35 PM, Kevin Enderby <enderby at apple.com> wrote:
>>>>> Hi Jack,
>>>>>
>>>>> Just a guess here, this may be the bug Chris helped me out with in the use of the include file xar/xar.h which is not C++ safe.  I needed to wrap my include via:
>>>>>
>>>>> #ifdef HAVE_LIBXAR
>>>>> extern "C" {
>>>>> #include <xar/xar.h>
>>>>> }
>>>>> #endif
>>>>>
>>>>> I think we may need some help from Chris to track this down.  I’ll bug him in a bit to see if he can help us on this.
>>>>
>>>> While the build here with  -DLLVM_LINK_LLVM_DYLIB:BOOL=ON passed on
>>>> the cmake options produces HAVE_LIBXAR:INTERNAL=1 in CMakeCache.txt, I
>>>> don't see anything in the cmakefiles for tools/llvm-objdump to provide
>>>> the necessary linkage on the system libxar shared library. Appending
>>>> the missing linkage for -lxar onto
>>>> build/stage1tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/link.txt...
>>>>
>>>> /sw/src/fink.build/llvm39-3.9.0-1/opt-bin/ccclang++   -fno-common
>>>> -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter
>>>> -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
>>>> -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
>>>> -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -O3
>>>> -Wl,-search_paths_first -Wl,-headerpad_max_install_names  -L/sw/lib
>>>> -Wl,-dead_strip CMakeFiles/llvm-objdump.dir/llvm-objdump.cpp.o
>>>> CMakeFiles/llvm-objdump.dir/COFFDump.cpp.o
>>>> CMakeFiles/llvm-objdump.dir/ELFDump.cpp.o
>>>> CMakeFiles/llvm-objdump.dir/MachODump.cpp.o  -o ../../bin/llvm-objdump
>>>> ../../lib/libLLVM.dylib -Wl,-rpath, at executable_path/../lib -lxar
>>>>
>>>> eliminates the bootstrap failure.
>>>>
>>>>>
>>>>> Kev
>>>>>
>>>>>> On May 24, 2016, at 10:28 AM, Jack Howarth <howarth.mailing.lists at gmail.com> wrote:
>>>>>>
>>>>>> On Tue, May 24, 2016 at 1:24 PM, Jack Howarth
>>>>>> <howarth.mailing.lists at gmail.com> wrote:
>>>>>>> On Tue, May 24, 2016 at 1:22 PM, Jack Howarth
>>>>>>> <howarth.mailing.lists at gmail.com> wrote:
>>>>>>>> On Tue, May 24, 2016 at 12:08 PM, Reid Kleckner <rnk at google.com> wrote:
>>>>>>>>> Kevin Enderby added those symbol uses in r270491. It has a cmake
>>>>>>>>> feature test, and all the uses of those symbols appear bracketed in
>>>>>>>>> HAVE_LIBXAR, so I don't know what went wrong for you.
>>>>>>>>
>>>>>>>> The trigger for this build failure is the usage of
>>>>>>>> -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON. If I drop that cmake
>>>>>>>> option, the linkage failure for llvm-objdump disappears.
>>>>>>>
>>>>>>> Wrong cmake option. I meant to say that -DLLVM_LINK_LLVM_DYLIB:BOOL=ON
>>>>>>> is the trigger of the build failure. Sorry for the noise there.
>>>>>>
>>>>>> Filed as https://llvm.org/bugs/show_bug.cgi?id=27855
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, May 24, 2016 at 8:07 AM, Jack Howarth via llvm-dev
>>>>>>>>> <llvm-dev at lists.llvm.org> wrote:
>>>>>>>>>> Is anyone else seeing a bootstrap failure on x86_64-apple-darwin15 in
>>>>>>>>>> current trunk?
>>>>>>>>>>
>>>>>>>>>> [ 95%] Linking CXX executable ../../bin/llvm-objdump
>>>>>>>>>> Undefined symbols for architecture x86_64:
>>>>>>>>>> "_xar_serialize", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_file_first", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_iter_new", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_prop_first", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_extract_tobuffersz", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_open", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_prop_get", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_close", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_prop_next", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_iter_free", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> "_xar_file_next", referenced from:
>>>>>>>>>>     DumpBitcodeSection(llvm::object::MachOObjectFile*, char const*,
>>>>>>>>>> unsigned int, bool, bool, bool, std::__1::basic_string<char,
>>>>>>>>>> std::__1::char_traits<char>, std::__1::allocator<char> >) in
>>>>>>>>>> MachODump.cpp.o
>>>>>>>>>> ld: symbol(s) not found for architecture x86_64
>>>>>>>>>> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>>>>>>>>>> tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/build.make:173: recipe
>>>>>>>>>> for target 'bin/llvm-objdump' failed
>>>>>>>>>> make[2]: *** [bin/llvm-objdump] Error 1
>>>>>>>>>> make[2]: Target 'tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/build'
>>>>>>>>>> not remade because of errors.
>>>>>>>>>> CMakeFiles/Makefile2:21861: recipe for target
>>>>>>>>>> 'tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/all' failed
>>>>>>>>>> make[1]: *** [tools/llvm-objdump/CMakeFiles/llvm-objdump.dir/all] Error 2
>>>>>>>>>> _______________________________________________
>>>>>>>>>> LLVM Developers mailing list
>>>>>>>>>> llvm-dev at lists.llvm.org
>>>>>>>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>>>
>>>


More information about the llvm-dev mailing list