Skip to content

Commit d7437c1

Browse files
committed
WIP: Fix for m68k
1 parent 8329a35 commit d7437c1

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

.github/workflows/m68k.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
"--mini-tests",
2727
"--std-tests",
2828
# TODO(antoyo): fix those on m68k.
29-
#"--test-libcore",
29+
"--test-libcore",
3030
#"--extended-rand-tests",
3131
#"--extended-regex-example-tests",
3232
#"--extended-regex-tests",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 3f3f48e81b70d0ca8f3756171f246d6e75f2e6ba Mon Sep 17 00:00:00 2001
2+
From: None <[email protected]>
3+
Date: Fri, 27 Oct 2023 08:32:25 -0400
4+
Subject: [PATCH] Remove failing test on targets where pointers aren't aligned
5+
on 4 bytes
6+
7+
---
8+
library/core/tests/ptr.rs | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
12+
index ee885ad..836b944 100644
13+
--- a/library/core/tests/ptr.rs
14+
+++ b/library/core/tests/ptr.rs
15+
@@ -717,7 +717,7 @@ fn is_aligned_const() {
16+
assert!(ptr.is_aligned());
17+
assert!(ptr.is_aligned_to(1));
18+
assert!(ptr.is_aligned_to(2));
19+
- assert!(ptr.is_aligned_to(4));
20+
+ //assert!(ptr.is_aligned_to(4));
21+
assert!(ptr.wrapping_byte_add(2).is_aligned_to(1));
22+
assert!(ptr.wrapping_byte_add(2).is_aligned_to(2));
23+
assert!(!ptr.wrapping_byte_add(2).is_aligned_to(4));
24+
--
25+
2.42.0
26+

run_in_vm.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
vm_parent_dir=${CG_GCC_VM_DIR:-$(pwd)}
4+
vm_dir=vm
5+
exe=$1
6+
exe_filename=$(basename $exe)
7+
vm_home_dir=$vm_parent_dir/$vm_dir/home
8+
vm_exe_path=$vm_home_dir/$exe_filename
9+
inside_vm_exe_path=/home/$exe_filename
10+
sudo cp $exe $vm_exe_path
11+
12+
shift
13+
pushd $vm_parent_dir
14+
sudo chroot $vm_dir qemu-m68k-static $inside_vm_exe_path $@
15+
popd

src/type_.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use gccjit::{RValue, Struct, Type};
22
use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, TypeMembershipMethods};
33
use rustc_codegen_ssa::common::TypeKind;
4-
use rustc_middle::{bug, ty};
4+
use rustc_middle::{bug, ty::{self, ParamEnv, Ty}};
55
use rustc_middle::ty::layout::TyAndLayout;
66
use rustc_target::abi::{AddressSpace, Align, Integer, Size};
77

@@ -55,12 +55,21 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
5555
}
5656

5757
pub fn type_ptr_to(&self, ty: Type<'gcc>) -> Type<'gcc> {
58-
ty.make_pointer()
58+
/*let rust_type = self.tcx.types.usize;
59+
let rust_type = Ty::new_imm_ptr(self.tcx, rust_type);
60+
let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(rust_type)).unwrap();
61+
let align = layout.align.abi.bytes();
62+
println!("Align: {}", align);*/
63+
ty.make_pointer()//.get_aligned(4)
5964
}
6065

6166
pub fn type_ptr_to_ext(&self, ty: Type<'gcc>, _address_space: AddressSpace) -> Type<'gcc> {
6267
// TODO(antoyo): use address_space, perhaps with TYPE_ADDR_SPACE?
63-
ty.make_pointer()
68+
/*let rust_type = self.tcx.types.usize; // TODO: use pointer type.
69+
let rust_type = Ty::new_imm_ptr(self.tcx, rust_type);
70+
let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(rust_type)).unwrap();
71+
let align = layout.align.abi.bytes();*/
72+
ty.make_pointer()//.get_aligned(4)
6473
}
6574

6675
pub fn type_i8p(&self) -> Type<'gcc> {

test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,11 @@ function asm_tests() {
275275
#./build_sysroot/build_sysroot.sh --release
276276

277277
function test_libcore() {
278+
dir=$(pwd)
278279
pushd build_sysroot/sysroot_src/library/core/tests
279280
echo "[TEST] libcore"
280281
rm -r ./target || true
281-
../../../../../cargo.sh test
282+
CARGO_TARGET_M68K_UNKNOWN_LINUX_GNU_RUNNER="bash $dir/run_in_vm.sh" ../../../../../cargo.sh test --target m68k-unknown-linux-gnu -- --skip mem::align_of_32 --skip mem::align_of_basic --skip mem::align_of_val_basic --skip mem::offset_of --skip num::dec2flt::fast_path_correct --skip num::dec2flt::float::test_f32_integer_decode --skip num::dec2flt::float::test_f64_integer_decode --skip num::dec2flt::special_code_paths --skip ptr::nonnull_tagged_pointer_with_provenance
282283
popd
283284
}
284285

0 commit comments

Comments
 (0)