5

以下用 clang6.0 编译命令:

LDFLAGS="-L/usr/local/opt/myllvm6.0rc1/lib -fuse-ld=lld" 
CPPFLAGS="-I/usr/local/opt/myllvm6.0rc1/include -I/usr/local/opt/myllvm6.0rc1/include/c++/v1/"; 
clang++ -fsanitize=address $LDFLAGS $CPPFLAGS -g -v main.cpp

给出:

 "/usr/local/opt/myllvm6.0rc1/bin/ld64.lld" -demangle -lto_library /usr/local/opt/myllvm6.0rc1/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o a.out -L/usr/local/opt/myllvm6.0rc1/lib /var/folders/14/rc46ppds1ms2kj_mvdcxlc040000gn/T/main-113675.o -lc++ /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib -rpath @executable_path -rpath /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin -lSystem /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin/libclang_rt.osx.a
warning: ignoring unknown argument: -no_deduplicate
warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
Unable to find library for -lto_library
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)

我不明白为什么它不能加载/usr/local/opt/myllvm6.0rc1/lib/libLTO.dylib(它存在于这个位置!)任何想法?

4

1 回答 1

1

您正在使用-fuse-ld=lld这是 LLD 文档所说的,并且您可以看到 ld64.lld 正在运行。但是,标志-no_deduplicate不是 lld 标志;这是一个 OSX ld 标志。ld64.lld 手册页在这里:

https://manpages.ubuntu.com/manpages/disco/man1/ld.lld.1.html

于 2020-10-25T01:35:56.773 回答