如何为LLVM指定自定义stdlib目录 [英] How to specify a custom stdlib directory for LLVM
问题描述
我有带有Clang的LLVM 3.3,并且
$/tmp/clang/bin/clang -print-search-dirs程序:=/tmp/clang/bin:/usr/lib/gcc/i486-linux-gnu/4.4/../../../../i486-linux-gnu/bin库:=/tmp/clang/bin/../lib/clang/3.3:/usr/lib/gcc/i486-linux-gnu/4.4:/usr/lib/gcc/i486-linux-gnu/4.4/../../../../lib32:/usr/lib/../lib32:/usr/lib/i486-linux-gnu/../../lib32:/usr/lib/gcc/i486-linux-gnu/4.4/../../..:/lib:/usr/lib
如何指示Clang使用除/usr/lib/gcc/i486-linux-gnu/4.4
以外的stdlib(例如 libgcc
)目录?我想改为使用/tmp/mygccstd
.
它也在寻找/usr/lib
和/lib
.如何禁用它?
-B
和-sysroot
的组合解决了这些问题. -nostdinc
, -isystem
和 -cxx-isystem
的组合完成了包含的技巧.并非所有这些标志都由 clang --help
显示,其中一些是我从 man gcc
中学到的,其他一些是阅读Clang源代码的,而另一些在线的.>
-gcc-toolchain
也有所不同,但是它使用怪异的规则来查找库,不允许在路径名组件中使用符号链接等,因此我最终改用了上面的其他标志.
I have LLVM 3.3 with Clang, and
$ /tmp/clang/bin/clang -print-search-dirs
programs: =/tmp/clang/bin:/usr/lib/gcc/i486-linux-gnu/4.4/../../../../i486-linux-gnu/bin
libraries: =/tmp/clang/bin/../lib/clang/3.3:/usr/lib/gcc/i486-linux-gnu/4.4:/usr/lib/gcc/i486-linux-gnu/4.4/../../../../lib32:/usr/lib/../lib32:/usr/lib/i486-linux-gnu/../../lib32:/usr/lib/gcc/i486-linux-gnu/4.4/../../..:/lib:/usr/lib
How can I instruct Clang to usage an stdlib (e.g. libgcc
) directory other than /usr/lib/gcc/i486-linux-gnu/4.4
? I'd like to make it use /tmp/mygccstd
instead.
It's also looking in /usr/lib
and /lib
. How do I disable that?
A combination of -B
and --sysroot
did the trick for the libraries. A combination of -nostdinc
, -isystem
and -cxx-isystem
did the trick for the includes. Not all these flags are displayed by clang --help
, some of them I learned from man gcc
, some other reading the Clang source code, and some other online.
-gcc-toolchain
also made a difference, but it was using weird rules to find the libraries, disallowing symlinks in the pathname components etc., so I ended up using the other flags above instead.
这篇关于如何为LLVM指定自定义stdlib目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!