gpt4 book ai didi

ios - 链接共享库时选项 -fembed-bitcode 消失

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:29:37 26 4
gpt4 key购买 nike

我尝试将几个适用于 iOS 的开源库编译为带有 bitcode 的共享库。我已将标志 -fembed-bitcode 添加到 CFLAGS 和 LDFLAGS 中。编译正常完成,但一些生成的库(例如 curl)中没有位码(我用 otool -l lib.dylib | grep LLVM 检查过)。

我的调查表明,当 dylib 链接时,标记 -fembed-bitcode 只是从链接器命令行中消失,尽管在 Makefile 中直接使用了 LDFLAGS。 -fembed-bitcode 如何从 LDFLAGS 中消失?

最佳答案

-fembed-bitcode 标志消失的原因是库使用 libtool 进行链接,它 strips默认未知标志:

When creating a shared library, but not when compiling or creating a program, libtool drops some flags from the command line provided by the user. This is done because flags unknown to libtool may interfere with library creation or require additional support from libtool, and because omitting flags is usually the conservative choice for a successful build.

If you encounter flags that you think are useful to pass, as a work-around you can prepend flags with -Wc, or -Xcompiler to allow them to be passed through to the compiler driver (see Link mode). Another possibility is to add flags already to the compiler command at configure run time:

./configure CC='gcc -m64'

因此,除了 -fembed-bitcode 之外,我还向 LDFLAGS 添加了 -Wc,-fembed-bitcode 标志,并使用 bitcode 编译库。

关于ios - 链接共享库时选项 -fembed-bitcode 消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50116027/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com