parent
cc30c20293
commit
53ef00e68c
@ -136,8 +136,15 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
|
||||
if name.is_empty() || !symbol.is_global() || symbol.is_undefined() {
|
||||
return None;
|
||||
}
|
||||
let dlsym_name = if cfg!(target_os = "macos") {
|
||||
// On macOS `dlsym` expects the name without leading `_`.
|
||||
assert!(name.starts_with("_"), "{:?}", name);
|
||||
&name[1..]
|
||||
} else {
|
||||
&name
|
||||
};
|
||||
let symbol: libloading::Symbol<*const u8> =
|
||||
unsafe { lib.get(name.as_bytes()) }.unwrap();
|
||||
unsafe { lib.get(dlsym_name.as_bytes()) }.unwrap();
|
||||
Some((name, *symbol))
|
||||
}));
|
||||
std::mem::forget(lib)
|
||||
|
16
test.sh
16
test.sh
@ -12,16 +12,6 @@ fi
|
||||
|
||||
source config.sh
|
||||
|
||||
jit() {
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
# FIXME(#671) `dlsym` returns "symbol not found" for existing symbols on macOS.
|
||||
echo "[JIT] $1 (Ignored on macOS)"
|
||||
else
|
||||
echo "[JIT] $1"
|
||||
SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic $2
|
||||
fi
|
||||
}
|
||||
|
||||
rm -r target/out || true
|
||||
mkdir -p target/out/clif
|
||||
|
||||
@ -31,7 +21,8 @@ $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib
|
||||
echo "[BUILD] example"
|
||||
$RUSTC example/example.rs --crate-type lib
|
||||
|
||||
#JIT_ARGS="abc bcd" jit mini_core_hello_world example/mini_core_hello_world.rs
|
||||
echo "[JIT] mini_core_hello_world"
|
||||
JIT_ARGS="abc bcd" SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs
|
||||
|
||||
echo "[AOT] mini_core_hello_world"
|
||||
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g
|
||||
@ -49,7 +40,8 @@ echo "[AOT] alloc_example"
|
||||
$RUSTC example/alloc_example.rs --crate-type bin
|
||||
./target/out/alloc_example
|
||||
|
||||
jit std_example example/std_example.rs
|
||||
echo "[JIT] std_example"
|
||||
SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs
|
||||
|
||||
echo "[AOT] dst_field_align"
|
||||
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
|
||||
|
Loading…
Reference in New Issue
Block a user