Skip to content

Commit 625db2a

Browse files
committed
unix: define target cc in yaml config
This avoids hard-coding target-specific logic in code.
1 parent bc620d6 commit 625db2a

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

cpython-unix/build.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,7 @@ def add_target_env(env, build_platform, target_triple, build_env):
9090
settings = get_target_settings(TARGETS_CONFIG, target_triple)
9191

9292
env["HOST_CC"] = settings["host_cc"]
93-
94-
if settings.get("needs_toolchain"):
95-
if "musl" in target_triple:
96-
env["CC"] = "musl-clang"
97-
else:
98-
env["CC"] = "clang"
99-
elif target_triple == "aarch64-unknown-linux-gnu":
100-
env["CC"] = "aarch64-linux-gnu-gcc"
101-
elif target_triple == "armv7-unknown-linux-gnueabi":
102-
env["CC"] = "arm-linux-gnueabi-gcc"
103-
elif target_triple == "armv7-unknown-linux-gnueabihf":
104-
env["CC"] = "arm-linux-gnueabihf-gcc"
105-
elif target_triple == "mips-unknown-linux-gnu":
106-
env["CC"] = "mips-linux-gnu-gcc"
107-
elif target_triple == "mipsel-unknown-linux-gnu":
108-
env["CC"] = "mipsel-linux-gnu-gcc"
109-
elif target_triple == "mips64el-unknown-linux-gnuabi64":
110-
env["CC"] = "mips64el-linux-gnuabi64-gcc"
111-
elif target_triple == "s390x-unknown-linux-gnu":
112-
env["CC"] = "s390x-linux-gnu-gcc"
113-
else:
114-
raise Exception("unhandled target triple: %s" % target_triple)
93+
env["CC"] = settings["target_cc"]
11594

11695
env["PYBUILD_PLATFORM"] = build_platform
11796
env["TOOLS_PATH"] = build_env.tools_path

cpython-unix/targets.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
# Path to C compiler to use when producing binaries targeting the
1717
# current build environment.
1818
#
19+
# target_cc
20+
#
21+
# Path to C compiler to use for building binaries targeting the
22+
# target architecture.
23+
#
1924
# openssl_target
2025
# Name of OpenSSL platform build target.
2126

@@ -25,6 +30,7 @@ aarch64-apple-darwin:
2530
- darwin
2631
needs_toolchain: true
2732
host_cc: clang
33+
target_cc: clang
2834
needs:
2935
- bzip2
3036
- libedit
@@ -44,6 +50,7 @@ aarch64-apple-ios:
4450
- darwin
4551
needs_toolchain: true
4652
host_cc: clang
53+
target_cc: clang
4754
needs:
4855
- bzip2
4956
- libffi
@@ -57,6 +64,7 @@ aarch64-unknown-linux-gnu:
5764
- linux
5865
docker_image_suffix: .cross
5966
host_cc: /usr/bin/x86_64-linux-gnu-gcc
67+
target_cc: /usr/bin/aarch64-linux-gnu-gcc
6068
needs:
6169
- bdb
6270
- binutils
@@ -84,6 +92,7 @@ arm64-apple-tvos:
8492
- darwin
8593
needs_toolchain: true
8694
host_cc: clang
95+
target_cc: clang
8796
needs:
8897
- bzip2
8998
- sqlite
@@ -96,6 +105,7 @@ armv7-unknown-linux-gnueabi:
96105
- linux
97106
docker_image_suffix: .cross
98107
host_cc: /usr/bin/x86_64-linux-gnu-gcc
108+
target_cc: /usr/bin/arm-linux-gnueabi-gcc
99109
needs:
100110
- bdb
101111
- binutils
@@ -123,6 +133,7 @@ armv7-unknown-linux-gnueabihf:
123133
- linux
124134
docker_image_suffix: .cross
125135
host_cc: /usr/bin/x86_64-linux-gnu-gcc
136+
target_cc: /usr/bin/arm-linux-gnueabihf-gcc
126137
needs:
127138
- bdb
128139
- binutils
@@ -150,6 +161,7 @@ i686-unknown-linux-gnu:
150161
- linux
151162
needs_toolchain: true
152163
host_cc: clang
164+
target_cc: clang
153165
needs:
154166
- bdb
155167
- binutils
@@ -179,6 +191,7 @@ mips-unknown-linux-gnu:
179191
- linux
180192
docker_image_suffix: .cross
181193
host_cc: /usr/bin/x86_64-linux-gnu-gcc
194+
target_cc: /usr/bin/mips-linux-gnu-gcc
182195
needs:
183196
- bdb
184197
- binutils
@@ -206,6 +219,7 @@ mipsel-unknown-linux-gnu:
206219
- linux
207220
docker_image_suffix: .cross
208221
host_cc: /usr/bin/x86_64-linux-gnu-gcc
222+
target_cc: /usr/bin/mipsel-linux-gnu-gcc
209223
needs:
210224
- bdb
211225
- binutils
@@ -233,6 +247,7 @@ s390x-unknown-linux-gnu:
233247
- linux
234248
docker_image_suffix: .cross
235249
host_cc: /usr/bin/x86_64-linux-gnu-gcc
250+
target_cc: /usr/bin/s390x-linux-gnu-gcc
236251
needs:
237252
- bdb
238253
- binutils
@@ -260,6 +275,7 @@ thumb7k-apple-watchos:
260275
- darwin
261276
needs_toolchain: true
262277
host_cc: clang
278+
target_cc: clang
263279
needs:
264280
- bzip2
265281
- sqlite
@@ -271,6 +287,7 @@ x86_64-apple-darwin:
271287
host_platforms:
272288
- darwin
273289
host_cc: clang
290+
target_cc: clang
274291
needs:
275292
- bzip2
276293
- libedit
@@ -290,6 +307,7 @@ x86_64-apple-ios:
290307
- darwin
291308
needs_toolchain: true
292309
host_cc: clang
310+
target_cc: clang
293311
needs:
294312
- bzip2
295313
- libffi
@@ -303,6 +321,7 @@ x86_64-apple-tvos:
303321
- darwin
304322
needs_toolchain: true
305323
host_cc: clang
324+
target_cc: clang
306325
needs:
307326
- bzip2
308327
- sqlite
@@ -314,6 +333,7 @@ x86_64-apple-watchos:
314333
- darwin
315334
needs_toolchain: true
316335
host_cc: clang
336+
target_cc: clang
317337
needs:
318338
- bzip2
319339
- sqlite
@@ -326,6 +346,7 @@ x86_64-unknown-linux-gnu:
326346
- linux
327347
needs_toolchain: true
328348
host_cc: clang
349+
target_cc: clang
329350
needs:
330351
- bdb
331352
- binutils
@@ -354,6 +375,7 @@ x86_64-unknown-linux-musl:
354375
- linux
355376
needs_toolchain: true
356377
host_cc: clang
378+
target_cc: musl-clang
357379
needs:
358380
- bdb
359381
- binutils

0 commit comments

Comments
 (0)