Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl<'a> Linker for GccLinker<'a> {
LinkOutputKind::StaticNoPicExe => {
// `-static` works for both gcc wrapper and ld.
self.link_or_cc_arg("-static");
if !self.is_ld && self.is_gnu {
if !self.is_ld && self.is_gnu && !self.sess.target.is_like_windows {
self.cc_arg("-no-pie");
}
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_target/src/spec/base/windows_gnullvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ pub(crate) fn opts() -> TargetOptions {
// but LLVM maintainers rejected it: https://reviews.llvm.org/D51440
let pre_link_args = TargetOptions::link_args(
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
&["-nolibc", "--unwindlib=none"],
&["-nolibc", "--unwindlib=libunwind", "-static-libgcc"],
);
// Order of `late_link_args*` does not matter with LLD.
let mingw_libs = &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"];

let mut late_link_args =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::No, Lld::No), &["-l:libunwind.a"]);
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);

TargetOptions {
Expand All @@ -46,8 +47,6 @@ pub(crate) fn opts() -> TargetOptions {
eh_frame_header: false,
no_default_libraries: false,
has_thread_local: true,
crt_static_allows_dylibs: true,
crt_static_respected: true,
debuginfo_kind: DebuginfoKind::Dwarf,
// FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to
// output DWO, despite using DWARF, doesn't use ELF..
Expand Down
5 changes: 0 additions & 5 deletions library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,3 @@ cfg_select! {
#[cfg(target_os = "hurd")]
#[link(name = "gcc_s")]
unsafe extern "C" {}

#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
unsafe extern "C" {}
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ fn copy_third_party_objects(
}

if target == "x86_64-fortanix-unknown-sgx"
|| target.ends_with("windows-gnullvm")
|| builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree
&& (target.contains("linux")
|| target.contains("fuchsia")
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,7 @@ impl CommandLineStep for Libunwind {
cfg.define("_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS", None);
cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
cfg.include(root.join("include"));
cfg.include(root.join("src"));
cfg.cargo_metadata(false);
cfg.out_dir(&out_dir);

Expand Down
Loading