rustc: Link LLVM directly into rustc again

This commit builds on #65501 continue to simplify the build system and
compiler now that we no longer have multiple LLVM backends to ship by
default. Here this switches the compiler back to what it once was long
long ago, which is linking LLVM directly to the compiler rather than
dynamically loading it at runtime. The `codegen-backends` directory of
the sysroot no longer exists and all relevant support in the build
system is removed. Note that `rustc` still supports a dynamically loaded
codegen backend as it did previously, it just no longer supports
dynamically loaded codegen backends in its own sysroot.

Additionally as part of this the `librustc_codegen_llvm` crate now once
again explicitly depends on all of its crates instead of implicitly
loading them through the sysroot. This involved filling out its
`Cargo.toml` and deleting all the now-unnecessary `extern crate`
annotations in the header of the crate. (this in turn required adding a
number of imports for names of macros too).

The end results of this change are:

* Rustbuild's build process for the compiler as all the "oh don't forget
  the codegen backend" checks can be easily removed.
* Building `rustc_codegen_llvm` is much simpler since it's simply
  another compiler crate.
* Managing the dependencies of `rustc_codegen_llvm` is much simpler since
  it's "just another `Cargo.toml` to edit"
* The build process should be a smidge faster because there's more
  parallelism in the main rustc build step rather than splitting
  `librustc_codegen_llvm` out to its own step.
* The compiler is expected to be slightly faster by default because the
  codegen backend does not need to be dynamically loaded.
* Disabling LLVM as part of rustbuild is still supported, supporting
  multiple codegen backends is still supported, and dynamic loading of a
  codegen backend is still supported.
This commit is contained in:
Alex Crichton 2019-10-22 08:51:35 -07:00 committed by Aaron Hill
parent 033662dfbc
commit 7f23e6e8d7
No known key found for this signature in database
GPG key ID: B4087E510E98B164
41 changed files with 163 additions and 415 deletions

View file

@ -24,6 +24,7 @@
use back::write::{create_target_machine, create_informational_target_machine};
use syntax_pos::symbol::Symbol;
<<<<<<< HEAD
extern crate rustc_demangle;
extern crate flate2;
#[macro_use] extern crate bitflags;
@ -46,11 +47,13 @@ extern crate syntax_pos;
extern crate rustc_errors as errors;
extern crate rustc_session;
=======
>>>>>>> rustc: Link LLVM directly into rustc again
use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::back::write::{CodegenContext, ModuleConfig, FatLTOInput};
use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModule};
use rustc_codegen_ssa::CompiledModule;
use errors::{FatalError, Handler};
use rustc_errors::{FatalError, Handler};
use rustc::dep_graph::WorkProduct;
use syntax::expand::allocator::AllocatorKind;
pub use llvm_util::target_features;
@ -339,12 +342,6 @@ impl CodegenBackend for LlvmCodegenBackend {
}
}
/// This is the entrypoint for a hot plugged rustc_codegen_llvm
#[no_mangle]
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
LlvmCodegenBackend::new()
}
pub struct ModuleLlvm {
llcx: &'static mut llvm::Context,
llmod_raw: *const llvm::Module,