+ -
当前位置:首页 → 问答吧 → [已解决]emerge gcc时如何增加一个configure选项?

[已解决]emerge gcc时如何增加一个configure选项?

时间:2009-09-18

来源:互联网

想要用emerge的方式为arm嵌入式开发构建一个工具链。
现已尝试
crossdev -t arm-none-eabi (这个命令要去编译Linux header)
crossdev -t arm-elf (这个命令在编译gcc stage1前去编译newlib)
均失败了。

然后,我又尝试了按照这个方法手工操作:
引用:
gentoo crossdev mini howto

$Id$

1. set PORTATE_OVERLAY in /etc/make.conf

echo "PORTDIR_OVERLAY=/usr/local/portage" >> /etc/make.conf

2. emerge crossdev

emerge -av crossdev

3. select CTARGET (powerpc for instance here), Setup 'categories'.

mkdir -p /etc/portage
echo cross-powerpc-unknown-linux-gnu >> /etc/portage/categories

4. make neccessary package symlinks

mkdir -p /usr/local/portage/cross-powerpc-unknown-linux-gnu
cd /usr/local/portage/cross-powerpc-unknown-linux-gnu
ln -s /usr/portage/sys-devel/binutils binutils
ln -s /usr/portage/sys-devel/gcc gcc
ln -s /usr/portage/sys-kernel/linux-headers linux-headers
ln -s /usr/portage/sys-libs/glibc glibc

5. emerge binutils

about USE flags, please look at [1]

emerge -av cross-powerpc-unknown-linux-gnu/binutils

6. emerge bootstrap gcc (Pass 1)

make sure only "nocxx" and "bootstrap" are selected:

USE="nocxx bootstrap -fortran -mudflap -nls" emerge -av cross-powerpc-unknown-linux-gnu/gcc

also use gcc-config to select the new (cross) gcc:

gcc-config -l # to list gccs
gcc-config XXX

7. emerge linux-headers

emerge -av cross-powerpc-unknown-linux-gnu/linux-headers

8. emerge glibc

emerge -av cross-powerpc-unknown-linux-gnu/glibc

make sure "nptl ntplonly" is in USE flags if you wan't nptl.

USE="ntpl nptlonly" emerge -av cross-powerpc-unknown-linux-gnu/glibc

9. emerge gcc (Pass 2), with c and c++ compilers:

make sure "nocxx" is not set, you could also enalbe "nls" or "mudflap" if
you like.

emerge -av cross-powerpc-unknown-linux-gnu/gcc

10. build stuff

When you go to emerge packages, you should just need to do:
ROOT=/blah/ CHOST=powerpc-unknown-linux-gnu emerge cpio
- you should also set CBUILD to your building machine for
completeness sake ... most of the time you won't need it,
but sometimes you will
- CTARGET is no longer needed so don't set it !

If you want to cross compile a kernel, do this:
make ARCH=powerpc CROSS_COMPILE=powerpc-unknown-linux-gnu-

[1] for step 6, the USE flags should better have "nocxx bootstrap" and no
other flags, they are tested to work on my system. other than step 6, the USE
flags is not abitrary so we could keep it as same as the host system as
possible.

.ref: http://dev.gentoo.org/~vapier/CROSS-COMPILE-HOWTO
按照上面的方法,我尝试了如下步骤

1、emerge -av cross-arm-none-eabi/binutils
2、USE="nocxx bootstrap -nls" emerge -av crossdev-arm-none-eabi/gcc
3、emerge -av cross-arm-none-eabi/newlib
4、emerge -av crossdev-arm-none-eabi/gcc
最后在第四步出错了。

参考网上资料,用configure、make方式的话,步骤如下应该可以成功构建工具链:

1、binutils

> tar xfvj binutils-2.19.1.tar.bz2
> cd binutils-2.19.1
> mkdir build
> cd build
> ../configure --target=arm-none-eabi --prefix=/opt/mine/arm-none-eabi --enable-interwork --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls
> make
> sudo make install
> cd ../..

2、gcc pass1

> tar xfvj gcc-4.3.3.tar.bz2
> cd gcc-4.3.3
> mkdir build
> cd build
> ../configure --with-libiconv-prefix=/opt/local --target=arm-none-eabi --prefix=/opt/mine/arm-none-eabi --enable-interwork --enable-multilib --enable-languages="c" --with-newlib --without-headers --disable-shared --with-gnu-as --with-gnu-ld --with-gmp=/opt/local --with-mpfr=/opt/local
> make all-gcc
> sudo make install-gcc
> cd ../..

3、newlib

> tar xfvz newlib-1.17.0.tar.gz
> cd newlib-1.17.0
> patch -p1 -i ../newlib-1.14.0-missing-makeinfo.patch # the patch will yield a warning because it is for an older version of newlib but should apply
> mkdir build
> cd build
> ../configure --target=arm-none-eabi --prefix=/opt/mine/arm-none-eabi --enable-interwork --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls
> make
> sudo make install
> cd ../..

4、gcc pass2
> cd gcc-4.3.3/build
> rm -rf * # clean up everything it makes stuff safer ^^
> ../configure --with-libiconv-prefix=/opt/local --target=arm-none-eabi --prefix=/opt/mine/arm-none-eabi --enable-interwork --enable-multilib --enable-languages="c" --with-newlib --disable-shared --with-gnu-as --with-gnu-ld --with-gmp=/opt/local --with-mpfr=/opt/local
> make
> sudo make install
> cd ../..

我仔细检查了emerge gcc时 configure的配置参数,发现少了--with-newlib这一项,所以我推测失败的原因在于少了这一个配置项,但是gcc的USE中好像没有与这个有关的参数,那么我如何才能在emerge gcc时让它给我增加这一个配置呢?

谢谢!

最后出错的log文件如下:
上传的附件
build.log.txt.bz2 (34.6 KB, 0 次查看)

作者: ifree   发布时间: 2009-09-18

export EXTRA_ECONF='--with-foo'

如果我记得没错

作者: zhllg   发布时间: 2009-09-18

谢谢张兄,正如你所言。

另,请问USE的原理是什么?有什么资料可参考?GCC 的ebuild文件太“简单”了,不知道它是怎样控制编译过程的。

作者: ifree   发布时间: 2009-09-18

引用:
作者: ifree
GCC 的ebuild文件太“简单”了,不知道它是怎样控制编译过程的。
eclass ?

作者: Etrnls   发布时间: 2009-09-18

eclass

ebuild开头有inherit ...

作者: zhllg   发布时间: 2009-09-18