about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-12 14:49:01 +0200
committerGitHub <noreply@github.com>2020-04-12 14:49:01 +0200
commitb83c2e952c493eaf5e006899fbe80acbcba06988 (patch)
tree1d94105e51a360afc6f35a83d9f9b521d9943958
parent32fb4dcdd7a57683a639a0959442711d0fd123bc (diff)
parent1864caaaa4d283143eb5e267e5cb46fa0500434a (diff)
downloadrust-b83c2e952c493eaf5e006899fbe80acbcba06988.tar.gz
rust-b83c2e952c493eaf5e006899fbe80acbcba06988.zip
Rollup merge of #71029 - Mark-Simulacrum:cargo-build, r=Mark-Simulacrum
Partial work on building with Cargo

This cherry picks the commits I'm directly approving from #70999, I want to land them so that that PR is smaller.
-rw-r--r--Cargo.lock5
-rw-r--r--src/bootstrap/compile.rs2
-rw-r--r--src/libprofiler_builtins/build.rs5
-rw-r--r--src/librustc_data_structures/Cargo.toml1
-rw-r--r--src/librustc_data_structures/lib.rs2
-rw-r--r--src/librustc_driver/Cargo.toml1
-rw-r--r--src/librustc_driver/lib.rs4
-rw-r--r--src/librustc_interface/Cargo.toml1
-rw-r--r--src/librustc_interface/lib.rs3
-rw-r--r--src/librustc_interface/tests.rs3
-rw-r--r--src/librustc_llvm/build.rs30
-rw-r--r--src/librustc_metadata/Cargo.toml1
-rw-r--r--src/librustc_metadata/lib.rs1
-rw-r--r--src/librustc_session/Cargo.toml1
-rw-r--r--src/librustc_session/lib.rs8
-rw-r--r--src/librustdoc/config.rs1
-rw-r--r--src/librustdoc/lib.rs2
-rw-r--r--src/libstd/Cargo.toml2
18 files changed, 42 insertions, 31 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 908bfa35557..73d276d1776 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3694,6 +3694,7 @@ dependencies = [
  "indexmap",
  "jobserver",
  "lazy_static 1.4.0",
+ "libc",
  "log",
  "measureme",
  "parking_lot 0.10.0",
@@ -3713,6 +3714,7 @@ version = "0.0.0"
 dependencies = [
  "env_logger 0.7.1",
  "lazy_static 1.4.0",
+ "libc",
  "log",
  "rustc_ast",
  "rustc_ast_pretty",
@@ -3867,6 +3869,7 @@ dependencies = [
 name = "rustc_interface"
 version = "0.0.0"
 dependencies = [
+ "libc",
  "log",
  "once_cell",
  "rustc-rayon",
@@ -3960,6 +3963,7 @@ name = "rustc_metadata"
 version = "0.0.0"
 dependencies = [
  "flate2",
+ "libc",
  "log",
  "memmap",
  "rustc_ast",
@@ -4197,6 +4201,7 @@ dependencies = [
 name = "rustc_session"
 version = "0.0.0"
 dependencies = [
+ "getopts",
  "log",
  "num_cpus",
  "rustc_ast",
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 32ce170a5a1..f44096af6dd 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -186,6 +186,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: Interned<String>, cargo: &mut Ca
     // `compiler-rt` is located.
     let compiler_builtins_root = builder.src.join("src/llvm-project/compiler-rt");
     let compiler_builtins_c_feature = if compiler_builtins_root.exists() {
+        // Note that `libprofiler_builtins/build.rs` also computes this so if
+        // you're changing something here please also change that.
         cargo.env("RUST_COMPILER_RT_ROOT", &compiler_builtins_root);
         " compiler-builtins-c".to_string()
     } else {
diff --git a/src/libprofiler_builtins/build.rs b/src/libprofiler_builtins/build.rs
index c990b289335..e23e2f2c130 100644
--- a/src/libprofiler_builtins/build.rs
+++ b/src/libprofiler_builtins/build.rs
@@ -63,8 +63,9 @@ fn main() {
         cfg.define("COMPILER_RT_HAS_ATOMICS", Some("1"));
     }
 
-    let root = env::var_os("RUST_COMPILER_RT_ROOT").unwrap();
-    let root = Path::new(&root);
+    // Note that this should exist if we're going to run (otherwise we just
+    // don't build profiler builtins at all).
+    let root = Path::new("../llvm-project/compiler-rt");
 
     let src_root = root.join("lib").join("profile");
     for src in profile_sources {
diff --git a/src/librustc_data_structures/Cargo.toml b/src/librustc_data_structures/Cargo.toml
index c5707bd24f7..6d7022acc78 100644
--- a/src/librustc_data_structures/Cargo.toml
+++ b/src/librustc_data_structures/Cargo.toml
@@ -27,6 +27,7 @@ smallvec = { version = "1.0", features = ["union", "may_dangle"] }
 rustc_index = { path = "../librustc_index", package = "rustc_index" }
 bitflags = "1.2.1"
 measureme = "0.7.1"
+libc = "0.2"
 
 [dependencies.parking_lot]
 version = "0.10"
diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs
index ba82e58d7a9..d0180911567 100644
--- a/src/librustc_data_structures/lib.rs
+++ b/src/librustc_data_structures/lib.rs
@@ -26,8 +26,6 @@
 
 #[macro_use]
 extern crate log;
-#[cfg(unix)]
-extern crate libc;
 #[macro_use]
 extern crate cfg_if;
 
diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml
index 652f16c2e08..cfd103aed32 100644
--- a/src/librustc_driver/Cargo.toml
+++ b/src/librustc_driver/Cargo.toml
@@ -11,6 +11,7 @@ crate-type = ["dylib"]
 
 [dependencies]
 lazy_static = "1.0"
+libc = "0.2"
 log = "0.4"
 env_logger = { version = "0.7", default-features = false }
 rustc_middle = { path = "../librustc_middle" }
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index acf8f1adbc2..0e3199975f9 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -8,9 +8,6 @@
 #![feature(nll)]
 #![recursion_limit = "256"]
 
-pub extern crate getopts;
-#[cfg(unix)]
-extern crate libc;
 #[macro_use]
 extern crate log;
 #[macro_use]
@@ -37,6 +34,7 @@ use rustc_save_analysis::DumpHandler;
 use rustc_serialize::json::{self, ToJson};
 use rustc_session::config::nightly_options;
 use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest};
+use rustc_session::getopts;
 use rustc_session::lint::{Lint, LintId};
 use rustc_session::{config, DiagnosticOutput, Session};
 use rustc_session::{early_error, early_warn};
diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml
index c9d81e51641..8ea866d7cab 100644
--- a/src/librustc_interface/Cargo.toml
+++ b/src/librustc_interface/Cargo.toml
@@ -10,6 +10,7 @@ path = "lib.rs"
 doctest = false
 
 [dependencies]
+libc = "0.2"
 log = "0.4"
 rayon = { version = "0.3.0", package = "rustc-rayon" }
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs
index ba1e2216ca8..0650d090034 100644
--- a/src/librustc_interface/lib.rs
+++ b/src/librustc_interface/lib.rs
@@ -6,9 +6,6 @@
 #![feature(generators)]
 #![recursion_limit = "256"]
 
-#[cfg(unix)]
-extern crate libc;
-
 mod callbacks;
 pub mod interface;
 mod passes;
diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs
index b452ccfe33a..c75f3b279a2 100644
--- a/src/librustc_interface/tests.rs
+++ b/src/librustc_interface/tests.rs
@@ -1,5 +1,3 @@
-extern crate getopts;
-
 use crate::interface::parse_cfgspecs;
 
 use rustc_data_structures::fx::FxHashSet;
@@ -9,6 +7,7 @@ use rustc_session::config::{build_configuration, build_session_options, to_crate
 use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
 use rustc_session::config::{ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
 use rustc_session::config::{Externs, OutputType, OutputTypes, SymbolManglingVersion};
+use rustc_session::getopts;
 use rustc_session::lint::Level;
 use rustc_session::search_paths::SearchPath;
 use rustc_session::{build_session, Session};
diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
index fcaeaf2e4b0..f14fc9fc2eb 100644
--- a/src/librustc_llvm/build.rs
+++ b/src/librustc_llvm/build.rs
@@ -24,18 +24,28 @@ fn main() {
     build_helper::restore_library_path();
 
     let target = env::var("TARGET").expect("TARGET was not set");
-    let llvm_config = env::var_os("LLVM_CONFIG").map(PathBuf::from).unwrap_or_else(|| {
-        if let Some(dir) = env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
-            let to_test =
-                dir.parent().unwrap().parent().unwrap().join(&target).join("llvm/bin/llvm-config");
-            if Command::new(&to_test).output().is_ok() {
-                return to_test;
+    let llvm_config =
+        env::var_os("LLVM_CONFIG").map(|x| Some(PathBuf::from(x))).unwrap_or_else(|| {
+            if let Some(dir) = env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
+                let to_test = dir
+                    .parent()
+                    .unwrap()
+                    .parent()
+                    .unwrap()
+                    .join(&target)
+                    .join("llvm/bin/llvm-config");
+                if Command::new(&to_test).output().is_ok() {
+                    return Some(to_test);
+                }
             }
-        }
-        PathBuf::from("llvm-config")
-    });
+            None
+        });
+
+    if let Some(llvm_config) = &llvm_config {
+        println!("cargo:rerun-if-changed={}", llvm_config.display());
+    }
+    let llvm_config = llvm_config.unwrap_or_else(|| PathBuf::from("llvm-config"));
 
-    println!("cargo:rerun-if-changed={}", llvm_config.display());
     println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
 
     // Test whether we're cross-compiling LLVM. This is a pretty rare case
diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml
index a88ccd52e91..b03e884cdaf 100644
--- a/src/librustc_metadata/Cargo.toml
+++ b/src/librustc_metadata/Cargo.toml
@@ -11,6 +11,7 @@ doctest = false
 
 [dependencies]
 flate2 = "1.0"
+libc = "0.2"
 log = "0.4"
 memmap = "0.7"
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs
index 22a2bf28041..4659be8c195 100644
--- a/src/librustc_metadata/lib.rs
+++ b/src/librustc_metadata/lib.rs
@@ -10,7 +10,6 @@
 #![feature(stmt_expr_attributes)]
 #![recursion_limit = "256"]
 
-extern crate libc;
 extern crate proc_macro;
 
 #[macro_use]
diff --git a/src/librustc_session/Cargo.toml b/src/librustc_session/Cargo.toml
index 3895d0f8061..814073bb4f7 100644
--- a/src/librustc_session/Cargo.toml
+++ b/src/librustc_session/Cargo.toml
@@ -9,6 +9,7 @@ name = "rustc_session"
 path = "lib.rs"
 
 [dependencies]
+getopts = "0.2"
 log = "0.4"
 rustc_errors = { path = "../librustc_errors" }
 rustc_feature = { path = "../librustc_feature" }
diff --git a/src/librustc_session/lib.rs b/src/librustc_session/lib.rs
index cc4d525d628..2ff92c46d12 100644
--- a/src/librustc_session/lib.rs
+++ b/src/librustc_session/lib.rs
@@ -1,10 +1,4 @@
 #![feature(crate_visibility_modifier)]
-#![feature(test)]
-
-// Use the test crate here so we depend on getopts through it. This allow tools to link to both
-// librustc_session and libtest.
-extern crate getopts;
-extern crate test as _;
 
 pub mod cgu_reuse_tracker;
 pub mod utils;
@@ -23,3 +17,5 @@ mod session;
 pub use session::*;
 
 pub mod output;
+
+pub use getopts;
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 179c5bfacf3..a5a1e20396c 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -10,6 +10,7 @@ use rustc_session::config::{
     nightly_options,
 };
 use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs};
+use rustc_session::getopts;
 use rustc_session::lint::Level;
 use rustc_session::search_paths::SearchPath;
 use rustc_span::edition::{Edition, DEFAULT_EDITION};
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 99860a103d7..b0d5a8e58e1 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -15,7 +15,6 @@
 #![recursion_limit = "256"]
 
 extern crate env_logger;
-extern crate getopts;
 extern crate rustc_ast;
 extern crate rustc_ast_pretty;
 extern crate rustc_attr;
@@ -51,6 +50,7 @@ use std::panic;
 use std::process;
 
 use rustc_session::config::{make_crate_type_option, ErrorOutputType, RustcOptGroup};
+use rustc_session::getopts;
 use rustc_session::{early_error, early_warn};
 
 #[macro_use]
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml
index 3a83f3f569a..ceb39c01c67 100644
--- a/src/libstd/Cargo.toml
+++ b/src/libstd/Cargo.toml
@@ -47,7 +47,7 @@ hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] }
 wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }
 
 [features]
-default = ["std_detect_file_io", "std_detect_dlsym_getauxval"]
+default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"]
 
 backtrace = [
   "backtrace_rs/dbghelp",          # backtrace/symbolize on MSVC