Skip to content

Commit 5f53178

Browse files
Mac OS Clang 17+ compile fix
1 parent 13932bb commit 5f53178

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

scripts/001-binutils.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,24 @@ TARGET_ALIAS="ee"
3636
TARG_XTRA_OPTS=""
3737
OSVER=$(uname)
3838

39-
## If using MacOS Apple, set gmp and mpfr paths using TARG_XTRA_OPTS
39+
## If using MacOS Apple, set gmp and mpfr paths using TARG_XTRA_OPTS
4040
## (this is needed for Apple Silicon but we will do it for all MacOS systems)
4141
if [ "$(uname -s)" = "Darwin" ]; then
42+
## Determine if we should add --with-system-zlib (for Clang ≥ 17)
43+
macos_zlib_flag=$(clang --version 2>&1 | \
44+
head -n1 | \
45+
grep -qE 'clang.*version ([1-9][7-9]|[2-9][0-9])' && echo "--with-system-zlib")
46+
4247
## Check if using brew
4348
if command -v brew &> /dev/null; then
44-
TARG_XTRA_OPTS="--with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr)"
49+
TARG_XTRA_OPTS="--with-gmp=$(brew --prefix gmp) \
50+
--with-mpfr=$(brew --prefix mpfr) \
51+
$macos_zlib_flag"
4552
elif command -v port &> /dev/null; then
46-
## Check if using MacPorts
47-
TARG_XTRA_OPTS="--with-gmp=$(port -q prefix gmp) --with-mpfr=$(port -q prefix mpfr)"
53+
## Check if using MacPorts
54+
TARG_XTRA_OPTS="--with-gmp=$(port -q prefix gmp) \
55+
--with-mpfr=$(port -q prefix mpfr) \
56+
$macos_zlib_flag"
4857
fi
4958
fi
5059

scripts/002-gcc-stage1.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,28 @@ TARG_XTRA_OPTS=""
3737
TARGET_CFLAGS="-O2 -gdwarf-2 -gz"
3838
OSVER=$(uname)
3939

40-
## If using MacOS Apple, set gmp, mpfr and mpc paths using TARG_XTRA_OPTS
40+
## If using MacOS Apple, set gmp, mpfr and mpc paths using TARG_XTRA_OPTS
4141
## (this is needed for Apple Silicon but we will do it for all MacOS systems)
4242
if [ "$(uname -s)" = "Darwin" ]; then
43+
## Determine if we should add --with-system-zlib (for Clang ≥ 17)
44+
macos_zlib_flag=$(clang --version 2>&1 | \
45+
head -n1 | \
46+
grep -qE 'clang.*version ([1-9][7-9]|[2-9][0-9])' && echo "--with-system-zlib")
47+
4348
## Check if using brew
4449
if command -v brew &> /dev/null; then
45-
TARG_XTRA_OPTS="--with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr) --with-mpc=$(brew --prefix libmpc)"
50+
TARG_XTRA_OPTS="--with-gmp=$(brew --prefix gmp) \
51+
--with-mpfr=$(brew --prefix mpfr) \
52+
--with-mpc=$(brew --prefix libmpc) \
53+
$macos_zlib_flag"
4654
elif command -v port &> /dev/null; then
4755
## Check if using MacPorts
4856
MACPORT_BASE=$(dirname `port -q contents gmp|grep gmp.h`|sed s#/include##g)
4957
echo Macport base is $MACPORT_BASE
50-
TARG_XTRA_OPTS="--with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$MACPORT_BASE"
58+
TARG_XTRA_OPTS="--with-gmp=$MACPORT_BASE \
59+
--with-mpfr=$MACPORT_BASE \
60+
--with-mpc=$MACPORT_BASE \
61+
$macos_zlib_flag"
5162
fi
5263
fi
5364

scripts/006-gcc-stage2.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,28 @@ TARG_XTRA_OPTS=""
3737
TARGET_CFLAGS="-O2 -gdwarf-2 -gz"
3838
OSVER=$(uname)
3939

40-
## If using MacOS Apple, set gmp, mpfr and mpc paths using TARG_XTRA_OPTS
40+
## If using MacOS Apple, set gmp, mpfr and mpc paths using TARG_XTRA_OPTS
4141
## (this is needed for Apple Silicon but we will do it for all MacOS systems)
4242
if [ "$(uname -s)" = "Darwin" ]; then
43+
## Determine if we should add --with-system-zlib (for Clang ≥ 17)
44+
macos_zlib_flag=$(clang --version 2>&1 | \
45+
head -n1 | \
46+
grep -qE 'clang.*version ([1-9][7-9]|[2-9][0-9])' && echo "--with-system-zlib")
47+
4348
## Check if using brew
4449
if command -v brew &> /dev/null; then
45-
TARG_XTRA_OPTS="--with-gmp=$(brew --prefix gmp) --with-mpfr=$(brew --prefix mpfr) --with-mpc=$(brew --prefix libmpc)"
50+
TARG_XTRA_OPTS="--with-gmp=$(brew --prefix gmp) \
51+
--with-mpfr=$(brew --prefix mpfr) \
52+
--with-mpc=$(brew --prefix libmpc) \
53+
$macos_zlib_flag"
4654
elif command -v port &> /dev/null; then
4755
## Check if using MacPorts
48-
MACPORT_BASE=$(dirname `port -q contents gmp|grep gmp.h`|sed s#/include##g)
49-
echo Macport base is $MACPORT_BASE
50-
TARG_XTRA_OPTS="--with-gmp=$MACPORT_BASE --with-mpfr=$MACPORT_BASE --with-mpc=$MACPORT_BASE"
56+
MACPORT_BASE=$(dirname `port -q contents gmp | grep gmp.h` | sed 's#/include##g')
57+
echo "MacPort base is $MACPORT_BASE"
58+
TARG_XTRA_OPTS="--with-gmp=$MACPORT_BASE \
59+
--with-mpfr=$MACPORT_BASE \
60+
--with-mpc=$MACPORT_BASE \
61+
$macos_zlib_flag"
5162
fi
5263
fi
5364

0 commit comments

Comments
 (0)