-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcc-for-alire.sh
executable file
·86 lines (68 loc) · 3.07 KB
/
gcc-for-alire.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Uses an existing compiler to build one for Alire.
script_loc=`cd $(dirname $0) && pwd -P`
. $script_loc/common.sh
XCODE=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
CLT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
SDKROOT=$(xcrun --show-sdk-path)
BUGURL=https://github.com/simonjwright/building-gcc-macos-native
echo "BUILDING THE COMPILER IN $PREFIX"
set -eu
rm -rf *
$GCC_SRC/configure \
--prefix=$PREFIX \
--without-libiconv-prefix \
--disable-libmudflap \
--disable-libstdcxx-pch \
--disable-libsanitizer \
--disable-libcc1 \
--disable-libcilkrts \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++,ada \
--host=$BUILD \
--target=$BUILD \
--build=$BUILD \
--without-isl \
--with-build-sysroot=$SDKROOT \
--with-sysroot= \
--with-specs="%{!sysroot=*:--sysroot=%:if-exists-else($XCODE $CLT)}" \
--with-bugurl=$BUGURL \
--$BOOTSTRAP-bootstrap \
--enable-host-pie \
CFLAGS=-Wno-deprecated-declarations \
CXXFLAGS=-Wno-deprecated-declarations
make -w -j$CORES
make -w -j$CORES install
# Install the shim for ld
# Find the full path name for the C compiler's location
tool_path=$(dirname $($PREFIX/bin/gcc --print-prog-name=cc1))
echo "Installing in $tool_path"
# Write our shim there. If we're running a pre-15 SDK, there won't be
# an ld-classic, so use the standard linker.
#
# Need to keep a lookout for SDKs version > 15.
#
# We quote the EOF to avoid parameter substitution while writing the
# document.
cat >$tool_path/ld <<'EOF'
#!/bin/sh
classic=$(xcrun --find ld-classic 2>/dev/null) || true
if [ -n "$classic" ]; then
exec $classic "$@"
else
exec ld "$@"
fi
EOF
# It needs to be executable!
chmod +x $tool_path/ld
# Fix up rpaths.
for exe in $PREFIX/bin/*; do
if [[ $(file $exe) == *executable* ]]; then
bash $script_loc/fix_executable_rpaths.sh $exe
fi
done
for lib in $PREFIX/lib/*.dylib; do
if [[ $(file $lib) == *shared\ library* ]]; then
bash $script_loc/fix_library_rpaths.sh $lib
fi
done