[Linux From Scratch 作一个自己的Linux操作系统发行版本]三、编译gcc

11 篇文章 2 订阅

执行指令

#!/bin/bash

tar -jxf $LFS/sources/gcc-6.3.0.tar.bz2
(
	cd gcc-6.3.0/
	# GCC now requires the GMP, MPFR and MPC packages
	tar -xf $LFS/sources/mpfr-3.1.5.tar.xz
	mv -v mpfr-3.1.5 mpfr
	tar -xf $LFS/sources/gmp-6.1.2.tar.xz
	mv -v gmp-6.1.2 gmp
	tar -xf $LFS/sources/mpc-1.0.3.tar.gz
	mv -v mpc-1.0.3 mpc
	# The following command will change the location of GCC's default dynamic linker to use the one installed in /tools.
	# It also removes /usr/include from GCC's include search path.
	for file in gcc/config/{linux,i386/linux{,64}}.h
		do
		cp -uv $file{,.orig}
		sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
		-e 's@/usr@/tools@g' $file.orig > $file
		echo '
		#undef STANDARD_STARTFILE_PREFIX_1
		#undef STANDARD_STARTFILE_PREFIX_2
		#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
		#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
		touch $file.orig
	done

	# on x86_64 hosts, set the default directory name for 64-bit libraries to “lib”
	case $(uname -m) in
	x86_64)
	sed -e '/m64=/s/lib64/lib/' \
	-i.orig gcc/config/i386/t-linux64
	;;
	esac

	mkdir -v build    
	cd build
	../configure \
		--target=$LFS_TGT \
		--prefix=/tools \
		--with-glibc-version=2.11 \
		--with-sysroot=$LFS \
		--with-newlib \
		--without-headers \
		--with-local-prefix=/tools \
		--with-native-system-header-dir=/tools/include \
		--disable-nls \
		--disable-shared \
		--disable-multilib \
		--disable-decimal-float \
		--disable-threads \
		--disable-libatomic \
		--disable-libgomp \
		--disable-libmpx \
		--disable-libquadmath \
		--disable-libssp \
		--disable-libvtv \
		--disable-libstdcxx \
		--enable-languages=c,c++
    
	make -j12	
	make install    
)
rm -fr gcc-6.3.0/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值