Skip to content

Commit 7d8bb5e

Browse files
authored
Declare the target_cxx value for all targets (#563)
This value can leak into user builds through sysconfig so it is not appropriate to use the `host_cxx`. See astral-sh/uv#12207 There's not a `musl-clang++` equivalent — so we skip this for those targets.
1 parent 4ef6f72 commit 7d8bb5e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Diff for: cpython-unix/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def add_target_env(env, build_platform, target_triple, build_env):
103103
env["CC"] = settings["target_cc"]
104104
# We always set CXX, otherwise a build could bypass our toolchain
105105
# accidentally, e.g., on macOS where `g++` links to the system clang.
106-
env["CXX"] = settings.get("target_cxx", settings.get("host_cxx"))
106+
env["CXX"] = settings["target_cxx"]
107107

108108
if settings.get("bolt_capable"):
109109
env["BOLT_CAPABLE"] = "1"

Diff for: cpython-unix/targets.yml

+29
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
# target_cc
2626
# Path to C compiler to use for building binaries targeting the
2727
# target architecture.
28+
29+
# target_cxx
30+
# Path to C++ compiler to use for building binaries targeting the
31+
# target architecture.
2832
#
2933
# target_cflags
3034
# List of extra compiler flags to use when building for the target.
@@ -69,6 +73,7 @@ aarch64-apple-darwin:
6973
host_cc: clang
7074
host_cxx: clang++
7175
target_cc: clang
76+
target_cxx: clang++
7277
apple_sdk_platform: macosx
7378
target_cflags:
7479
- '-arch'
@@ -114,6 +119,7 @@ aarch64-apple-ios:
114119
host_cc: clang
115120
host_cxx: clang++
116121
target_cc: clang
122+
target_cxx: clang++
117123
target_cflags:
118124
- '-arch'
119125
- 'arm64'
@@ -159,6 +165,7 @@ aarch64-unknown-linux-gnu:
159165
host_cc: /usr/bin/x86_64-linux-gnu-gcc
160166
host_cxx: /usr/bin/x86_64-linux-gnu-g++
161167
target_cc: /usr/bin/aarch64-linux-gnu-gcc
168+
target_cxx: /usr/bin/aarch64-linux-gnu-g++
162169
needs:
163170
- autoconf
164171
- bdb
@@ -195,6 +202,7 @@ arm64-apple-tvos:
195202
host_cc: clang
196203
host_cxx: clang++
197204
target_cc: clang
205+
target_cxx: clang++
198206
target_cflags:
199207
- '-arch'
200208
- 'arm64'
@@ -239,6 +247,7 @@ armv7-unknown-linux-gnueabi:
239247
host_cc: /usr/bin/x86_64-linux-gnu-gcc
240248
host_cxx: /usr/bin/x86_64-linux-gnu-g++
241249
target_cc: /usr/bin/arm-linux-gnueabi-gcc
250+
target_cxx: /usr/bin/arm-linux-gnueabi-g++
242251
needs:
243252
- autoconf
244253
- bdb
@@ -279,6 +288,7 @@ armv7-unknown-linux-gnueabihf:
279288
host_cc: /usr/bin/x86_64-linux-gnu-gcc
280289
host_cxx: /usr/bin/x86_64-linux-gnu-g++
281290
target_cc: /usr/bin/arm-linux-gnueabihf-gcc
291+
target_cxx: /usr/bin/arm-linux-gnueabihf-g++
282292
needs:
283293
- autoconf
284294
- bdb
@@ -319,6 +329,7 @@ i686-unknown-linux-gnu:
319329
host_cc: clang
320330
host_cxx: clang++
321331
target_cc: clang
332+
target_cxx: clang++
322333
target_cflags:
323334
- '-m32'
324335
- '-fvisibility=hidden'
@@ -364,6 +375,7 @@ mips-unknown-linux-gnu:
364375
host_cc: /usr/bin/x86_64-linux-gnu-gcc
365376
host_cxx: /usr/bin/x86_64-linux-gnu-g++
366377
target_cc: /usr/bin/mips-linux-gnu-gcc
378+
target_cxx: /usr/bin/mips-linux-gnu-g++
367379
needs:
368380
- autoconf
369381
- bdb
@@ -404,6 +416,7 @@ mipsel-unknown-linux-gnu:
404416
host_cc: /usr/bin/x86_64-linux-gnu-gcc
405417
host_cxx: /usr/bin/x86_64-linux-gnu-g++
406418
target_cc: /usr/bin/mipsel-linux-gnu-gcc
419+
target_cxx: /usr/bin/mipsel-linux-gnu-g++
407420
needs:
408421
- autoconf
409422
- bdb
@@ -444,6 +457,7 @@ ppc64le-unknown-linux-gnu:
444457
host_cc: /usr/bin/x86_64-linux-gnu-gcc
445458
host_cxx: /usr/bin/x86_64-linux-gnu-g++
446459
target_cc: /usr/bin/powerpc64le-linux-gnu-gcc
460+
target_cxx: /usr/bin/powerpc64le-linux-gnu-g++
447461
needs:
448462
- autoconf
449463
- bdb
@@ -484,6 +498,7 @@ riscv64-unknown-linux-gnu:
484498
host_cc: /usr/bin/x86_64-linux-gnu-gcc
485499
host_cxx: /usr/bin/x86_64-linux-gnu-g++
486500
target_cc: /usr/bin/riscv64-linux-gnu-gcc
501+
target_cxx: /usr/bin/riscv64-linux-gnu-g++
487502
needs:
488503
- autoconf
489504
- bdb
@@ -524,6 +539,7 @@ s390x-unknown-linux-gnu:
524539
host_cc: /usr/bin/x86_64-linux-gnu-gcc
525540
host_cxx: /usr/bin/x86_64-linux-gnu-g++
526541
target_cc: /usr/bin/s390x-linux-gnu-gcc
542+
target_cxx: /usr/bin/s390x-linux-gnu-g++
527543
needs:
528544
- autoconf
529545
- bdb
@@ -560,6 +576,7 @@ thumb7k-apple-watchos:
560576
host_cc: clang
561577
host_cxx: clang++
562578
target_cc: clang
579+
target_cxx: clang++
563580
target_cflags:
564581
- '-arch'
565582
- 'armv7k'
@@ -609,6 +626,7 @@ x86_64-apple-darwin:
609626
host_cc: clang
610627
host_cxx: clang++
611628
target_cc: clang
629+
target_cxx: clang++
612630
target_cflags:
613631
- '-arch'
614632
- 'x86_64'
@@ -653,6 +671,7 @@ x86_64-apple-ios:
653671
host_cc: clang
654672
host_cxx: clang++
655673
target_cc: clang
674+
target_cxx: clang++
656675
target_cflags:
657676
- '-arch'
658677
- 'x86_64'
@@ -694,6 +713,7 @@ x86_64-apple-tvos:
694713
host_cc: clang
695714
host_cxx: clang++
696715
target_cc: clang
716+
target_cxx: clang++
697717
target_cflags:
698718
- '-arch'
699719
- 'x86_64'
@@ -734,6 +754,7 @@ x86_64-apple-watchos:
734754
host_cc: clang
735755
host_cxx: clang++
736756
target_cc: clang
757+
target_cxx: clang++
737758
target_cflags:
738759
- '-arch'
739760
- 'x86_64'
@@ -778,6 +799,7 @@ x86_64-unknown-linux-gnu:
778799
host_cc: clang
779800
host_cxx: clang++
780801
target_cc: clang
802+
target_cxx: clang++
781803
target_cflags:
782804
- '-fvisibility=hidden'
783805
# Needed to prevent BOLT from crashing.
@@ -823,6 +845,7 @@ x86_64_v2-unknown-linux-gnu:
823845
host_cc: clang
824846
host_cxx: clang++
825847
target_cc: clang
848+
target_cxx: clang++
826849
target_cflags:
827850
- '-march=x86-64-v2'
828851
- '-fvisibility=hidden'
@@ -869,6 +892,7 @@ x86_64_v3-unknown-linux-gnu:
869892
host_cc: clang
870893
host_cxx: clang++
871894
target_cc: clang
895+
target_cxx: clang++
872896
target_cflags:
873897
- '-march=x86-64-v3'
874898
- '-fvisibility=hidden'
@@ -915,6 +939,7 @@ x86_64_v4-unknown-linux-gnu:
915939
host_cc: clang
916940
host_cxx: clang++
917941
target_cc: clang
942+
target_cxx: clang++
918943
target_cflags:
919944
- '-march=x86-64-v4'
920945
- '-fvisibility=hidden'
@@ -961,6 +986,7 @@ x86_64-unknown-linux-musl:
961986
host_cc: clang
962987
host_cxx: clang++
963988
target_cc: musl-clang
989+
target_cxx: clang++ # TODO: Explore a musl-clang++ shim?
964990
target_cflags:
965991
- '-fvisibility=hidden'
966992
needs:
@@ -1004,6 +1030,7 @@ x86_64_v2-unknown-linux-musl:
10041030
host_cc: clang
10051031
host_cxx: clang++
10061032
target_cc: musl-clang
1033+
target_cxx: clang++ # TODO: Explore a musl-clang++ shim?
10071034
target_cflags:
10081035
- '-march=x86-64-v2'
10091036
- '-fvisibility=hidden'
@@ -1048,6 +1075,7 @@ x86_64_v3-unknown-linux-musl:
10481075
host_cc: clang
10491076
host_cxx: clang++
10501077
target_cc: musl-clang
1078+
target_cxx: clang++ # TODO: Explore a musl-clang++ shim?
10511079
target_cflags:
10521080
- '-march=x86-64-v3'
10531081
- '-fvisibility=hidden'
@@ -1092,6 +1120,7 @@ x86_64_v4-unknown-linux-musl:
10921120
host_cc: clang
10931121
host_cxx: clang++
10941122
target_cc: musl-clang
1123+
target_cxx: clang++ # TODO: Explore a musl-clang++ shim?
10951124
target_cflags:
10961125
- '-march=x86-64-v4'
10971126
- '-fvisibility=hidden'

0 commit comments

Comments
 (0)