问题
I'm working on touching up homebrew's (OS X package manager) llvm formula. Unfortunately, something about the parts I added broke the build in a way I just cannot figure out.
tl;dr ld asks for a library containing a _wordexp symbol for iOS simulator, and I have absolutely no clue where it is, if it exists
Compilation consistently fails for me when the compiler is attempting to link the address sanitizer dylib for iOS Simulator.
Reproduction steps (OS X only as far as I know, don't have *nix systems handy):
- install homebrew if it isn't already installed
- replace homebrew's llvm formula with the WIP one above
- Run
brew install llvm --with-clang --with-lldb --verbose --debug - wait for the build to fail and ask you what to do
- Drop into a debug shell
- cd to
projects/compiler-rt/lib/asan/CMakeFiles/clang_rt.asan_iossim_dynamic.dir add the following line to
link.txt-Wl,-syslibroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk- go back up to
asan - Run
make
At this point on my machine, something like this pops up:
Undefined symbols for architecture x86_64:
"_wordexp", referenced from:
_wrap_wordexp in asan_interceptors.cc.o
substitution_wordexp in asan_interceptors.cc.o
(maybe you meant: _wrap_wordexp)
ld: symbol(s) not found for architecture x86_64
I thought that it was just a matter of adding another folder to the linker search path. Turns out it isn't that simple:
wordexp.his in<path-to-iPhoneSimulator.sdk>/usr/include, but runningfind . -type f -name "*.dylib" -print0 | xargs -0 nm | grep -n "T _wordexp" -B <large number> | lessin Xcode-beta.app showed that the only .dylibs in Xcode that exported a
_wordexpsymbol were in theWatchSimulator.platformfolder- Running the same command in
/usrshowed that 3 libraries in/usr/lib/systemexported_wordexp(libsystem_asl,libsystem_c, andlibsystem_blocks), but the linker doesn't seem to care when I add/usr/lib/systemto the search path even when the code is the x86_64 code it wants, and the corresponding dylibs I found for other platforms didn't contain_wordexp - Googling about about this particular symbol missing turned up mostly stuff about Apple implementing
wordexp()with Perl - I think I remember seeing something in the llvm-dev mailing list archives about *BSD/OSX not implementing
wordexp, but the header file is definitely there,wordexp()shows up in the manpages, and the functions declared in the header file seem to work just fine when compiling for OSX - The symbol is not in the libc++(abi) dylibs compiled earlier in the build
- Every other part of the build compiles just fine except for the
asanfolder and its parents
What am I missing? Given that this error does not seem to be particularly common, there could be a chance it's my machine, but I'm hoping the chances are pretty low, because I wiped and reinstalled my computer this weekend.
(OS X 10.11, Xcode/CLT 7.1, mid-2012 Retina pro)
If more info is needed I'll be happy to provide it.
Edit 1: Simplified link.txt fix. Turns out setting sysroot for clang++ doesn't do so for ld
回答1:
Turns out the error was a result of the way homebrew processed compiler flags. That and a few other problems have been fixed since, so this probably isn't too useful any more.
For those curious about how exactly this broke, homebrew tries to change compiler flags to suppress warnings and create a more consistent building experience. One of these changes was to remove any -isysroot or -system flags, because that was added by homebrew itself at a later stage. Unfortunately, homebrew assumed that only the OS X SDK would be used, so when the build expected to build something with the iPhone simulator SDK it was pointed to the OS X SDK.
来源:https://stackoverflow.com/questions/32595742/homebrew-llvm-build-cannot-find-ios-simulator-library-containing-wordexp-symbol