Skip to content

rustc: Remove __rust_crate_map_toplevel alias #12588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
18 changes: 0 additions & 18 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2641,24 +2641,6 @@ pub fn trans_crate(sess: session::Session,
decl_gc_metadata(ccx, llmod_id);
fill_crate_map(ccx, ccx.crate_map);

// win32: wart with exporting crate_map symbol
// We set the crate map (_rust_crate_map_toplevel) to use dll_export
// linkage but that ends up causing the linker to look for a
// __rust_crate_map_toplevel symbol (extra underscore) which it will
// subsequently fail to find. So to mitigate that we just introduce
// an alias from the symbol it expects to the one that actually exists.
if ccx.sess.targ_cfg.os == OsWin32 && !ccx.sess.building_library.get() {

let maptype = val_ty(ccx.crate_map).to_ref();

"__rust_crate_map_toplevel".with_c_str(|buf| {
unsafe {
llvm::LLVMAddAlias(ccx.llmod, maptype,
ccx.crate_map, buf);
}
})
}

glue::emit_tydescs(ccx);
if ccx.sess.opts.debuginfo {
debuginfo::finalize(ccx);
Expand Down
17 changes: 12 additions & 5 deletions src/libstd/rt/crate_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,21 @@ pub fn get_crate_map() -> Option<&'static CrateMap<'static>> {

let sym = unsafe {
let module = dl::open_internal();
let rust_crate_map_toplevel = if cfg!(target_arch = "x86") {
"__rust_crate_map_toplevel"
} else {
"_rust_crate_map_toplevel"
};
let rust_crate_map_toplevel = "_rust_crate_map_toplevel";
let sym = rust_crate_map_toplevel.with_c_str(|buf| {
dl::symbol(module, buf)
});

// NOTE remove this after snapshot
let sym = if sym.is_null() {
let rust_crate_map_toplevel = "__rust_crate_map_toplevel";
rust_crate_map_toplevel.with_c_str(|buf| {
dl::symbol(module, buf)
})
} else {
sym
};

dl::close(module);
sym
};
Expand Down
2 changes: 1 addition & 1 deletion src/llvm
Submodule llvm updated from b015ec to 5fe5e1