【问题标题】:Source-built clang-3.7 on Linux not finding Block_copyLinux 上源构建的 clang-3.7 未找到 Block_copy
【发布时间】:2015-09-29 14:40:55
【问题描述】:

我在我的 Ubuntu Linux 系统上从源代码构建并安装了 llvm/clang-3.7(我正在从源代码构建,因为我工作的开发环境没有 apt-get 可用)。 gcc 版本是 4.8.2。我按照http://clang.llvm.org/get_started.html 的 clang 构建说明进行操作,一切正常(mkdir build; cd build; cmake -G "Unix Makefiles" ../llvm; make; make install)。但是,我现在发现测试 Block_copy 的程序无法编译。当我尝试构建 gnustep-base 时,该程序由 autoconf 自动生成。失败的部分是:

int
main ()
{
    return _Block_copy ();
    ;
 return 0;
}

我的编译命令是:

clang -o conftest -m64 -march=opteron -mno-3dnow -ggdb -O2 -Wall  -I/home/build/GNUstep/Local/Library/Headers -I/home/build/GNUstep/Local/Library/Headers -I/home/build/GNUstep/System/Library/Headers -fgnu-runtime -x objective-c -m64  -L/home/build/GNUstep/Local/Library/Libraries -L/home/build/GNUstep/Local/Library/Libraries -L/home/build/GNUstep/System/Library/Libraries conftest.c -lrt -ldl  -lpthread -rdynamic -m64 -fgnu-runtime -L/home/build/GNUstep/Library/Libraries -L/home/build/GNUstep/Local/Library/Libraries -L/home/build/GNUstep/System/Library/Libraries -lobjc -lm

我是否需要使用特殊选项构建 clang 以启用块,还是应该与另一个库链接?

【问题讨论】:

    标签: linux cmake clang objective-c-blocks autoconf


    【解决方案1】:

    我是否需要使用特殊选项构建 clang 才能启用块

    没有。但是您可能需要使用 clang 二进制文件的 -fblocks 选项。

    -fblocks
        Enable the "Blocks" language feature.
    

    我应该链接到另一个库吗?

    AFAIK,是的。

    _Block_copy 是 BlocksRuntime 的一部分。

    你编译过compiler-rt吗?它包括 BlocksRuntime。 The document 解释了如何构建 compiler-rt。

    【讨论】:

    • 谢谢!事实证明,默认情况下,clang 不再在 Linux 上构建 BlocksRuntime,但可以破解 cmake makefile 来请求它。我现在正在看那个。此外,事实证明我什至不需要 clang 的块支持,因为它内置于我正在链接的 libobjc2 中。 :)
    猜你喜欢
    • 2016-11-09
    • 2020-05-10
    • 2013-03-17
    • 1970-01-01
    • 2022-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多