在OS X 10.9中构建GCC 4.8.2

时间:2013-11-18 23:53:23

标签: gcc osx-mavericks

我正在尝试在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

我不确定segfault是否是由于缺少依赖关系或gcc中的合法问题。

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

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

1 个答案:

答案 0 :(得分:3)

我在几台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。