【问题标题】:Building GCC 4.8.2 in OS X 10.9在 OS X 10.9 中构建 GCC 4.8.2
【发布时间】:2013-12-02 08:23:31
【问题描述】:

我正在尝试在 OS X 10.9 中编译和安装 GCC 4.8.2。我按照这里的说明(http://gcc.gnu.org/wiki/InstallingGCC)首先运行./contrib/download_prerequesites,然后从与源不同的目录运行configure 和make。我的构建失败并出现错误:

checking for suffix of object files... configure: error: in `/Users/prokilogrammer/temp/gcc-build482/x86_64-apple-darwin13.0.2/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.

显然,如果正确安装了 GCC 的依赖项(GMP、MPC、MPFR)(http://gcc.gnu.org/wiki/FAQ#configure_suffix),这个问题将得到解决。我检查并确保它们正确安装在 /usr/local/lib 和 /usr/local/include 目录下。

查看 config.log,我看到以下错误:

configure:3565: checking for suffix of object files
configure:3587: /Users/prokilogrammer/temp/gcc-build482/./gcc/xgcc -B/Users/prokilogrammer/temp/gcc-build482/./gcc/ -B/usr/local/x86_64-apple-darwin13.0.2/bin/ -B/usr/local/x86_64-apple-darwin13.0.2/lib/ -isystem /usr/local/x86_64-apple-darwin13.0.2/include -isystem /usr/local/x86_64-apple-darwin13.0.2/sys-include    -c -g -O2  conftest.c >&5
conftest.c:1:0: internal compiler error: Segmentation fault: 11
 /* confdefs.h */
 ^
libbacktrace could not find executable to open

我不确定段错误是因为缺少依赖项还是 gcc 中的合法问题。

你们有遇到过类似的问题吗?有解决方案/解决方法吗?

PS:我也试过设置 LD_LIBRARY_PATH 和 DYLD_LIBRARY_PATH 没有任何运气。

【问题讨论】:

    标签: gcc osx-mavericks


    【解决方案1】:

    我已经在几台 Mavericks 机器上构建了 GCC 4.8.2,但我选择了稍微不同的策略。具体来说,我在构建目录中包含了 GMP、MPC、MPFR(以及 CLOOG 和 ISL)的代码。我使用了一个脚本来准自动化它:

    GCC_VER=gcc-4.8.2
    tar -xf ${GCC_VER}.tar.bz2 || exit 1
    
    cd ${GCC_VER} || exit
    
    cat <<EOF |
        cloog 0.18.0 tar.gz 
        gmp 5.1.3 tar.xz 
        isl 0.11.1 tar.bz2 
        mpc 1.0.1 tar.gz 
        mpfr 3.1.2 tar.xz
    EOF
    
    while read file vrsn extn
    do
        tar -xf "../$file-$vrsn.$extn" &&
        ln -s "$file-$vrsn" "$file"
    done
    

    完成后:

    mkdir gcc-4.8.2-obj
    cd gcc-4.8.2-obj
    ../gcc-4.8.2/configure --prefix=$HOME/gcc/v4.8.2
    make -j8 bootstrap
    

    AFAICR,4.8.1 和 4.8.2 就差不多了。

    【讨论】:

    • 感谢您的指导。我按照您的指示进行操作,但没有成功。我遇到了同样的错误。我不确定我的环境出了什么问题。
    • 很抱歉听到这个消息。你预装了哪个编译器?我使用的是 XCode 5。你能让那个编译器编译任何代码吗?我没有任何/usr/local/x86_64-apple-darwin13.0.2 目录。这是否意味着您使用的是以前编译的 GCC?
    • 糟糕;我在 10 月初进行了构建,我看到的是 darwin12.x 而不是 13.x,这表明是 Mountain Lion 而不是 Mavericks 构建。因此,我已将我的 GCC 4.8.2 移开,并使用 XCode gcc 进行引导阶段重做配置等。我正在使用上面概述的脚本,将两个片段组合在一起。到目前为止,一切都很好......我正在追踪这一切。
    • 在具有 16 GiB RAM 和 SSD 驱动器的机器上花费了大约 45 分钟,但使用 Apple 提供的“gcc”在我的机器上成功完成了编译(/usr/bin/gcc -version 表示:Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix) 引导构建。
    • 其实是的。我刚刚意识到我安装了引导 gcc 构建的 osx-gcc-installer。我没有意识到这个包在 10.9 中没有得到官方支持。我卸载了这个包并安装了 XCode。现在我可以很好地编译 gcc 了 :) 感谢您的帮助。 PS:顺便说一句,我这次使用 Home Brew 编译 gcc。
    猜你喜欢
    • 2013-11-01
    • 2014-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-10
    • 2013-10-26
    • 2013-11-01
    • 2014-06-23
    相关资源
    最近更新 更多