Skip to content

Commit

Permalink
Auto merge of #47553 - alexcrichton:beta-next, r=alexcrichton
Browse files Browse the repository at this point in the history
[beta] Rollup + backports

This is a rollup of two PRs:

* #47546
* #47431

and a backport of two PRs:

* #47505
* #47220
  • Loading branch information
bors committed Jan 18, 2018
2 parents 597549e + cbfb985 commit 1262787
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 15 deletions.
8 changes: 6 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,15 @@ impl Build {
.arg("ls-remote")
.arg("origin")
.arg("beta")
.current_dir(&self.src)
);
let beta = beta.trim().split_whitespace().next().unwrap();
let master = output(
Command::new("git")
.arg("ls-remote")
.arg("origin")
.arg("master")
.current_dir(&self.src)
);
let master = master.trim().split_whitespace().next().unwrap();

Expand All @@ -802,7 +804,8 @@ impl Build {
Command::new("git")
.arg("merge-base")
.arg(beta)
.arg(master),
.arg(master)
.current_dir(&self.src),
);
let base = base.trim();

Expand All @@ -813,7 +816,8 @@ impl Build {
.arg("rev-list")
.arg("--count")
.arg("--merges")
.arg(format!("{}...HEAD", base)),
.arg(format!("{}...HEAD", base))
.current_dir(&self.src),
);
let n = count.trim().parse().unwrap();
self.prerelease_version.set(Some(n));
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"gather borrowck statistics"),
no_landing_pads: bool = (false, parse_bool, [TRACKED],
"omit landing pads for unwinding"),
fewer_names: bool = (false, parse_bool, [TRACKED],
"reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"),
debug_llvm: bool = (false, parse_bool, [UNTRACKED],
"enable debug output from LLVM"),
meta_stats: bool = (false, parse_bool, [UNTRACKED],
Expand Down Expand Up @@ -2813,6 +2815,10 @@ mod tests {
opts.debugging_opts.no_landing_pads = true;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
opts.debugging_opts.fewer_names = true;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
opts.debugging_opts.no_trans = true;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
Expand Down
9 changes: 8 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use lint;
use middle::allocator::AllocatorKind;
use middle::dependency_format;
use session::search_paths::PathKind;
use session::config::{BorrowckMode, DebugInfoLevel};
use session::config::{BorrowckMode, DebugInfoLevel, OutputType};
use ty::tls;
use util::nodemap::{FxHashMap, FxHashSet};
use util::common::{duration_to_secs_str, ErrorReported};
Expand Down Expand Up @@ -504,6 +504,13 @@ impl Session {
pub fn linker_flavor(&self) -> LinkerFlavor {
self.opts.debugging_opts.linker_flavor.unwrap_or(self.target.target.linker_flavor)
}

pub fn fewer_names(&self) -> bool {
let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly) ||
self.opts.output_types.contains_key(&OutputType::Bitcode);
self.opts.debugging_opts.fewer_names || !more_names
}

pub fn no_landing_pads(&self) -> bool {
self.opts.debugging_opts.no_landing_pads || self.panic_strategy() == PanicStrategy::Abort
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ pub enum ModuleBuffer {}
#[link(name = "rustllvm", kind = "static")]
extern "C" {
// Create and destroy contexts.
pub fn LLVMContextCreate() -> ContextRef;
pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> ContextRef;
pub fn LLVMContextDispose(C: ContextRef);
pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint;

Expand Down
13 changes: 7 additions & 6 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ pub fn get_linker(sess: &Session) -> (PathBuf, Command, Vec<(OsString, OsString)
// was tagged as #42791) and some more info can be found on #44443 for
// emscripten itself.
let cmd = |linker: &Path| {
if cfg!(windows) && linker.ends_with(".bat") {
let mut cmd = Command::new("cmd");
cmd.arg("/c").arg(linker);
cmd
} else {
Command::new(linker)
if let Some(linker) = linker.to_str() {
if cfg!(windows) && linker.ends_with(".bat") {
let mut cmd = Command::new("cmd");
cmd.arg("/c").arg(linker);
return cmd
}
}
Command::new(linker)
};

if let Some(ref linker) = sess.opts.cg.linker {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ impl ThinModule {
// into that context. One day, however, we may do this for upstream
// crates but for locally translated modules we may be able to reuse
// that LLVM Context and Module.
let llcx = llvm::LLVMContextCreate();
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
let llmod = llvm::LLVMRustParseBitcodeForThinLTO(
llcx,
self.data().as_ptr(),
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ pub struct CodegenContext {
pub thinlto: bool,
pub no_landing_pads: bool,
pub save_temps: bool,
pub fewer_names: bool,
pub exported_symbols: Arc<ExportedSymbols>,
pub opts: Arc<config::Options>,
pub crate_types: Vec<config::CrateType>,
Expand Down Expand Up @@ -1407,6 +1408,7 @@ fn start_executing_work(tcx: TyCtxt,
unsafe { llvm::LLVMRustThinLTOAvailable() },

no_landing_pads: sess.no_landing_pads(),
fewer_names: sess.fewer_names(),
save_temps: sess.opts.cg.save_temps,
opts: Arc::new(sess.opts.clone()),
time_passes: sess.time_passes(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub fn is_pie_binary(sess: &Session) -> bool {
}

pub unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextRef, ModuleRef) {
let llcx = llvm::LLVMContextCreate();
let llcx = llvm::LLVMRustContextCreate(sess.fewer_names());
let mod_name = CString::new(mod_name).unwrap();
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);

Expand Down
8 changes: 7 additions & 1 deletion src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ extern "C" char *LLVMRustGetLastError(void) {
return Ret;
}

void LLVMRustSetLastError(const char *Err) {
extern "C" void LLVMRustSetLastError(const char *Err) {
free((void *)LastError);
LastError = strdup(Err);
}

extern "C" LLVMContextRef LLVMRustContextCreate(bool shouldDiscardNames) {
auto ctx = new LLVMContext();
ctx->setDiscardValueNames(shouldDiscardNames);
return wrap(ctx);
}

extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M,
const char *Triple) {
unwrap(M)->setTargetTriple(Triple::normalize(Triple));
Expand Down
2 changes: 1 addition & 1 deletion src/rustllvm/rustllvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/Linker/Linker.h"

void LLVMRustSetLastError(const char *);
extern "C" void LLVMRustSetLastError(const char *);

enum class LLVMRustResult { Success, Failure };

Expand Down
2 changes: 1 addition & 1 deletion src/tools/cargo

0 comments on commit 1262787

Please sign in to comment.