Skip to content

Commit b9f7054

Browse files
committed
Add option to build without LTO.
1 parent b5958f5 commit b9f7054

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

build.mac.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,23 @@ fi
1313

1414
echo Building for architecture $arch
1515

16+
export "LTO_OPTS=-flto=thin"
17+
export "LTO=1"
18+
if [[ $1 == "--no-lto" ]]; then
19+
export "LTO_OPTS="
20+
export "LTO=0"
21+
shift
22+
fi
23+
1624
# The dependencies must be outside of the build folder because
1725
# the python build process ends up running a find -delete that
1826
# happens to also delete all the static libraries that we built.
1927
export "PREFIX=$(pwd)/../Nuitka-Python-Deps"
2028
export "PYTHON_BASE=$(pwd)"
2129
export "PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig"
22-
export "CFLAGS=-arch $arch -mmacosx-version-min=10.9 -I${PREFIX}/include -I${PYTHON_BASE}/Include -fPIC -flto=thin"
23-
export "CXXFLAGS=-arch $arch -mmacosx-version-min=10.9 -I${PREFIX}/include -fPIC -flto=thin"
24-
export "LDFLAGS=-arch $arch -L${PREFIX}/lib -flto=thin"
30+
export "CFLAGS=-arch $arch -mmacosx-version-min=10.9 -I${PREFIX}/include -I${PYTHON_BASE}/Include -fPIC ${LTO_OPTS}"
31+
export "CXXFLAGS=-arch $arch -mmacosx-version-min=10.9 -I${PREFIX}/include -fPIC ${LTO_OPTS}"
32+
export "LDFLAGS=-arch $arch -L${PREFIX}/lib ${LTO_OPTS}"
2533
export "MACOSX_DEPLOYMENT_TARGET=10.9"
2634

2735
# Allow to overload the compiler used via CC environment variable
@@ -36,6 +44,14 @@ fi
3644
export CC
3745
export CXX
3846

47+
# Have this as a standard path. We are not yet relocatable, but that will come hopefully.
48+
target=~/Library/Nuitka-Python${short_version}-$arch
49+
50+
if [ ! -z "$1" ]
51+
then
52+
target="$1"
53+
fi
54+
3955
ELEVATE=
4056
if [ ! -w "$(dirname "$target")" ]
4157
then
@@ -256,25 +272,21 @@ cd ..
256272
long_version=$(git branch --show-current 2>/dev/null || git symbolic-ref --short HEAD)
257273
short_version=$(echo $long_version | sed -e 's#\.##')
258274

259-
# Have this as a standard path. We are not yet relocatable, but that will come hopefully.
260-
target=~/Library/Nuitka-Python${short_version}-$arch
261-
262-
if [ ! -z "$1" ]
263-
then
264-
target="$1"
265-
fi
266-
267275
cp Modules/Setup.macos Modules/Setup
268276

269277
export "LDFLAGS=-L${PREFIX}/lib"
270278

279+
if [[ "$LTO" == "1" ]]; then
280+
LTO_BUILD_OPT=--with-lto
281+
fi
282+
271283
./configure "--prefix=$target" --disable-shared --enable-ipv6 --enable-unicode=ucs4 \
272-
--enable-optimizations --with-lto --with-computed-gotos --with-fpectl --without-readline \
284+
--enable-optimizations $LTO_BUILD_OPT --with-computed-gotos --with-fpectl --without-readline \
273285
--with-system-expat --with-system-libmpdec \
274286
CC="$CC" \
275287
CXX="$CXX" \
276288
CFLAGS="-g $CFLAGS" \
277-
LDFLAGS="-arch $arch -g -Xlinker $LDFLAGS -flto=thin" \
289+
LDFLAGS="-arch $arch -g -Xlinker $LDFLAGS ${LTO_OPTS}" \
278290
LIBS="-lffi -lbz2 -lsqlite3 -llzma -lnp_embed -lssl -lcrypto " \
279291
ax_cv_c_float_words_bigendian=no \
280292
___ORIG_DEPS_PREFIX=${PREFIX}___

0 commit comments

Comments
 (0)