Skip to content

Commit 07f2116

Browse files
committed
WIP: Fix int intrinsics
1 parent a122c90 commit 07f2116

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

build_sysroot/build_sysroot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if [[ "$1" == "--release" ]]; then
2323
else
2424
sysroot_channel='debug'
2525
# TODO: add flags to simplify the case for cross-compilation.
26-
AR="m68k-unknown-linux-gnu-ar" CC="m68k-unknown-linux-gnu-gcc" cargo build --target $TARGET_TRIPLE --features compiler_builtins/c
26+
AR="m68k-unknown-linux-gnu-ar" CC="m68k-unknown-linux-gnu-gcc" cargo build --target $TARGET_TRIPLE
2727
fi
2828

2929
# Copy files to sysroot

build_system/src/prepare.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::utils::{cargo_install, git_clone, run_command, run_command_with_outpu
44
use std::fs;
55
use std::path::Path;
66

7-
fn prepare_libcore(sysroot_path: &Path) -> Result<(), String> {
7+
fn prepare_libcore(sysroot_path: &Path, cross_compile: bool) -> Result<(), String> {
88
let rustc_path = match get_rustc_path() {
99
Some(path) => path,
1010
None => return Err("`rustc` path not found".to_string()),
@@ -87,6 +87,12 @@ fn prepare_libcore(sysroot_path: &Path) -> Result<(), String> {
8787
Ok(())
8888
},
8989
)?;
90+
if cross_compile {
91+
walk_dir("cross_patches", |_| Ok(()), |file_path: &Path| {
92+
patches.push(file_path.to_path_buf());
93+
Ok(())
94+
})?;
95+
}
9096
patches.sort();
9197
for file_path in patches {
9298
println!("[GIT] apply `{}`", file_path.display());
@@ -156,24 +162,30 @@ where
156162
}
157163

158164
struct PrepareArg {
165+
cross_compile: bool,
159166
only_libcore: bool,
160167
}
161168

162169
impl PrepareArg {
163170
fn new() -> Result<Option<Self>, String> {
164171
let mut only_libcore = false;
172+
let mut cross_compile = false;
165173

166174
for arg in std::env::args().skip(2) {
167175
match arg.as_str() {
168176
"--only-libcore" => only_libcore = true,
177+
"--cross" => cross_compile = true,
169178
"--help" => {
170179
Self::usage();
171180
return Ok(None);
172181
}
173182
a => return Err(format!("Unknown argument `{a}`")),
174183
}
175184
}
176-
Ok(Some(Self { only_libcore }))
185+
Ok(Some(Self {
186+
cross_compile,
187+
only_libcore,
188+
}))
177189
}
178190

179191
fn usage() {
@@ -194,7 +206,7 @@ pub fn run() -> Result<(), String> {
194206
None => return Ok(()),
195207
};
196208
let sysroot_path = Path::new("build_sysroot");
197-
prepare_libcore(sysroot_path)?;
209+
prepare_libcore(sysroot_path, args.cross_compile)?;
198210

199211
if !args.only_libcore {
200212
cargo_install("hyperfine")?;

tests/lang_tests_common.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,25 @@ pub fn main_inner(profile: Profile) {
7373
}
7474
}
7575
// Test command 2: run `tempdir/x`.
76-
let vm_parent_dir = "..";
77-
let vm_dir = "vm";
76+
let vm_parent_dir = "/home/bouanto/Ordinateur/VirtualMachines";
77+
let vm_dir = "debian-m68k-root-img/";
7878
let exe_filename = exe.file_name().unwrap();
7979
let vm_exe_path = PathBuf::from(vm_parent_dir).join(vm_dir).join("home").join(exe_filename);
8080
// FIXME: panicking here makes the test pass.
8181
let inside_vm_exe_path = PathBuf::from("/home").join(&exe_filename);
8282
let mut copy = Command::new("sudo");
8383
copy.arg("cp");
8484
copy.args(&[&exe, &vm_exe_path]);
85-
copy.status().expect("copy executable inside VM");
8685

8786
let mut runtime = Command::new("sudo");
8887
runtime.args(&["chroot", vm_dir, "qemu-m68k-static"]);
8988
runtime.arg(inside_vm_exe_path);
9089
runtime.current_dir(vm_parent_dir);
91-
vec![("Compiler", compiler), ("Run-time", runtime)]
90+
vec![
91+
("Compiler", compiler),
92+
("Copy", copy),
93+
("Run-time", runtime),
94+
]
9295
})
9396
.run();
9497
}

0 commit comments

Comments
 (0)