mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
dc8c4719c3
building gcc with gcc (targeting OS X on linux) causes the following errors: error 1: g++ -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 -static-libstdc++ -static-libgcc -o xg++ \ gcc.o ggc-none.o g++spec.o driver-i386.o darwin-driver.o libcommon-target.a \ libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a /usr/bin/ld: unrecognised emulation mode: acosx_version_min Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om elf_k1om i386pep i386pe error 2: g++ -c -DIN_GCC_FRONTEND -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 -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace cc1-checksum.c -o cc1-checksum.o cc1plus: error: unrecognized command line option '-mmacosx-version-min=10.4' after fixing the -mmacosx-version-min issue in the gcc/specs file, I get the following weird error (gmp is indeed installed): g++ -c -DIN_GCC_FRONTEND -g -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 -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace cc1-checksum.c -o cc1-checksum.o In file included from cc1-checksum.c:2:0: ../../gcc/system.h:641:17: fatal error: gmp.h: No such file or directory #include <gmp.h> all these errors do not appear when clang is used for building gcc.
136 lines
3.0 KiB
Bash
Executable File
136 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
export LC_ALL="C"
|
|
export LIBRARY_PATH=""
|
|
|
|
export CC=clang
|
|
export CXX=clang++
|
|
|
|
which osxcross-conf || {
|
|
echo "you need to complete ./build.sh first, before you can start building gcc"
|
|
exit 1
|
|
}
|
|
|
|
eval `osxcross-conf`
|
|
|
|
set -e
|
|
|
|
# How many concurrent jobs should be used for compiling?
|
|
JOBS=4 #`grep -c ^processor /proc/cpuinfo`
|
|
|
|
# GCC version to build
|
|
GCC_VERSION=4.8.2
|
|
|
|
# GCC mirror
|
|
GCC_MIRROR="ftp://ftp.gwdg.de/pub/misc/gcc/releases"
|
|
|
|
function require
|
|
{
|
|
which $1 &>/dev/null
|
|
while [ $? -ne 0 ]
|
|
do
|
|
echo ""
|
|
read -p "Install $1 then press enter"
|
|
which $1 &>/dev/null
|
|
done
|
|
}
|
|
|
|
require wget
|
|
|
|
BASE_DIR=`pwd`
|
|
|
|
pushd $OSXCROSS_BUILD_DIR
|
|
|
|
if [ ! -f "have_gcc_${GCC_VERSION}" ]; then
|
|
|
|
pushd $OSXCROSS_TARBALL_DIR
|
|
wget -c "$GCC_MIRROR/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2"
|
|
popd
|
|
|
|
rm -rf gcc* 2>/dev/null
|
|
|
|
echo "extracting gcc ..."
|
|
tar xf "$OSXCROSS_TARBALL_DIR/gcc-$GCC_VERSION.tar.bz2"
|
|
|
|
pushd gcc*$GCC_VERSION*
|
|
|
|
patch -p0 < $OSXCROSS_PATCH_DIR/gcc-dsymutil.patch
|
|
|
|
mkdir -p build
|
|
pushd build
|
|
|
|
../configure \
|
|
--target=x86_64-apple-$OSXCROSS_TARGET \
|
|
--with-ld=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-ld \
|
|
--with-as=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-as \
|
|
--with-sysroot=$OSXCROSS_SDK \
|
|
--disable-nls \
|
|
--enable-languages=c,c++,objc,obj-c++ \
|
|
--without-headers \
|
|
--enable-multilib \
|
|
--enable-lto \
|
|
--prefix=$OSXCROSS_TARGET_DIR
|
|
|
|
make -j$JOBS
|
|
make install -j$JOBS
|
|
|
|
popd #build
|
|
popd #gcc
|
|
|
|
touch "have_gcc_${GCC_VERSION}"
|
|
|
|
fi #have gcc
|
|
|
|
popd #build dir
|
|
|
|
cp ogcc/ogcc $OSXCROSS_TARGET_DIR/bin
|
|
|
|
pushd $OSXCROSS_TARGET_DIR/bin
|
|
|
|
if [ ! -f $OSXCROSS_TARGET_DIR/bin/i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
|
|
mv x86_64-apple-$OSXCROSS_TARGET-gcc x86_64-apple-$OSXCROSS_TARGET-base-gcc
|
|
mv x86_64-apple-$OSXCROSS_TARGET-g++ x86_64-apple-$OSXCROSS_TARGET-base-g++
|
|
|
|
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-gcc i386-apple-$OSXCROSS_TARGET-base-gcc
|
|
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-g++ i386-apple-$OSXCROSS_TARGET-base-g++
|
|
fi
|
|
|
|
ln -sf ogcc o32-gcc
|
|
ln -sf ogcc o32-g++
|
|
ln -sf ogcc o64-gcc
|
|
ln -sf ogcc o64-g++
|
|
|
|
ln -sf ogcc i386-apple-$OSXCROSS_TARGET-gcc
|
|
ln -sf ogcc i386-apple-$OSXCROSS_TARGET-g++
|
|
ln -sf ogcc x86_64-apple-$OSXCROSS_TARGET-gcc
|
|
ln -sf ogcc x86_64-apple-$OSXCROSS_TARGET-g++
|
|
|
|
popd #target dir / bin
|
|
|
|
function test_compiler
|
|
{
|
|
echo -ne "testing $1 ... "
|
|
$1 $2 -O2 -Wall -o test && rm test
|
|
echo "works"
|
|
}
|
|
|
|
echo ""
|
|
|
|
test_compiler o32-gcc $BASE_DIR/oclang/test.c
|
|
test_compiler o64-gcc $BASE_DIR/oclang/test.c
|
|
|
|
test_compiler o32-g++ $BASE_DIR/oclang/test.cpp
|
|
test_compiler o64-g++ $BASE_DIR/oclang/test.cpp
|
|
|
|
echo ""
|
|
|
|
echo "Done! Now you can use o32-gcc/o32-g++ and o64-gcc/o64-g++ as compiler"
|
|
echo ""
|
|
echo "Example usage:"
|
|
echo ""
|
|
echo "Example 1: CC=o32-gcc ./configure --host=i386-apple-$OSXCROSS_TARGET"
|
|
echo "Example 2: CC=i386-apple-$OSXCROSS_TARGET-gcc ./configure --host=i386-apple-$OSXCROSS_TARGET"
|
|
echo "Example 3: o64-gcc -Wall test.c -o test"
|
|
echo "Example 4: x86_64-apple-$OSXCROSS_TARGET-strip -x test"
|
|
echo ""
|