Skip to content

Commit fd54085

Browse files
committed
unix: set CC in add_target_env()
This is boilerplate code that can be consolidated. And we don't want to set CC when using a toolchain already in the environment.
1 parent 2b90ff7 commit fd54085

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

cpython-unix/build.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ def install_sccache(build_env):
8787
def add_target_env(env, build_platform, target_triple, build_env):
8888
add_env_common(env)
8989

90+
settings = get_target_settings(TARGETS_CONFIG, target_triple)
91+
92+
if settings.get("needs_toolchain"):
93+
if "musl" in target_triple:
94+
env["CC"] = "musl-clang"
95+
else:
96+
env["CC"] = "clang"
97+
9098
env["PYBUILD_PLATFORM"] = build_platform
9199
env["TOOLS_PATH"] = build_env.tools_path
92100

@@ -293,12 +301,9 @@ def simple_build(
293301
build_env.copy_file(SUPPORT / ("build-%s.sh" % entry))
294302

295303
env = {
296-
"CC": "clang",
297304
"TOOLCHAIN": "clang-%s" % host_platform,
298305
"%s_VERSION" % entry.upper().replace("-", "_"): DOWNLOADS[entry]["version"],
299306
}
300-
if "musl" in target_triple:
301-
env["CC"] = "musl-clang"
302307

303308
add_target_env(env, host_platform, target_triple, build_env)
304309

@@ -472,14 +477,10 @@ def build_libedit(
472477
build_env.copy_file(SUPPORT / "build-libedit.sh")
473478

474479
env = {
475-
"CC": "clang",
476480
"TOOLCHAIN": "clang-%s" % host_platform,
477481
"LIBEDIT_VERSION": DOWNLOADS["libedit"]["version"],
478482
}
479483

480-
if "musl" in target_triple:
481-
env["CC"] = "musl-clang"
482-
483484
add_target_env(env, host_platform, target_triple, build_env)
484485

485486
build_env.run("build-libedit.sh", environment=env)
@@ -508,14 +509,10 @@ def build_readline(
508509
build_env.copy_file(SUPPORT / "build-readline.sh")
509510

510511
env = {
511-
"CC": "clang",
512512
"TOOLCHAIN": "clang-%s" % host_platform,
513513
"READLINE_VERSION": DOWNLOADS["readline"]["version"],
514514
}
515515

516-
if "musl" in target_triple:
517-
env["CC"] = "musl-clang"
518-
519516
add_target_env(env, host_platform, target_triple, build_env)
520517

521518
build_env.run("build-readline.sh", environment=env)
@@ -550,16 +547,12 @@ def build_tix(
550547
build_env.copy_file(p)
551548

552549
env = {
553-
"CC": "clang",
554550
"TOOLCHAIN": "clang-%s" % host_platform,
555551
"TCL_VERSION": DOWNLOADS["tcl"]["version"],
556552
"TIX_VERSION": DOWNLOADS["tix"]["version"],
557553
"TK_VERSION": DOWNLOADS["tk"]["version"],
558554
}
559555

560-
if "musl" in target_triple:
561-
env["CC"] = "musl-clang"
562-
563556
add_target_env(env, host_platform, target_triple, build_env)
564557

565558
build_env.run("build-tix.sh", environment=env)
@@ -895,17 +888,13 @@ def build_cpython(
895888
build_env.copy_file(fh.name, dest_name="Makefile.extra")
896889

897890
env = {
898-
"CC": "clang",
899891
"PIP_VERSION": DOWNLOADS["pip"]["version"],
900892
"PYTHON_VERSION": entry["version"],
901893
"PYTHON_MAJMIN_VERSION": ".".join(entry["version"].split(".")[0:2]),
902894
"SETUPTOOLS_VERSION": DOWNLOADS["setuptools"]["version"],
903895
"TOOLCHAIN": "clang-%s" % host_platform,
904896
}
905897

906-
if "musl" in target_triple:
907-
env["CC"] = "musl-clang"
908-
909898
if optimizations == "debug":
910899
env["CPYTHON_DEBUG"] = "1"
911900
if optimizations in ("pgo", "pgo+lto"):

0 commit comments

Comments
 (0)