问题
I'm trying to build LLDB as part of Clang/LLVM. LLVM, Clang, Compiler-RT and Extras build OK. However, LLVM has an issue when building with the other components.
The directory structure is set up according to LLVM/Clang/LLDB instructions. The docs on LLDB are located at Building LLDB. Below was run from the build
directory, which lies next to the llvm
directory (llvm
is where all sources were unpacked):
$ cd build
$ ../llvm/configure --enable-optimized --enable-cxx11 --enable-libcpp --prefix=/usr/local
...
$ make -j4
...
llvm[4]: Compiling ARM_DWARF_Registers.cpp for Release+Asserts build
llvm[4]: Compiling KQueue.cpp for Release+Asserts build
llvm[4]: Compiling PseudoTerminal.cpp for Release+Asserts build
llvm[4]: Compiling Range.cpp for Release+Asserts build
llvm[4]: Compiling SharingPtr.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractor.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractorGDBRemote.cpp for Release+Asserts build
llvm[4]: Compiling TimeSpecTimeout.cpp for Release+Asserts build
llvm[4]: Building Release+Asserts Archive Library liblldbUtility.a
llvm[3]: Linking Release+Asserts Shared Library liblldb.dylib
Undefined symbols for architecture x86_64:
"SystemRuntimeMacOSX::Initialize()", referenced from:
lldb_private::Initialize() in liblldbInitAndLog.a(lldb.o)
"SystemRuntimeMacOSX::Terminate()", referenced from:
lldb_private::Terminate() in liblldbInitAndLog.a(lldb.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/Users/jwalton/Clang-3.4.2/build/Release+Asserts/lib/liblldb.dylib] Error 1
make[2]: *** [all] Error 1
make[1]: *** [all] Error 1
make: *** [all] Error 1
EDIT: following Matt's instructions below, I was able to avoid Undefined symbols SystemRuntimeMacOSX::Initialize and SystemRuntimeMacOSX::Terminate
. But the build still dies with:
llvm[4]: Compiling ARM_DWARF_Registers.cpp for Release+Asserts build
llvm[4]: Compiling KQueue.cpp for Release+Asserts build
llvm[4]: Compiling PseudoTerminal.cpp for Release+Asserts build
llvm[4]: Compiling Range.cpp for Release+Asserts build
llvm[4]: Compiling SharingPtr.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractor.cpp for Release+Asserts build
llvm[4]: Compiling StringExtractorGDBRemote.cpp for Release+Asserts build
llvm[4]: Compiling TimeSpecTimeout.cpp for Release+Asserts build
llvm[4]: Building Release+Asserts Archive Library liblldbUtility.a
make[3]: *** No rule to make target `/Users/jwalton/Clang-3.4.2/build/Release+Asserts/lib/liblldbPluginSystemRuntimeMacOSX.a',
needed by `/Users/jwalton/Clang-3.4.2/build/Release+Asserts/lib/liblldb.dylib'. Stop.
The odd thing is, lldbPluginSystemRuntimeMacOSX
is handled the same as other plugins like lldbPluginProcessMachCore
. The same directives appear in the same places like Cmake.txt
.
The host platform is OS X 10.8.5, x64, fully patched. Xcode version is 5.1.1 (5B1008) (which is the latest).
Does anyone know what magical steps I should perform to get lldb to compile with LLVM and Clang?
100 BOUNTY EDIT: There's a pastebin with my recipe in a shell script at Clang 3.4.2 recipe. The recipe uses Missing-Makefile
, and Matt provides it below. The recipe patches the makefile, so you won't need to do it manually.
150 BOUNTY EDIT: Cos' answer was the final step. This question need both Matt's answer and Cos' answer. Cos provided an updated recipe. Its available at Clang 3.4.2 Recipe (Final).
回答1:
You need to add following patch to your script:
sed -i '' '\|DIRS += Process/mach-core|a\
DIRS += SystemRuntime/MacOSX\
' llvm/tools/lldb/source/Plugins/Makefile
Your updated recipe
回答2:
I believe that Jim's advice above is probably the best option. But, I also experienced this problem attempting to build llvm+clang+lldb 3.4.
I narrowed the problem down to one particular plugin, specific to OS X, not building at all via Make. This was a build system bug, fixed by this commit:
https://github.com/llvm-mirror/lldb/commit/7a53199e140843235d2bd2b12182ceb764419c8a
You can use the commit above as a guide. Only two changes actually need to be made to build successfully. I just patched my local copy.
lldb/lib/Makefile: "lldbPluginSystemRuntimeMacOSX.a" needs to be added after line 98
lldb/source/Plugins/SystemRuntime/MacOSX/Makefile needs to be created with the following contents:
##===- source/Plugins/SystemRuntime/MacOSX/Makefile ---------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ../../../..
LIBRARYNAME := lldbPluginSystemRuntimeMacOSX
BUILD_ARCHIVE = 1
include $(LLDB_LEVEL)/Makefile
With all this done, I was able to finish the build and get a functioning version of liblldb.dylib, which is what I was after. Hope this helps!
回答3:
I generally build using the Xcode project on MacOS X. Just get the lldb sources, and do:
cd lldb
xcodebuild -configuration Debug
or if you want to debug the Clang side of things as well:
xcodebuild -configuration DebugClang
You don't even need to get the llvm sources, the Xcode project will check them out for you if they aren't present (but won't override the version you have it you want to try to build against a branch or whatever...)
TOT lldb is building fine for me right now.
There are other folks on the lldb-dev mailing list who do use the Makefile build, if you want to build it this way for some reason, you might ask there.some
来源:https://stackoverflow.com/questions/24923650/undefined-symbols-systemruntimemacosxinitialize-and-systemruntimemacosxtermi