@@ -117,13 +117,17 @@ def add_target_env(env, build_platform, target_triple, build_env):
117117 extra_host_ldflags = []
118118
119119 if build_platform == "linux64" :
120- env [ "BUILD_TRIPLE" ] = "x86_64-unknown-linux-gnu"
120+ machine = platform . machine ()
121121
122- env ["TARGET_TRIPLE" ] = (
123- target_triple .replace ("x86_64_v2-" , "x86_64-" )
124- .replace ("x86_64_v3-" , "x86_64-" )
125- .replace ("x86_64_v4-" , "x86_64-" )
126- )
122+ if machine == "aarch64" :
123+ env ["BUILD_TRIPLE" ] = "aarch64-unknown-linux-gnu"
124+ else :
125+ env ["BUILD_TRIPLE" ] = "x86_64-unknown-linux-gnu"
126+ env ["TARGET_TRIPLE" ] = (
127+ target_triple .replace ("x86_64_v2-" , "x86_64-" )
128+ .replace ("x86_64_v3-" , "x86_64-" )
129+ .replace ("x86_64_v4-" , "x86_64-" )
130+ )
127131
128132 # This will make x86_64_v2, etc count as cross-compiling. This is
129133 # semantically correct, since the current machine may not support
@@ -516,10 +520,12 @@ def python_build_info(
516520
517521 binary_suffix = ""
518522
519- if platform == "linux64" :
523+ if platform in ("linux64" , "linux_aarch64" ):
524+ arch = "aarch64" if platform == "linux_aarch64" else "x86_64"
525+
520526 bi ["core" ]["static_lib" ] = (
521- "install/lib/python{version}/config-{version}{binary_suffix}-x86_64 -linux-gnu/libpython{version}{binary_suffix}.a" .format (
522- version = version , binary_suffix = binary_suffix
527+ "install/lib/python{version}/config-{version}{binary_suffix}-{arch} -linux-gnu/libpython{version}{binary_suffix}.a" .format (
528+ version = version , binary_suffix = binary_suffix , arch = arch ,
523529 )
524530 )
525531
@@ -599,7 +605,7 @@ def python_build_info(
599605 if lib .startswith ("-l" ):
600606 lib = lib [2 :]
601607
602- if platform == "linux64" and lib not in linux_allowed_system_libraries :
608+ if platform in ( "linux64" , "linux_aarch64" ) and lib not in linux_allowed_system_libraries :
603609 raise Exception ("unexpected library in LIBS (%s): %s" % (libs , lib ))
604610 elif platform == "macos" and lib not in MACOS_ALLOW_SYSTEM_LIBRARIES :
605611 raise Exception ("unexpected library in LIBS (%s): %s" % (libs , lib ))
@@ -867,7 +873,7 @@ def build_cpython(
867873 extension_module_loading = ["builtin" ]
868874 crt_features = []
869875
870- if host_platform == "linux64" :
876+ if host_platform in ( "linux64" , "linux_aarch64" ) :
871877 if "static" in parsed_build_options :
872878 crt_features .append ("static" )
873879 else :
0 commit comments