https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797

--- Comment #82 from Jens-S. Vöckler <jens4303 at me dot com> ---
I had some prior issues with w.r.t 32bits. Tinkering, this script does build a
gcc 9.1 on macOS 10.14.5 on APFS. I didn't create it for beauty, and it's
specific to my setup. The resulting compiler is unable to generate 32bit stuff.

#!/bin/bash
#
here="$PWD"
trap 'cd "$here"' EXIT

prefix=/opt/gcc-9.1.0
if [[ ! -d $prefix ]]; then
    echo "FATAL: No such directory: $prefix" 1>&2
    exit 1
fi

# fix for fink interference
PATH=$(echo $PATH | \
           tr -d '\012' | \
           tr ':' '\012' | \
           fgrep -v /sw/bin | \
           tr '\012' ':')
export PATH="$PATH:/sw/bin";
echo "PATH=$PATH"

set -v
test -d gcc-9.1.0 || gtar xJf gcc-9.1.0.tar.xz
cd gcc-9.1.0

test -d gmp-6.1.2 || gtar xJf ../gmp-6.1.2.tar.xz
test -e gmp || ln -s gmp-6.1.2 gmp

test -d mpfr-4.0.2 || gtar xJf ../mpfr-4.0.2.tar.xz
test -e mpfr || ln -s mpfr-4.0.2 mpfr

test -d mpc-1.1.0 || gtar xzf ../mpc-1.1.0.tar.gz
test -e mpc || ln -s mpc-1.1.0 mpc

test -d isl-0.18 || gtar xjf ../isl-0.18.tar.bz2
test -e isl || ln -s isl-0.18 isl

mkdir objdir
cd objdir
set +v

../configure "--prefix=$prefix" \
    --enable-languages=c,c++,fortran,lto,objc,obj-c++ \
    --with-system-zlib \
    --disable-multilib \
    --with-cpu=core2 \
    --enable-threads \
   
"--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
test $? -eq 0 || exit 2

make -j 3 BOOT_CFLAGS='-O' bootstrap
test $? -eq 0 || exit 42

make install

---&< snip, snip &<---

$ file /opt/gcc-9.1.0/bin/g++ 
/opt/gcc-9.1.0/bin/g++: Mach-O 64-bit executable x86_64

$ /opt/gcc/bin/g++ hello.cc -o hello 
$ file hello
hello: Mach-O 64-bit executable x86_64
$ otool -L hello
hello:
        /opt/gcc-9.1.0/lib/libstdc++.6.dylib (compatibility version 7.0.0,
current version 7.26.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1252.250.1)
        /opt/gcc-9.1.0/lib/libgcc_s.1.dylib (compatibility version 1.0.0,
current version 1.0.0)
$ ./hello 
Hello, world

Reply via email to