Skip to content

Commit

Permalink
Link libgcc statically on Win64.
Browse files Browse the repository at this point in the history
Allow linking it statically on Win32 with an override.
  • Loading branch information
vadimcn committed Sep 22, 2014
1 parent 3907a13 commit a468659
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/librustc/back/link.rs
Expand Up @@ -991,10 +991,15 @@ fn link_args(cmd: &mut Command,
}

if sess.targ_cfg.os == abi::OsWindows {
// Make sure that we link to the dynamic libgcc, otherwise cross-module
// DWARF stack unwinding will not work.
// This behavior may be overridden by --link-args "-static-libgcc"
cmd.arg("-shared-libgcc");
if sess.targ_cfg.arch == abi::X86 {
// Make sure that we link to the dynamic libgcc, otherwise cross-module
// DWARF stack unwinding will not work.
// This behavior may be overridden by -Clink-args="-static-libgcc"
cmd.arg("-shared-libgcc");
} else {
// On Win64 unwinding is handled by the OS, so we can link libgcc statically.
cmd.arg("-static-libgcc");
}

// And here, we see obscure linker flags #45. On windows, it has been
// found to be necessary to have this flag to compile liblibc.
Expand Down
1 change: 0 additions & 1 deletion src/librustrt/libunwind.rs
Expand Up @@ -87,7 +87,6 @@ pub type _Unwind_Exception_Cleanup_Fn =

#[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "windows")]
#[link(name = "gcc_s")]
extern {}

Expand Down

5 comments on commit a468659

@bors
Copy link
Contributor

@bors bors commented on a468659 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at vadimcn@a468659

@bors
Copy link
Contributor

@bors bors commented on a468659 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging vadimcn/rust/link-libgcc = a468659 into auto

@bors
Copy link
Contributor

@bors bors commented on a468659 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vadimcn/rust/link-libgcc = a468659 merged ok, testing candidate = 8cad720

@bors
Copy link
Contributor

@bors bors commented on a468659 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a468659 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 8cad720

Please sign in to comment.