Skip to content

Commit 909bffa

Browse files
authored
Merge pull request #211 from madsmtm/test-assembly-gnustep
Test GNUStep assembly
2 parents 9e32ff6 + c54c300 commit 909bffa

File tree

34 files changed

+1593
-1011
lines changed

34 files changed

+1593
-1011
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,7 @@ jobs:
403403
args: ${{ env.ARGS }} ${{ env.TESTARGS }} --features unstable-static-sel
404404

405405
- name: Run assembly tests
406-
# Not run on GNUStep yet since a lot of function labels are mangled and
407-
# not inlined (and hence quite hard to match on, at some point we'll
408-
# need to find a solution to that).
409-
if: ${{ !contains(matrix.os, 'ubuntu') }}
406+
if: ${{ !contains(matrix.runtime, 'compiler-rt') }}
410407
shell: bash
411408
run:
412409
export HOST_TARGET=$(rustc -vV | grep host | cut -f2 -d' ')

helper-scripts/run-assembly-tests.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
export HELPER="cargo run --features=run --bin=test-assembly -- --target"
6+
export NIGHTLY_HELPER="cargo +nightly run --features=run --bin=test-assembly -- -Zbuild-std --target"
7+
8+
echo "Apple"
9+
$HELPER x86_64-apple-darwin
10+
$HELPER aarch64-apple-darwin
11+
$NIGHTLY_HELPER armv7s-apple-ios
12+
$NIGHTLY_HELPER armv7-apple-ios
13+
$NIGHTLY_HELPER i386-apple-ios
14+
15+
echo "Old Apple"
16+
$NIGHTLY_HELPER i686-apple-darwin
17+
18+
echo "GNUStep"
19+
$HELPER x86_64-unknown-linux-gnu --no-default-features --features=std,gnustep-2-1
20+
$HELPER i686-unknown-linux-gnu --no-default-features --features=std,gnustep-2-1
21+
22+
echo "Old GNUStep"
23+
$HELPER x86_64-unknown-linux-gnu --no-default-features --features=std,gnustep-1-7
24+
$HELPER i686-unknown-linux-gnu --no-default-features --features=std,gnustep-1-7

objc2/src/message/gnustep.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
use core::hint;
12
use core::mem;
23

34
use super::conditional_try;
45
use crate::ffi;
5-
use crate::runtime::{Class, Object, Sel};
6+
use crate::runtime::{Class, Imp, Object, Sel};
67
use crate::{Encode, MessageArguments};
78

9+
#[inline]
10+
fn unwrap_msg_send_fn(msg_send_fn: Option<Imp>) -> Imp {
11+
match msg_send_fn {
12+
Some(msg_send_fn) => msg_send_fn,
13+
None => {
14+
// SAFETY: This will never be NULL, even if the selector is not
15+
// found a callable function pointer will still be returned!
16+
//
17+
// `clang` doesn't insert a NULL check here either.
18+
unsafe { hint::unreachable_unchecked() }
19+
}
20+
}
21+
}
22+
823
#[track_caller]
924
pub(crate) unsafe fn send_unverified<A, R>(receiver: *mut Object, sel: Sel, args: A) -> R
1025
where
@@ -22,7 +37,7 @@ where
2237
}
2338

2439
let msg_send_fn = unsafe { ffi::objc_msg_lookup(receiver.cast(), sel.as_ptr()) };
25-
let msg_send_fn = msg_send_fn.expect("Null IMP");
40+
let msg_send_fn = unwrap_msg_send_fn(msg_send_fn);
2641
unsafe { conditional_try(|| A::__invoke(msg_send_fn, receiver, sel, args)) }
2742
}
2843

@@ -48,6 +63,6 @@ where
4863
super_class: superclass.cast(),
4964
};
5065
let msg_send_fn = unsafe { ffi::objc_msg_lookup_super(&sup, sel.as_ptr()) };
51-
let msg_send_fn = msg_send_fn.expect("Null IMP");
66+
let msg_send_fn = unwrap_msg_send_fn(msg_send_fn);
5267
unsafe { conditional_try(|| A::__invoke(msg_send_fn, receiver, sel, args)) }
5368
}

test-assembly/crates/test_msg_send_id/expected/apple-old-x86.s

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)