Skip to content

Commit 63a0747

Browse files
committed
Make simple_global_asm even simpler
Windows builder croaked. This change tries to fix that by actually calling the global_asm-defined function so the symbol doesn't get optimized away, if that is in fact what was happening. Additionally, we provide an empty main() for non-x86 arches.
1 parent 24a89a0 commit 63a0747

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Diff for: src/librustc/ich/impls_hir.rs

+3
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for hir::Item {
881881
hir::ItemFn(..) |
882882
hir::ItemMod(..) |
883883
hir::ItemForeignMod(..) |
884+
hir::ItemGlobalAsm(..) |
884885
hir::ItemTy(..) |
885886
hir::ItemEnum(..) |
886887
hir::ItemStruct(..) |
@@ -925,6 +926,7 @@ impl_stable_hash_for!(enum hir::Item_ {
925926
ItemFn(fn_decl, unsafety, constness, abi, generics, body_id),
926927
ItemMod(module),
927928
ItemForeignMod(foreign_mod),
929+
ItemGlobalAsm(global_asm),
928930
ItemTy(ty, generics),
929931
ItemEnum(enum_def, generics),
930932
ItemStruct(variant_data, generics),
@@ -1083,6 +1085,7 @@ impl_stable_hash_for!(enum hir::def::Def {
10831085
Upvar(def_id, index, expr_id),
10841086
Label(node_id),
10851087
Macro(def_id, macro_kind),
1088+
GlobalAsm(def_id),
10861089
Err
10871090
});
10881091

Diff for: src/librustc_metadata/schema.rs

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for EntryKind<'tcx> {
298298
EntryKind::ForeignImmStatic |
299299
EntryKind::ForeignMutStatic |
300300
EntryKind::ForeignMod |
301+
EntryKind::GlobalAsm |
301302
EntryKind::Field |
302303
EntryKind::Type => {
303304
// Nothing else to hash here.

Diff for: src/test/run-pass/simple_global_asm.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@
99
// except according to those terms.
1010

1111
#![feature(global_asm)]
12+
#![feature(naked_functions)]
1213

1314
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
1415
global_asm!(r#"
1516
.global foo
1617
foo:
17-
jmp baz
18+
ret
1819
"#);
1920

2021
extern {
2122
fn foo();
2223
}
2324

24-
#[no_mangle]
25-
pub extern fn baz() {}
25+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
26+
fn main() { unsafe { foo(); } }
2627

28+
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
2729
fn main() {}

0 commit comments

Comments
 (0)