6464MACOS_ALLOW_FRAMEWORKS = {"CoreFoundation" }
6565
6666
67- def add_target_env (env , build_platform , target_triple , build_env ):
67+ def add_target_env (env , build_platform , target_triple , build_env , build_options ):
6868 add_env_common (env )
6969
7070 settings = get_target_settings (TARGETS_CONFIG , target_triple )
@@ -83,7 +83,11 @@ def add_target_env(env, build_platform, target_triple, build_env):
8383 env ["PYBUILD_PLATFORM" ] = build_platform
8484 env ["TOOLS_PATH" ] = build_env .tools_path
8585
86- extra_target_cflags = list (settings .get ("target_cflags" , []))
86+ if "debug" in build_options :
87+ extra_target_cflags = ["-O0" ]
88+ else :
89+ extra_target_cflags = ["-O3" ]
90+ extra_target_cflags += list (settings .get ("target_cflags" , []))
8791 extra_target_ldflags = list (settings .get ("target_ldflags" , []))
8892 extra_host_cflags = []
8993 extra_host_ldflags = []
@@ -272,7 +276,7 @@ def simple_build(
272276 if "static" in build_options :
273277 env ["STATIC" ] = 1
274278
275- add_target_env (env , host_platform , target_triple , build_env )
279+ add_target_env (env , host_platform , target_triple , build_env , build_options )
276280
277281 # for OpenSSL, set the OPENSSL_TARGET environment variable
278282 if entry .startswith ("openssl-" ):
@@ -379,7 +383,7 @@ def build_libedit(
379383 "LIBEDIT_VERSION" : DOWNLOADS ["libedit" ]["version" ],
380384 }
381385
382- add_target_env (env , host_platform , target_triple , build_env )
386+ add_target_env (env , host_platform , target_triple , build_env , build_options )
383387
384388 build_env .run ("build-libedit.sh" , environment = env )
385389 build_env .get_tools_archive (dest_archive , "deps" )
@@ -440,7 +444,7 @@ def build_cpython_host(
440444 "PYTHON_VERSION" : python_version ,
441445 }
442446
443- add_target_env (env , host_platform , target_triple , build_env )
447+ add_target_env (env , host_platform , target_triple , build_env , build_options )
444448
445449 # Set environment variables allowing convenient testing for Python
446450 # version ranges.
@@ -831,7 +835,7 @@ def build_cpython(
831835 if "static" in parsed_build_options :
832836 env ["CPYTHON_STATIC" ] = "1"
833837
834- add_target_env (env , host_platform , target_triple , build_env )
838+ add_target_env (env , host_platform , target_triple , build_env , build_options )
835839
836840 build_env .run ("build-cpython.sh" , environment = env )
837841
0 commit comments