@@ -181,8 +181,9 @@ def wasi_sdk_env(context):
181181 for env_var , binary_name in list (env .items ()):
182182 env [env_var ] = os .fsdecode (wasi_sdk_path / "bin" / binary_name )
183183
184- if not wasi_sdk_path .name .startswith ("wasi-sdk" ):
185- for compiler in ["CC" , "CPP" , "CXX" ]:
184+ for compiler in ["CC" , "CPP" , "CXX" ]:
185+ env [compiler ] += f" --target={ context .host_triple } "
186+ if not wasi_sdk_path .name .startswith ("wasi-sdk" ):
186187 env [compiler ] += f" --sysroot={ sysroot } "
187188
188189 env ["PKG_CONFIG_PATH" ] = ""
@@ -229,7 +230,11 @@ def configure_wasi_python(context, working_dir):
229230 "https://github.com/bytecodealliance/wasmtime"
230231 )
231232 host_runner = context .host_runner .format_map (args )
232- env_additions = {"CONFIG_SITE" : config_site , "HOSTRUNNER" : host_runner }
233+ env_additions = {
234+ "CONFIG_SITE" : config_site ,
235+ "HOSTRUNNER" : host_runner ,
236+ "CFLAGS" : f"{ os .environ .get ('CFLAGS' , '' )} -DPY_CALL_TRAMPOLINE" .strip (),
237+ }
233238 build_python = os .fsdecode (context .build_python_interpreter )
234239 # The path to `configure` MUST be relative, else `python.wasm` is unable
235240 # to find the stdlib due to Python not recognizing that it's being
@@ -239,7 +244,6 @@ def configure_wasi_python(context, working_dir):
239244 f"--host={ context .host_triple } " ,
240245 f"--build={ context .build_python_path .name } " ,
241246 f"--with-build-python={ build_python } " ,
242- "CFLAGS=-DPY_CALL_TRAMPOLINE" ,
243247 ]
244248 if context .is_debug :
245249 configure .append ("--with-pydebug" )
0 commit comments