1
1
#!/usr/bin/python3
2
2
import os
3
+ import platform
3
4
import shutil
4
5
import argparse
6
+ import sysconfig
5
7
import tempfile
6
8
from pathlib import Path
7
9
from typing import Tuple
@@ -23,6 +25,15 @@ def sleep():
23
25
time .sleep (1 )
24
26
25
27
28
+ def is_arm64_process () -> bool :
29
+ # Are we currently running in 'native' arm64 mode?
30
+ return platform .machine () == 'arm64'
31
+
32
+
33
+ def is_on_macos () -> bool :
34
+ return 'macosx' in sysconfig .get_platform ()
35
+
36
+
26
37
def build () -> None :
27
38
axle_dir = Path (__file__ ).parents [1 ]
28
39
sysroot_dir = axle_dir / "axle-sysroot"
@@ -132,17 +143,22 @@ def build() -> None:
132
143
libstdcpp_dir = gcc_dir / 'libstdc++-v3'
133
144
run_and_check (['autoconf' ], cwd = libstdcpp_dir , env_additions = env )
134
145
146
+ gcc_configure_args = [
147
+ configure_script_path .as_posix (),
148
+ f"--target=x86_64-elf-axle" ,
149
+ f"--prefix={ build_products_dir .as_posix ()} " ,
150
+ f"--with-sysroot={ sysroot_dir .as_posix ()} " ,
151
+ "--disable-nls" ,
152
+ # Ref: https://stackoverflow.com/questions/46487529/crosscompiling-gcc-link-tests-are-not-allowed-after-gcc-no-executables-when-che
153
+ "--disable-bootstrap" ,
154
+ "--enable-languages=c,c++" ,
155
+ ]
156
+ if is_on_macos () and is_arm64_process ():
157
+ # homebrew_root = "/opt/homebrew/"
158
+ homebrew_root = "/usr/local/homebrew/"
159
+ gcc_configure_args .append (f"--with-gmp={ homebrew_root } " )
135
160
run_and_check (
136
- [
137
- configure_script_path .as_posix (),
138
- f"--target=x86_64-elf-axle" ,
139
- f"--prefix={ build_products_dir .as_posix ()} " ,
140
- f"--with-sysroot={ sysroot_dir .as_posix ()} " ,
141
- "--disable-nls" ,
142
- # Ref: https://stackoverflow.com/questions/46487529/crosscompiling-gcc-link-tests-are-not-allowed-after-gcc-no-executables-when-che
143
- "--disable-bootstrap" ,
144
- "--enable-languages=c,c++" ,
145
- ],
161
+ gcc_configure_args ,
146
162
cwd = gcc_build_dir ,
147
163
env_additions = env
148
164
)
0 commit comments