问题描述
我试图建立在Mac OS X上的gcc交叉编译器,目标是 ARM-ELF-EABI
。
I'm trying to build a gcc cross compiler on Mac OS X, the target is arm-elf-eabi
.
这是我迄今所做的:
我试过不使用铛/ LLVM从Mac,所以我从酿造使用的GCC-4.8。
I tried not to use clang/llvm from Mac, so I used the gcc-4.8 from brew.
brew tap homebrew/versions
brew install gcc48
brew install binutils
建筑之前,我设置环境变量:
Before the building, I set the environment variables:
export CC=/usr/local/bin/gcc-4.8
export CXX=/usr/local/bin/g++-4.8
export CPP=/usr/local/bin/cpp-4.8
export LD=/usr/local/bin/gcc-4.8
export PREFIX=/opt/cross
export TARGET=arm-elf-eabi
打造的binutils
下载的binutils源,然后创建一个build目录,并可以建立的binutils没有问题:
build binutils
Downloading a binutils source, then creating a build directory, and could build binutils without an issue:
mkdir build-binutils
cd build-binutils
../binutils-2.24/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --enable-64-bit-bfd --disable-shared --disable-werror --disable-nls
make configure-host
make LDFLAGS="-all-static"
sudo make install
建筑GCC
下载GCC 4.8源代码,并运行构建过程
building gcc
Downloading gcc 4.8 source, and run the build process
mkdir build-gcc
cd build-gcc
../gcc-4.8.3/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --without-headers --disable-shared --enable-multilib --with-sysroot --disable-werror
make configure-host
make all-gcc << ERROR
make all-target-libgcc
不过,我得到了无效房源的选项
建筑r'`错误。
/usr/local/bin/g++-4.8 -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../gcc-4.8.3/gcc -I../../gcc-4.8.3/gcc/build -I../../gcc-4.8.3/gcc/../include -I../../gcc-4.8.3/gcc/../libcpp/include \
-o build/genconstants.o ../../gcc-4.8.3/gcc/genconstants.c
Assembler messages:
Fatal error: invalid listing option `r'
make[2]: *** [build/genconstants.o] Error 1
make[1]: *** [all-gcc] Error 2
替代建设进程
我试图用默认的编译器从Mac具有以下配置:
Alternative building process
I tried to use default compiler from Mac with the following configuration:
./contrib/download_prerequisites
CFLAGS="-arch i386 -arch x86_64 -Wno-error=deprecated-declarations -Wno-error=unused-variable -Wno-error=unused-function" ../gcc-4.8.3/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c --without-headers --disable-shared --enable-multilib
然后,它正常工作与让所有海湾合作委员会
,但我也有不同的错误使所有目标-libgcc中
,所以我会坚持到GCC方法取代铛/ LLVM的做法。
Then, it works fine with make all-gcc
, but I also have different error with make all-target-libgcc
, so I'll stick to gcc approach instead of clang/llvm approach.
我的猜测是,汇编为
苹果有蹊跷的是海湾合作委员会给(因为没有什么错铛/ LLVM)参数。
My guess is that the assembler as
from Apple has something wrong with parameters that gcc gives (because there's nothing wrong with clang/llvm).
什么可能是错误的?如何解决这个问题?
What might be wrong? How to solve this issue?
推荐答案
在目录打造-GCC / GCC
,存在一个为
来代替调用的/ usr / bin中/为
的脚本文件。当我改名为
到 as_temp
,然后重新运行,一切正常。
环境变量 AS =的/ usr / bin中/为
似乎并没有解决这个问题。
In the directory build-gcc/gcc
, there exists an as
script file to be invoked instead of the /usr/bin/as
. When I renamed as
to as_temp
, and rerun, everything works fine.The environmental variable AS=/usr/bin/as
does not seem to solve this issue.
我需要再修改的 /选择/交叉/ ARM-ELF-EABI / SYS-根/ usr / include目录
应该按顺序创建prevent另一个错误信息。
I needed one more modification that /opt/cross/arm-elf-eabi/sys-root/usr/include
should be created in order to prevent another error message.
我还发现,是在交叉编译pretty有用Mac OS X的
I also found that this site is pretty useful in cross compilation on Mac OS X.
这篇关于如何使ARM的交叉编译在Mac OS X(错误:无效的房源选项'R' - 交叉编译错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!