Skip to content

Commit

Permalink
Make simple_global_asm even simpler
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrhota committed Apr 13, 2017
1 parent 24a89a0 commit 63a0747
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for hir::Item {
hir::ItemFn(..) |
hir::ItemMod(..) |
hir::ItemForeignMod(..) |
hir::ItemGlobalAsm(..) |
hir::ItemTy(..) |
hir::ItemEnum(..) |
hir::ItemStruct(..) |
Expand Down Expand Up @@ -925,6 +926,7 @@ impl_stable_hash_for!(enum hir::Item_ {
ItemFn(fn_decl, unsafety, constness, abi, generics, body_id),
ItemMod(module),
ItemForeignMod(foreign_mod),
ItemGlobalAsm(global_asm),
ItemTy(ty, generics),
ItemEnum(enum_def, generics),
ItemStruct(variant_data, generics),
Expand Down Expand Up @@ -1083,6 +1085,7 @@ impl_stable_hash_for!(enum hir::def::Def {
Upvar(def_id, index, expr_id),
Label(node_id),
Macro(def_id, macro_kind),
GlobalAsm(def_id),
Err
});

Expand Down
1 change: 1 addition & 0 deletions src/librustc_metadata/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for EntryKind<'tcx> {
EntryKind::ForeignImmStatic |
EntryKind::ForeignMutStatic |
EntryKind::ForeignMod |
EntryKind::GlobalAsm |
EntryKind::Field |
EntryKind::Type => {
// Nothing else to hash here.
Expand Down
8 changes: 5 additions & 3 deletions src/test/run-pass/simple_global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
// except according to those terms.

#![feature(global_asm)]
#![feature(naked_functions)]

#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
global_asm!(r#"
.global foo
foo:
jmp baz
ret
"#);

extern {
fn foo();
}

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

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

0 comments on commit 63a0747

Please sign in to comment.