10
10
from build_utils import run_and_check
11
11
from build_utils import run_and_capture_output_and_check
12
12
13
-
14
13
_REPO_ROOT = Path (__file__ ).parents [1 ]
15
14
_RUST_PROGRAMS_DIR = _REPO_ROOT / "rust_programs"
16
15
# TODO(PT): Template this file to include the full path to x86_64-elf-axle-gcc
@@ -84,14 +83,14 @@ def _build_rust_libc_port(temp_dir: Path) -> None:
84
83
env = {'CC' : toolchain_dir / 'bin' / 'x86_64-elf-axle-gcc' }
85
84
run_and_check (
86
85
[
87
- 'cargo' ,
88
- 'build' ,
89
- '--no-default-features' ,
90
- '-Zbuild-std=core,alloc' ,
86
+ 'cargo' ,
87
+ 'build' ,
88
+ '--no-default-features' ,
89
+ '-Zbuild-std=core,alloc' ,
91
90
# '-Z macro-backtrace',
92
91
f'--target={ _TARGET_SPEC_FILE .as_posix ()} ' ,
93
92
],
94
- cwd = libc_dir ,
93
+ cwd = libc_dir ,
95
94
env_additions = env
96
95
)
97
96
@@ -133,7 +132,7 @@ def test_rust_programs() -> None:
133
132
],
134
133
cwd = program_dir
135
134
)
136
-
135
+
137
136
138
137
def build_rust_programs (check_only : bool = False ) -> None :
139
138
cargo_workspace_dir = _RUST_PROGRAMS_DIR
@@ -151,7 +150,11 @@ def build_rust_programs(check_only: bool = False) -> None:
151
150
'features=host_dep' ,
152
151
],
153
152
cwd = cargo_workspace_dir ,
154
- env_additions = {"RUSTFLAGS" : "-Cforce-frame-pointers=yes" },
153
+ # PT: Without manually linking axle's newlib port, linking failed after adding some Rust code that
154
+ # implicitly called `fmod`:
155
+ # /libm.a(lib_a-w_fmod.o): in function `fmod':
156
+ # .../newlib/libm/math/w_fmod.c:89: undefined reference to `__errno'
157
+ env_additions = {"RUSTFLAGS" : "-Cforce-frame-pointers=yes -Clink-arg=-lc" },
155
158
)
156
159
for entry in cargo_workspace_dir .iterdir ():
157
160
if not entry .is_dir ():
0 commit comments