编译gcc和glibc

gcc 8.1.0

下载源代码包,执行contrib/download_prerequisites,如果网络不畅通,直接wget下载即可。下载之后重新执行contrib/download_prerequisites,它会校验。

可能需要的依赖

yum install gcc-c++ -y

yum install libgcc.i686 -y

yum install glibc-devel.i686 -y

不要在gcc自己的代码中configure

../gcc-8.1.0/configure –prefix=/com/test/gcc81 –enable-languages=c,c++

make

make install


glibc 2.27

把gcc加入到环境变量

echo “slibdir=/com/test/glibc227/lib64″ > configparms

这是把so放入lib64的唯一方法,参考 http://devpit.org/wiki/Gnu_Toolchain/GLIBC/Building_GLIBC#64-bit_config

# farking configparms file is a hidden/secret config file and is the only

# place slibdir can be set.  If you don't set slibdir to lib64/ it'll put

# ld64.so in lib/ which'll make gcc, objdump, and friends puke.


/root/glibc-2.27/configure –prefix=/com/test/glibc227 –libdir=/com/test/glibc227/lib64


make

make install


gcc math.c -o new -lm -I /com/test/glibc227/include/ -L /com/test/glibc227/lib -Wl,-rpath=/com/test/glibc227/lib -Wl,–dynamic-linker=/com/test/glibc227/lib/ld-2.27.so

编译32位 /root/glibc-2.27/configure –prefix=/com/test/glibc227 –host=i686-linux-gnu –build=i686-linux-gnu CC=”gcc -m32″ CXX=”g++ -m32″ CFLAGS=”-O2 -march=i686″ CXXFLAGS=”-O2 -march=i686″

你可能感兴趣的:(编译gcc和glibc)