Skip to content

Commit a2ffa58

Browse files
committed
Disable libstd and libtest dylib
1 parent 85bc611 commit a2ffa58

File tree

6 files changed

+71
-13
lines changed

6 files changed

+71
-13
lines changed

.github/workflows/m68k.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ jobs:
6767
- name: Setup path to libgccjit
6868
run: |
6969
sudo dpkg -i gcc-m68k-13.deb
70-
echo "*********************"
71-
ls /usr/bin
72-
echo "*********************"
73-
ls /bin
74-
echo "*********************"
75-
ls /lib
76-
echo "*********************"
77-
ls /usr/lib
7870
echo /usr/lib/ > gcc_path
7971
8072
- name: Set env
@@ -119,7 +111,6 @@ jobs:
119111
#path: rust
120112
#key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }}
121113

122-
# TODO: reset cross-gcc config file (i.e. try to revert CT_BINUTILS_V_2_37 to CT_BINUTILS_V_2_38).
123114
- name: Test build (TODO REMOVE)
124115
run: |
125116
cat > main.c <<EOF
@@ -148,6 +139,10 @@ jobs:
148139
- name: Build
149140
run: |
150141
./y.sh prepare --only-libcore
142+
# TODO: move into prepare command under a flag --cross-patches?
143+
pushd build_sysroot/sysroot_src
144+
git am ../../cross_patches/*.patch
145+
popd
151146
./build.sh
152147
cargo test
153148
./clean_all.sh

build_sysroot/build_sysroot.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ if [[ "$1" == "--release" ]]; then
2222
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
2323
else
2424
sysroot_channel='debug'
25-
cargo build --target $TARGET_TRIPLE --features compiler_builtins/c
25+
# 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
2627
fi
2728

2829
# Copy files to sysroot

config.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ RUN_WRAPPER=''
2828
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
2929
if [[ "$TARGET_TRIPLE" == "m68k-unknown-linux-gnu" ]]; then
3030
#TARGET_TRIPLE="mips-unknown-linux-gnu"
31+
# TODO: figure a better way for the user to do that automatically for any target.
3132
linker='-Clinker=m68k-unknown-linux-gnu-gcc'
3233
elif [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
3334
# We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
@@ -61,4 +62,4 @@ export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
6162
# To do so, add a symlink for cc to /opt/gcc/bin/gcc in our PATH.
6263
# Another option would be to add the following Rust flag: -Clinker=/opt/gcc/bin/gcc
6364
export PATH="/opt/m68k-unknown-linux-gnu/bin:$PATH"
64-
export TARGET=$TARGET_TRIPLE
65+
#export TARGET=$TARGET_TRIPLE
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From 966beefe08be6045bfcca26079b76a7a80413080 Mon Sep 17 00:00:00 2001
2+
From: None <[email protected]>
3+
Date: Thu, 28 Sep 2023 17:37:38 -0400
4+
Subject: [PATCH] Disable libstd and libtest dylib
5+
6+
---
7+
library/std/Cargo.toml | 2 +-
8+
library/test/Cargo.toml | 2 +-
9+
2 files changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
12+
index 5b21355..cb0c49b 100644
13+
--- a/library/std/Cargo.toml
14+
+++ b/library/std/Cargo.toml
15+
@@ -9,7 +9,7 @@ description = "The Rust Standard Library"
16+
edition = "2021"
17+
18+
[lib]
19+
-crate-type = ["dylib", "rlib"]
20+
+crate-type = ["rlib"]
21+
22+
[dependencies]
23+
alloc = { path = "../alloc", public = true }
24+
diff --git a/library/test/Cargo.toml b/library/test/Cargo.toml
25+
index 91a1abd..a58c160 100644
26+
--- a/library/test/Cargo.toml
27+
+++ b/library/test/Cargo.toml
28+
@@ -4,7 +4,7 @@ version = "0.0.0"
29+
edition = "2021"
30+
31+
[lib]
32+
-crate-type = ["dylib", "rlib"]
33+
+crate-type = ["rlib"]
34+
35+
[dependencies]
36+
getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] }
37+
--
38+
2.42.0
39+

tests/lang_tests_common.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ pub fn main_inner(profile: Profile) {
5050
"-o", exe.to_str().expect("to_str"),
5151
path.to_str().expect("to_str"),
5252
]);
53+
54+
// TODO: allow setting this with a CLI arg (or environment variable if not possible).
55+
compiler.args(&["--target", "m68k-unknown-linux-gnu"]);
56+
compiler.args(&["-Clinker=m68k-unknown-linux-gnu-gcc"]);
57+
let mut env_path = std::env::var("PATH").unwrap_or_default();
58+
env_path = format!("/opt/m68k-unknown-linux-gnu/bin:{}", env_path);
59+
compiler.env("PATH", env_path);
60+
5361
if let Some(flags) = option_env!("TEST_FLAGS") {
5462
for flag in flags.split_whitespace() {
5563
compiler.arg(&flag);
@@ -65,7 +73,21 @@ pub fn main_inner(profile: Profile) {
6573
}
6674
}
6775
// Test command 2: run `tempdir/x`.
68-
let runtime = Command::new(exe);
76+
let vm_parent_dir = "..";
77+
let vm_dir = "vm";
78+
let exe_filename = exe.file_name().unwrap();
79+
let vm_exe_path = PathBuf::from(vm_parent_dir).join(vm_dir).join("home").join(exe_filename);
80+
// FIXME: panicking here makes the test pass.
81+
let inside_vm_exe_path = PathBuf::from("/home").join(&exe_filename);
82+
let mut copy = Command::new("sudo");
83+
copy.arg("cp");
84+
copy.args(&[&exe, &vm_exe_path]);
85+
copy.status().expect("copy executable inside VM");
86+
87+
let mut runtime = Command::new("sudo");
88+
runtime.args(&["chroot", vm_dir, "qemu-m68k-static"]);
89+
runtime.arg(inside_vm_exe_path);
90+
runtime.current_dir(vm_parent_dir);
6991
vec![("Compiler", compiler), ("Run-time", runtime)]
7092
})
7193
.run();

tests/run/empty_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ pub(crate) unsafe auto trait Freeze {}
3535
*/
3636

3737
#[start]
38-
fn main(mut argc: isize, _argv: *const *const u8) -> isize {
38+
fn main(_argc: isize, _argv: *const *const u8) -> isize {
3939
0
4040
}

0 commit comments

Comments
 (0)