Skip to content

Commit c2f1073

Browse files
committed
workarounds to make link guards work on windows
Link guards cause problems in some specific scenarios on windows because they force libcore to be instantiated, since we do not GC functions effectively on windows. The changes here are two: 1. disable core for rsbegin/rsend 2. make panic_fmt an extern fn for smallest-hello-world so that it is not marked as "internal" for LLVM
1 parent e366ca6 commit c2f1073

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/rtstartup/rsbegin.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,20 @@
2323
// of other runtime components (registered via yet another special image section).
2424

2525
#![crate_type="rlib"]
26-
#![no_std]
26+
#![feature(no_core, lang_items, optin_builtin_traits)]
27+
#![no_core]
2728
#![allow(non_camel_case_types)]
2829

30+
#[lang="sized"]
31+
trait Sized {}
32+
33+
#[lang="copy"]
34+
trait Copy {}
35+
36+
#[lang="sync"]
37+
trait Sync {}
38+
impl Sync for .. {}
39+
2940
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
3041
pub mod eh_frames
3142
{

src/rtstartup/rsend.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
// See rsbegin.rs for details.
1212

1313
#![crate_type="rlib"]
14-
#![no_std]
14+
#![feature(no_core, lang_items, optin_builtin_traits)]
15+
#![no_core]
16+
17+
#[lang="sync"]
18+
trait Sync {}
19+
impl Sync for .. {}
1520

1621
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
1722
pub mod eh_frames

src/test/run-pass/smallest-hello-world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }
2222

2323
#[lang = "eh_personality"] extern fn eh_personality() {}
2424
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
25-
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
25+
#[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} }
2626
#[no_mangle] pub extern fn rust_eh_register_frames () {}
2727
#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
2828

0 commit comments

Comments
 (0)