Skip to content
New issue

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

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

Already on GitHub? # to your account

rustc_llvm: remove stale references #46280

Merged
merged 3 commits into from
Dec 2, 2017
Merged
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ config.stamp
keywords.md
lexer.ml
src/etc/dl
src/librustc_llvm/llvmdeps.rs
tmp.*.rs
version.md
version.ml
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl Step for TestHelpers {
.warnings(false)
.debug(false)
.file(build.src.join("src/rt/rust_test_helpers.c"))
.compile("librust_test_helpers.a");
.compile("rust_test_helpers");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ fn main() {
cc::Build::new()
.flag("-fvisibility=hidden")
.file("pthread_atfork_dummy.c")
.compile("libpthread_atfork_dummy.a");
.compile("pthread_atfork_dummy");
}
}
2 changes: 1 addition & 1 deletion src/libprofiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ fn main() {
cfg.file(Path::new("../libcompiler_builtins/compiler-rt/lib/profile").join(src));
}

cfg.compile("libprofiler-rt.a");
cfg.compile("profiler-rt");
}
8 changes: 4 additions & 4 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ fn main() {
}

for component in &components {
let mut flag = String::from("-DLLVM_COMPONENT_");
let mut flag = String::from("LLVM_COMPONENT_");
flag.push_str(&component.to_uppercase());
cfg.flag(&flag);
cfg.define(&flag, None);
}

if env::var_os("LLVM_RUSTLLVM").is_some() {
cfg.flag("-DLLVM_RUSTLLVM");
cfg.define("LLVM_RUSTLLVM", None);
}

build_helper::rerun_if_changed_anything_in_dir(Path::new("../rustllvm"));
Expand All @@ -169,7 +169,7 @@ fn main() {
.file("../rustllvm/ArchiveWrapper.cpp")
.cpp(true)
.cpp_link_stdlib(None) // we handle this below
.compile("librustllvm.a");
.compile("rustllvm");

let (llvm_kind, llvm_link_arg) = detect_llvm_link(major, minor, &llvm_config);

Expand Down
18 changes: 7 additions & 11 deletions src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,13 @@ pub mod debuginfo {

pub enum ModuleBuffer {}

// Link to our native llvm bindings (things that we need to use the C++ api
// for) and because llvm is written in C++ we need to link against libstdc++
//
// You'll probably notice that there is an omission of all LLVM libraries
// from this location. This is because the set of LLVM libraries that we
// link to is mostly defined by LLVM, and the `llvm-config` tool is used to
// figure out the exact set of libraries. To do this, the build system
// generates an llvmdeps.rs file next to this one which will be
// automatically updated whenever LLVM is updated to include an up-to-date
// set of the libraries we need to link to LLVM for.
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this comment still largely applicable with some editing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sort of, but there's no longer anything here to anchor it to, and the relevant code (in build.rs) is rather self explanatory.

Copy link
Member

Choose a reason for hiding this comment

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

Ok yeah on rereading let's leave out

#[link(name = "rustllvm", kind = "static")] // not quite true but good enough
Copy link
Member

Choose a reason for hiding this comment

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

This line shouldn't be removed as I believe it's required for msvc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure? cc::Build::compile prints to stdout a cargo directive that makes the link work, which I think is how this works. https://docs.rs/cc/1.0.3/src/cc/lib.rs.html#781

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I am quite sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you help me understand how hoedown, profiler-rt, binaryen_wrapper, and others work? AFAICT, none of them have #[link(...)] attributes.

Copy link
Member

Choose a reason for hiding this comment

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

Sure yes. This annotation is primarily needed for MSVC where attributes like dllimport/dllexport are applied and need to be correct for everything to link successfully. The #[link] annotation here says "these symbols are included statically" which means that they're all exported with dllexport and from the rustc_llvm dynamic library. Otherwise the rustc_trans dynamic library would not be able to access these symbols.

The other libraries we have just happen to not run into this situation where they cross dynamic library boundaries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I've included your explanation in the code.

// This annotation is primarily needed for MSVC where attributes like
// dllimport/dllexport are applied and need to be correct for everything to
// link successfully. The #[link] annotation here says "these symbols are
// included statically" which means that they're all exported with dllexport
// and from the rustc_llvm dynamic library. Otherwise the rustc_trans dynamic
// library would not be able to access these symbols.
#[link(name = "rustllvm", kind = "static")]
extern "C" {
// Create and destroy contexts.
pub fn LLVMContextCreate() -> ContextRef;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fn main() {
.warnings(false)
.include(src_dir)
.warnings(false)
.compile("libhoedown.a");
.compile("hoedown");
}