Allow building stage 2 compiler libraries
This commit is contained in:
parent
cba53f0be5
commit
d44a256157
@ -159,6 +159,10 @@ fn main() {
|
|||||||
cmd.arg("-C").arg("panic=abort");
|
cmd.arg("-C").arg("panic=abort");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg!(not(feature="llvm")) && stage != "0" {
|
||||||
|
cmd.arg("-Zno-trans");
|
||||||
|
}
|
||||||
|
|
||||||
// Set various options from config.toml to configure how we're building
|
// Set various options from config.toml to configure how we're building
|
||||||
// code.
|
// code.
|
||||||
if env::var("RUSTC_DEBUGINFO") == Ok("true".to_string()) {
|
if env::var("RUSTC_DEBUGINFO") == Ok("true".to_string()) {
|
||||||
|
@ -531,7 +531,7 @@ impl<'a> Builder<'a> {
|
|||||||
// For other crates, however, we know that we've already got a standard
|
// For other crates, however, we know that we've already got a standard
|
||||||
// library up and running, so we can use the normal compiler to compile
|
// library up and running, so we can use the normal compiler to compile
|
||||||
// build scripts in that situation.
|
// build scripts in that situation.
|
||||||
if mode == Mode::Libstd {
|
if mode == Mode::Libstd || !self.build.config.llvm_enabled {
|
||||||
cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
|
cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
|
||||||
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
|
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,11 +104,7 @@ impl Step for Std {
|
|||||||
|
|
||||||
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
|
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
|
||||||
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
|
build.clear_if_dirty(&out_dir, &builder.rustc(compiler));
|
||||||
let mut cargo = if compiler.stage == 0 {
|
let mut cargo = builder.cargo(compiler, Mode::Libstd, target, "build");
|
||||||
builder.cargo(compiler, Mode::Libstd, target, "build")
|
|
||||||
}else{
|
|
||||||
builder.cargo(compiler, Mode::Libstd, target, "check")
|
|
||||||
};
|
|
||||||
std_cargo(build, &compiler, target, &mut cargo);
|
std_cargo(build, &compiler, target, &mut cargo);
|
||||||
run_cargo(build,
|
run_cargo(build,
|
||||||
&mut cargo,
|
&mut cargo,
|
||||||
@ -165,7 +161,6 @@ pub fn std_cargo(build: &Build,
|
|||||||
// missing
|
// missing
|
||||||
// We also only build the runtimes when --enable-sanitizers (or its
|
// We also only build the runtimes when --enable-sanitizers (or its
|
||||||
// config.toml equivalent) is used
|
// config.toml equivalent) is used
|
||||||
//cargo.env("RUST_FLAGS", "-Zno-trans");
|
|
||||||
cargo.env("LLVM_CONFIG", build.llvm_config(target));
|
cargo.env("LLVM_CONFIG", build.llvm_config(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ use derive_registrar;
|
|||||||
|
|
||||||
use profile;
|
use profile;
|
||||||
|
|
||||||
pub fn compile_input(sess: &Session,
|
pub fn compile_input(sess: &mut Session,
|
||||||
cstore: &CStore,
|
cstore: &CStore,
|
||||||
input: &Input,
|
input: &Input,
|
||||||
outdir: &Option<PathBuf>,
|
outdir: &Option<PathBuf>,
|
||||||
@ -100,17 +100,32 @@ pub fn compile_input(sess: &Session,
|
|||||||
sess.err("LLVM is not supported by this rustc. Please use -Z no-trans to compile")
|
sess.err("LLVM is not supported by this rustc. Please use -Z no-trans to compile")
|
||||||
}
|
}
|
||||||
|
|
||||||
if sess.opts.crate_types.iter().all(|&t|{
|
for cty in sess.opts.crate_types.iter_mut() {
|
||||||
t != CrateType::CrateTypeRlib && t != CrateType::CrateTypeExecutable
|
match *cty {
|
||||||
}) && !sess.opts.crate_types.is_empty() {
|
CrateType::CrateTypeRlib | CrateType::CrateTypeExecutable => {},
|
||||||
sess.err(
|
CrateType::CrateTypeDylib | CrateType::CrateTypeCdylib |
|
||||||
"LLVM is not supported by this rustc, so non rlib libraries are not supported"
|
CrateType::CrateTypeStaticlib => {
|
||||||
);
|
sess.parse_sess.span_diagnostic.warn(
|
||||||
|
&format!("LLVM unsupported, so non rlib output type {} \
|
||||||
|
will be treated like rlib lib", cty)
|
||||||
|
);
|
||||||
|
*cty = CrateType::CrateTypeRlib;
|
||||||
|
},
|
||||||
|
CrateType::CrateTypeProcMacro => {
|
||||||
|
sess.parse_sess.span_diagnostic.err(
|
||||||
|
"No LLVM support, so cant compile proc macros"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.abort_if_errors();
|
sess.abort_if_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure nobody changes sess after crate types
|
||||||
|
// have optionally been adjusted for no llvm builds
|
||||||
|
let sess = &*sess;
|
||||||
|
|
||||||
if sess.profile_queries() {
|
if sess.profile_queries() {
|
||||||
profile::begin();
|
profile::begin();
|
||||||
}
|
}
|
||||||
@ -267,6 +282,10 @@ pub fn compile_input(sess: &Session,
|
|||||||
|
|
||||||
if cfg!(not(feature="llvm")) {
|
if cfg!(not(feature="llvm")) {
|
||||||
let (_, _) = (outputs, trans);
|
let (_, _) = (outputs, trans);
|
||||||
|
|
||||||
|
if sess.opts.crate_types.contains(&CrateType::CrateTypeRlib) {
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
sess.fatal("LLVM is not supported by this rustc");
|
sess.fatal("LLVM is not supported by this rustc");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,9 +319,9 @@ pub fn compile_input(sess: &Session,
|
|||||||
CompileState::state_when_compilation_done(input, sess, outdir, output),
|
CompileState::state_when_compilation_done(input, sess, outdir, output),
|
||||||
Ok(())
|
Ok(())
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keep_hygiene_data(sess: &Session) -> bool {
|
fn keep_hygiene_data(sess: &Session) -> bool {
|
||||||
|
@ -457,6 +457,14 @@ impl<'a> Context<'a> {
|
|||||||
//
|
//
|
||||||
// The goal of this step is to look at as little metadata as possible.
|
// The goal of this step is to look at as little metadata as possible.
|
||||||
self.filesearch.search(|path, kind| {
|
self.filesearch.search(|path, kind| {
|
||||||
|
let mut path = path.to_owned();
|
||||||
|
if cfg!(not(feature="llvm")) {
|
||||||
|
// This is a hack to make crates both defined as dylib
|
||||||
|
// and rlib to be findable without LLVM
|
||||||
|
path.set_extension("rlib");
|
||||||
|
}
|
||||||
|
let path = &path;
|
||||||
|
|
||||||
let file = match path.file_name().and_then(|s| s.to_str()) {
|
let file = match path.file_name().and_then(|s| s.to_str()) {
|
||||||
None => return FileDoesntMatch,
|
None => return FileDoesntMatch,
|
||||||
Some(file) => file,
|
Some(file) => file,
|
||||||
@ -745,7 +753,15 @@ impl<'a> Context<'a> {
|
|||||||
let mut rmetas = FxHashMap();
|
let mut rmetas = FxHashMap();
|
||||||
let mut dylibs = FxHashMap();
|
let mut dylibs = FxHashMap();
|
||||||
{
|
{
|
||||||
let locs = locs.map(|l| PathBuf::from(l)).filter(|loc| {
|
let locs = locs.map(|l| PathBuf::from(l))
|
||||||
|
.map(|mut l| {
|
||||||
|
if cfg!(not(feature="llvm")) {
|
||||||
|
// This is a hack to make crates both defined as dylib
|
||||||
|
// and rlib to be findable without LLVM
|
||||||
|
l.set_extension("rlib");
|
||||||
|
}
|
||||||
|
l
|
||||||
|
}).filter(|loc| {
|
||||||
if !loc.exists() {
|
if !loc.exists() {
|
||||||
sess.err(&format!("extern location for {} does not exist: {}",
|
sess.err(&format!("extern location for {} does not exist: {}",
|
||||||
self.crate_name,
|
self.crate_name,
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
extern crate rustc_trans_utils;
|
|
||||||
|
|
||||||
use super::archive::{ArchiveBuilder, ArchiveConfig};
|
use super::archive::{ArchiveBuilder, ArchiveConfig};
|
||||||
use super::linker::Linker;
|
use super::linker::Linker;
|
||||||
use super::command::Command;
|
use super::command::Command;
|
||||||
@ -27,7 +25,6 @@ use {CrateTranslation, CrateInfo};
|
|||||||
use rustc::util::common::time;
|
use rustc::util::common::time;
|
||||||
use rustc::util::fs::fix_windows_verbatim_for_gcc;
|
use rustc::util::fs::fix_windows_verbatim_for_gcc;
|
||||||
use rustc::hir::def_id::CrateNum;
|
use rustc::hir::def_id::CrateNum;
|
||||||
use rustc::hir::svh::Svh;
|
|
||||||
use rustc_back::tempdir::TempDir;
|
use rustc_back::tempdir::TempDir;
|
||||||
use rustc_back::{PanicStrategy, RelroLevel};
|
use rustc_back::{PanicStrategy, RelroLevel};
|
||||||
use context::get_reloc_model;
|
use context::get_reloc_model;
|
||||||
@ -88,9 +85,9 @@ pub const RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET: usize =
|
|||||||
pub const RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET: usize =
|
pub const RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET: usize =
|
||||||
RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET + 8;
|
RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET + 8;
|
||||||
|
|
||||||
pub use self::rustc_trans_utils::link::{find_crate_name, filename_for_input,
|
pub use rustc_trans_utils::link::{find_crate_name, filename_for_input, default_output_for_target,
|
||||||
default_output_for_target, invalid_output_for_target,
|
invalid_output_for_target, build_link_meta, out_filename,
|
||||||
build_link_meta};
|
check_file_is_writeable};
|
||||||
|
|
||||||
// The third parameter is for env vars, used on windows to set up the
|
// The third parameter is for env vars, used on windows to set up the
|
||||||
// path for MSVC to find its DLLs, and gcc to find its bundled
|
// path for MSVC to find its DLLs, and gcc to find its bundled
|
||||||
@ -218,13 +215,6 @@ pub fn link_binary(sess: &Session,
|
|||||||
out_filenames
|
out_filenames
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_writeable(p: &Path) -> bool {
|
|
||||||
match p.metadata() {
|
|
||||||
Err(..) => true,
|
|
||||||
Ok(m) => !m.permissions().readonly()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf {
|
fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf {
|
||||||
let out_filename = outputs.single_output_file.clone()
|
let out_filename = outputs.single_output_file.clone()
|
||||||
.unwrap_or(outputs
|
.unwrap_or(outputs
|
||||||
@ -288,32 +278,6 @@ pub fn ignored_for_lto(info: &CrateInfo, cnum: CrateNum) -> bool {
|
|||||||
info.is_no_builtins.contains(&cnum) || info.compiler_builtins == Some(cnum)
|
info.is_no_builtins.contains(&cnum) || info.compiler_builtins == Some(cnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn out_filename(sess: &Session,
|
|
||||||
crate_type: config::CrateType,
|
|
||||||
outputs: &OutputFilenames,
|
|
||||||
crate_name: &str)
|
|
||||||
-> PathBuf {
|
|
||||||
let default_filename = filename_for_input(sess, crate_type, crate_name, outputs);
|
|
||||||
let out_filename = outputs.outputs.get(&OutputType::Exe)
|
|
||||||
.and_then(|s| s.to_owned())
|
|
||||||
.or_else(|| outputs.single_output_file.clone())
|
|
||||||
.unwrap_or(default_filename);
|
|
||||||
|
|
||||||
check_file_is_writeable(&out_filename, sess);
|
|
||||||
|
|
||||||
out_filename
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure files are writeable. Mac, FreeBSD, and Windows system linkers
|
|
||||||
// check this already -- however, the Linux linker will happily overwrite a
|
|
||||||
// read-only file. We should be consistent.
|
|
||||||
fn check_file_is_writeable(file: &Path, sess: &Session) {
|
|
||||||
if !is_writeable(file) {
|
|
||||||
sess.fatal(&format!("output file {} is not writeable -- check its \
|
|
||||||
permissions", file.display()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn link_binary_output(sess: &Session,
|
fn link_binary_output(sess: &Session,
|
||||||
trans: &CrateTranslation,
|
trans: &CrateTranslation,
|
||||||
crate_type: config::CrateType,
|
crate_type: config::CrateType,
|
||||||
|
@ -938,7 +938,7 @@ pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
|
|||||||
pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
rx: mpsc::Receiver<Box<Any + Send>>)
|
rx: mpsc::Receiver<Box<Any + Send>>)
|
||||||
-> OngoingCrateTranslation {
|
-> OngoingCrateTranslation {
|
||||||
use back::link::rustc_trans_utils::find_exported_symbols;
|
use rustc_trans_utils::find_exported_symbols;
|
||||||
|
|
||||||
check_for_rustc_errors_attr(tcx);
|
check_for_rustc_errors_attr(tcx);
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ extern crate rustc_incremental;
|
|||||||
extern crate rustc_llvm as llvm;
|
extern crate rustc_llvm as llvm;
|
||||||
extern crate rustc_platform_intrinsics as intrinsics;
|
extern crate rustc_platform_intrinsics as intrinsics;
|
||||||
extern crate rustc_const_math;
|
extern crate rustc_const_math;
|
||||||
|
extern crate rustc_trans_utils;
|
||||||
extern crate rustc_demangle;
|
extern crate rustc_demangle;
|
||||||
extern crate jobserver;
|
extern crate jobserver;
|
||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
|
@ -14,10 +14,43 @@ use rustc::middle::cstore::{self, LinkMeta};
|
|||||||
use rustc::dep_graph::{DepKind, DepNode};
|
use rustc::dep_graph::{DepKind, DepNode};
|
||||||
use rustc::hir::svh::Svh;
|
use rustc::hir::svh::Svh;
|
||||||
use rustc_incremental::IncrementalHashesMap;
|
use rustc_incremental::IncrementalHashesMap;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
|
pub fn out_filename(sess: &Session,
|
||||||
|
crate_type: config::CrateType,
|
||||||
|
outputs: &OutputFilenames,
|
||||||
|
crate_name: &str)
|
||||||
|
-> PathBuf {
|
||||||
|
let default_filename = filename_for_input(sess, crate_type, crate_name, outputs);
|
||||||
|
let out_filename = outputs.outputs.get(&OutputType::Exe)
|
||||||
|
.and_then(|s| s.to_owned())
|
||||||
|
.or_else(|| outputs.single_output_file.clone())
|
||||||
|
.unwrap_or(default_filename);
|
||||||
|
|
||||||
|
check_file_is_writeable(&out_filename, sess);
|
||||||
|
|
||||||
|
out_filename
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure files are writeable. Mac, FreeBSD, and Windows system linkers
|
||||||
|
// check this already -- however, the Linux linker will happily overwrite a
|
||||||
|
// read-only file. We should be consistent.
|
||||||
|
pub fn check_file_is_writeable(file: &Path, sess: &Session) {
|
||||||
|
if !is_writeable(file) {
|
||||||
|
sess.fatal(&format!("output file {} is not writeable -- check its \
|
||||||
|
permissions", file.display()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_writeable(p: &Path) -> bool {
|
||||||
|
match p.metadata() {
|
||||||
|
Err(..) => true,
|
||||||
|
Ok(m) => !m.permissions().readonly()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta {
|
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta {
|
||||||
let krate_dep_node = &DepNode::new_no_params(DepKind::Krate);
|
let krate_dep_node = &DepNode::new_no_params(DepKind::Krate);
|
||||||
let r = LinkMeta {
|
let r = LinkMeta {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user