问题描述
我正在研究修饰自制软件(OS X程序包管理器) llvm公式.不幸的是,关于我添加的零件的某些事情以一种我无法弄清楚的方式破坏了构建.
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
要求为iOS模拟器提供一个包含_wordexp
符号的库,我绝对不知道它在哪里,如果存在的话
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
当编译器尝试链接地址清理器 dylib时,编译对我始终失败适用于iOS模拟器.
Compilation consistently fails for me when the compiler is attempting to link the address sanitizer dylib for iOS Simulator.
复制步骤(据我所知,仅OS X,没有方便的* nix系统):
Reproduction steps (OS X only as far as I know, don't have *nix systems handy):
- 如果尚未安装homebrew,请安装
- 用上面的WIP替换自制软件的llvm公式
- 运行
brew install llvm --with-clang --with-lldb --verbose --debug
- 等待构建失败并询问您怎么做
- 放入调试shell
- cd到
projects/compiler-rt/lib/asan/CMakeFiles/clang_rt.asan_iossim_dynamic.dir
-
将以下行添加到
link.txt
- 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
asan
make
asan
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.h
在<path-to-iPhoneSimulator.sdk>/usr/include
中,但正在运行
find . -type f -name "*.dylib" -print0 | xargs -0 nm | grep -n "T _wordexp" -B <large number> | less
Xcode-beta.app中的
显示Xcode中唯一导出_wordexp
符号的.dylibs在WatchSimulator.platform
文件夹中
in Xcode-beta.app showed that the only .dylibs in Xcode that exported a _wordexp
symbol were in the WatchSimulator.platform
folder
我想念什么?鉴于该错误似乎并不常见,因此可能是我的机器,但是我希望这个机会很低,因为这个周末我擦去并重新安装了计算机.
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、2012年中Retina专业版)
(OS X 10.11, Xcode/CLT 7.1, mid-2012 Retina pro)
如果需要更多信息,我将很乐意提供.
If more info is needed I'll be happy to provide it.
简化的link.txt
修复程序.原来为clang++
设置sysroot对于ld
Edit 1: Simplified link.txt
fix. Turns out setting sysroot for clang++
doesn't do so for ld
推荐答案
原来,该错误是由自制程序处理编译器标志的方式引起的.此后,还有其他一些问题已得到解决,因此这可能不再有用.
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.
对于那些对这究竟是如何中断感到好奇的人,自制软件尝试更改编译器标志以抑制警告并创建更一致的构建体验.这些更改之一是删除任何-isysroot
或-system
标志,因为这些标志是由自制程序自身在以后阶段添加的.不幸的是,自制软件假定仅会使用OS X SDK,因此,当该构建期望使用iPhone模拟器SDK进行构建时,便指向OS X SDK.
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.
这篇关于自制llvm构建找不到包含_wordexp符号的iOS仿真器库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!