|
发表于 2009-12-18 12:45:54
|
显示全部楼层
"裸编译器"的说法偶是多年前看到的,原始出处已不可考,但其已经算是一个专业术语,有广泛使用,如 http://wiki.osdev.org/GCC_Cross-Compiler 中有段: gcc
Now, you can build GCC. (Use v3.3 or later - v3.2.x has a bug with internal __malloc declarations resulting in an error during compilation. This could be fixed by patching four occurrences in three different source files, but I lost the diff output and am not in a mind of re-checking. ;-) )
cd /usr/src/build-gcc
export PATH=$PATHPREFIX/bin
../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX --disable-nls \
--enable-languages=c,c++ --without-headers
make all-gcc
make install-gcc
The path has to be extended since GCC needs the binutils we built earlier at some point of the build process. You might want to add these extensions to your $PATH permanently, so you won't have to use fully qualified path names every time you call your cross-compiler.
--disable-nls is the same as for binutils above.
--without-headers tells GCC not to rely on any C library (standard or runtime) being present for the target.
--enable-languages tells GCC not to compile all the other language frontends it supports, but only C (and optionally C++).
If you are compiling GCC <= 3.3.x, you need --with-newlib as additional parameter. Those older versions have a known bug that keeps --without-headers from working correctly. Additionally setting --with-newlib is a workaround for that bug.
Summary
Now you have a "naked" cross-compiler. It does not have access to a C library or C runtime yet, so you cannot use any of the standard includes or create runable binaries. But it is quite sufficient to compile your self-made kernel. 前面一个玩笑就能激起您那么高怒气。
内核一样有库,只是无法像用户空间库那样存在,您自己看看 linux-kernel 中的 lib 目录。
一个用户空间的软件,不使用任何库,不使用任何系统调用,特例存在,并且偶自己早些年真的那么玩过,为了看看绕过 内核 和 libc 能做什么。
您如果接触嵌入式开发用的板子,更容易理解,简单点,一般板子上有些 LED,控制用的管脚一般直接编址到内存特定地址特定位,对内存特定地址操作即可完成对 LED 的控制,用 c 可简单实现。
全面考虑问题 不是 钻牛角。 |
|