Skip to content

Commit f322496

Browse files
jjhelmusgeofft
andauthored
link with noexecstack when cross-compiling (#1092)
Explicitly disable an executable stack on all Linux targets, even when cross-compiling. Follow up to test failures cased by #1070 --------- Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
1 parent e7a7f46 commit f322496

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

cpython-unix/build-tcl.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,20 @@ rm -rf pkgs/sqlite* pkgs/tdbc*
6767
pushd unix
6868

6969
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC -I${TOOLS_PATH}/deps/include"
70-
LDFLAGS="${EXTRA_TARGET_CFLAGS} -L${TOOLS_PATH}/deps/lib"
70+
LDFLAGS="${EXTRA_TARGET_LDFLAGS} -L${TOOLS_PATH}/deps/lib"
7171
if [[ "${PYBUILD_PLATFORM}" != macos* ]]; then
7272
LDFLAGS="${LDFLAGS} -Wl,--exclude-libs,ALL"
7373
fi
7474

75-
CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
75+
# Tcl configures and builds packages (itcl, threads, ...) as make targets.
76+
# These do not pick up environment variables passed to ./configure
77+
# Export compiler flags to make them available when configuring and building
78+
# these packages.
79+
# An alternative is to include these when calling ./configure AND make
80+
export CFLAGS LDFLAGS
81+
export CPPFLAGS="${CFLAGS}"
82+
83+
./configure \
7684
--build="${BUILD_TRIPLE}" \
7785
--host="${TARGET_TRIPLE}" \
7886
--prefix=/tools/deps \

cpython-unix/targets.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ armv7-unknown-linux-gnueabi:
185185
host_cxx: /usr/bin/x86_64-linux-gnu-g++
186186
target_cc: /usr/bin/arm-linux-gnueabi-gcc
187187
target_cxx: /usr/bin/arm-linux-gnueabi-g++
188+
target_ldflags:
189+
# Hardening
190+
- '-Wl,-z,noexecstack'
188191
needs:
189192
- autoconf
190193
- bdb
@@ -226,6 +229,9 @@ armv7-unknown-linux-gnueabihf:
226229
host_cxx: /usr/bin/x86_64-linux-gnu-g++
227230
target_cc: /usr/bin/arm-linux-gnueabihf-gcc
228231
target_cxx: /usr/bin/arm-linux-gnueabihf-g++
232+
target_ldflags:
233+
# Hardening
234+
- '-Wl,-z,noexecstack'
229235
needs:
230236
- autoconf
231237
- bdb
@@ -266,6 +272,9 @@ loongarch64-unknown-linux-gnu:
266272
host_cxx: /usr/bin/x86_64-linux-gnu-g++
267273
target_cc: /usr/bin/loongarch64-linux-gnu-gcc
268274
target_cxx: /usr/bin/loongarch64-linux-gnu-g++
275+
target_ldflags:
276+
# Hardening
277+
- '-Wl,-z,noexecstack'
269278
needs:
270279
- autoconf
271280
- bdb
@@ -307,6 +316,9 @@ mips-unknown-linux-gnu:
307316
host_cxx: /usr/bin/x86_64-linux-gnu-g++
308317
target_cc: /usr/bin/mips-linux-gnu-gcc
309318
target_cxx: /usr/bin/mips-linux-gnu-g++
319+
target_ldflags:
320+
# Hardening
321+
- '-Wl,-z,noexecstack'
310322
needs:
311323
- autoconf
312324
- bdb
@@ -348,6 +360,9 @@ mipsel-unknown-linux-gnu:
348360
host_cxx: /usr/bin/x86_64-linux-gnu-g++
349361
target_cc: /usr/bin/mipsel-linux-gnu-gcc
350362
target_cxx: /usr/bin/mipsel-linux-gnu-g++
363+
target_ldflags:
364+
# Hardening
365+
- '-Wl,-z,noexecstack'
351366
needs:
352367
- autoconf
353368
- bdb
@@ -389,6 +404,9 @@ ppc64le-unknown-linux-gnu:
389404
host_cxx: /usr/bin/x86_64-linux-gnu-g++
390405
target_cc: /usr/bin/powerpc64le-linux-gnu-gcc
391406
target_cxx: /usr/bin/powerpc64le-linux-gnu-g++
407+
target_ldflags:
408+
# Hardening
409+
- '-Wl,-z,noexecstack'
392410
needs:
393411
- autoconf
394412
- bdb
@@ -430,6 +448,9 @@ riscv64-unknown-linux-gnu:
430448
host_cxx: /usr/bin/x86_64-linux-gnu-g++
431449
target_cc: /usr/bin/riscv64-linux-gnu-gcc
432450
target_cxx: /usr/bin/riscv64-linux-gnu-g++
451+
target_ldflags:
452+
# Hardening
453+
- '-Wl,-z,noexecstack'
433454
needs:
434455
- autoconf
435456
- bdb
@@ -474,6 +495,9 @@ s390x-unknown-linux-gnu:
474495
target_cflags:
475496
# set the minimum compatibility level to z10 (released 2008)
476497
- '-march=z10'
498+
target_ldflags:
499+
# Hardening
500+
- '-Wl,-z,noexecstack'
477501
needs:
478502
- autoconf
479503
- bdb

pythonbuild/downloads.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@
212212
"version": "1.4.19",
213213
},
214214
"mpdecimal": {
215-
"url": "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz",
215+
# Mirrored from https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz
216+
"url": "https://astral-sh.github.io/mirror/files/mpdecimal-4.0.0.tar.gz",
216217
"size": 315325,
217218
"sha256": "942445c3245b22730fd41a67a7c5c231d11cb1b9936b9c0f76334fb7d0b4468c",
218219
"version": "4.0.0",

0 commit comments

Comments
 (0)