Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[WIP] Upgrade to and test LLVM 6 #47681

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "src/llvm"]
path = src/llvm
url = https://github.com/rust-lang/llvm.git
url = https://github.com/alexcrichton/llvm.git
branch = master
[submodule "src/rt/hoedown"]
path = src/rt/hoedown
Expand Down
22 changes: 0 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,20 @@ matrix:

# Linux builders, remaining docker images
- env: IMAGE=arm-android
if: branch = auto
- env: IMAGE=armhf-gnu
if: branch = auto
- env: IMAGE=dist-various-1 DEPLOY=1
if: branch = auto
- env: IMAGE=dist-various-2 DEPLOY=1
if: branch = auto
- env: IMAGE=dist-aarch64-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-android DEPLOY=1
if: branch = auto
- env: IMAGE=dist-arm-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-armhf-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-armv7-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-i586-gnu-i586-i686-musl DEPLOY=1
if: branch = auto
- env: IMAGE=dist-i686-freebsd DEPLOY=1
if: branch = auto
- env: IMAGE=dist-i686-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-mips-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-mips64-linux DEPLOY=1
Expand All @@ -141,43 +132,30 @@ matrix:
- env: IMAGE=dist-mipsel-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-powerpc-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-powerpc64-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-powerpc64le-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-s390x-linux DEPLOY=1
if: branch = auto
- env: IMAGE=dist-x86_64-freebsd DEPLOY=1
if: branch = auto
- env: IMAGE=dist-x86_64-musl DEPLOY=1
if: branch = auto
- env: IMAGE=dist-x86_64-netbsd DEPLOY=1
if: branch = auto
- env: IMAGE=asmjs
if: branch = auto
- env: IMAGE=i686-gnu
if: branch = auto
- env: IMAGE=i686-gnu-nopt
if: branch = auto
- env: IMAGE=wasm32-unknown
if: branch = auto
- env: IMAGE=x86_64-gnu
if: branch = auto
- env: IMAGE=x86_64-gnu-full-bootstrap
if: branch = auto
- env: IMAGE=x86_64-gnu-aux
if: branch = auto
- env: IMAGE=x86_64-gnu-tools
if: branch = auto
- env: IMAGE=x86_64-gnu-debug
if: branch = auto
- env: IMAGE=x86_64-gnu-nopt
if: branch = auto
- env: IMAGE=x86_64-gnu-distcheck
if: branch = auto
- env: IMAGE=x86_64-gnu-incremental
if: branch = auto

- stage: publish toolstate
if: branch = master AND type = push
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Build {
initial_rustc: config.initial_rustc.clone(),
initial_cargo: config.initial_cargo.clone(),
local_rebuild: config.local_rebuild,
fail_fast: config.cmd.fail_fast(),
fail_fast: config.cmd.fail_fast() && false,
verbosity: config.verbose,

build: config.build,
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Step for Llvm {
// NOTE: remember to also update `config.toml.example` when changing the defaults!
let llvm_targets = match build.config.llvm_targets {
Some(ref s) => s,
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX;Hexagon",
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;MSP430;Sparc;NVPTX;Hexagon",
};

let llvm_exp_targets = &build.config.llvm_experimental_targets;
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-i686-freebsd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-x86_64-freebsd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
Expand Down
2 changes: 1 addition & 1 deletion src/dlmalloc
Submodule dlmalloc updated 1 files
+3 −10 src/wasm.rs
8 changes: 4 additions & 4 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ pub struct TargetOptions {
/// Relocation model to use in object file. Corresponds to `llc
/// -relocation-model=$relocation_model`. Defaults to "pic".
pub relocation_model: String,
/// Code model to use. Corresponds to `llc -code-model=$code_model`. Defaults to "default".
pub code_model: String,
/// Code model to use. Corresponds to `llc -code-model=$code_model`.
pub code_model: Option<String>,
/// TLS model to use. Options are "global-dynamic" (default), "local-dynamic", "initial-exec"
/// and "local-exec". This is similar to the -ftls-model option in GCC/Clang.
pub tls_model: String,
Expand Down Expand Up @@ -483,7 +483,7 @@ impl Default for TargetOptions {
only_cdylib: false,
executables: false,
relocation_model: "pic".to_string(),
code_model: "default".to_string(),
code_model: None,
tls_model: "global-dynamic".to_string(),
disable_redzone: false,
eliminate_frame_pointer: true,
Expand Down Expand Up @@ -736,7 +736,7 @@ impl Target {
key!(only_cdylib, bool);
key!(executables, bool);
key!(relocation_model);
key!(code_model);
key!(code_model, optional);
key!(tls_model);
key!(disable_redzone, bool);
key!(eliminate_frame_pointer, bool);
Expand Down
14 changes: 6 additions & 8 deletions src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,11 @@ pub enum RelocMode {
#[repr(C)]
pub enum CodeModel {
Other,
Default,
JITDefault,
Small,
Kernel,
Medium,
Large,
None,
}

/// LLVMRustDiagnosticKind
Expand All @@ -331,7 +330,6 @@ pub enum DiagnosticKind {
pub enum ArchiveKind {
Other,
K_GNU,
K_MIPS64,
K_BSD,
K_COFF,
}
Expand Down Expand Up @@ -1546,7 +1544,7 @@ extern "C" {
InlinedAt: MetadataRef)
-> ValueRef;
pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;

pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
Expand Down Expand Up @@ -1717,9 +1715,9 @@ extern "C" {
Identifier: *const c_char,
) -> ModuleRef;
pub fn LLVMGetModuleIdentifier(M: ModuleRef, size: *mut usize) -> *const c_char;
pub fn LLVMRustThinLTOGetDICompileUnit(M: ModuleRef,
CU1: *mut *mut c_void,
CU2: *mut *mut c_void);
pub fn LLVMRustThinLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
pub fn LLVMRustLTOGetDICompileUnit(M: ModuleRef,
CU1: *mut *mut c_void,
CU2: *mut *mut c_void);
pub fn LLVMRustLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
pub fn LLVMRustThinLTORemoveAvailableExternally(M: ModuleRef);
}
1 change: 0 additions & 1 deletion src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ impl FromStr for ArchiveKind {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"gnu" => Ok(ArchiveKind::K_GNU),
"mips64" => Ok(ArchiveKind::K_MIPS64),
"bsd" => Ok(ArchiveKind::K_BSD),
"coff" => Ok(ArchiveKind::K_COFF),
_ => Err(()),
Expand Down
24 changes: 20 additions & 4 deletions src/librustc_trans/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ fn fat_lto(cgcx: &CodegenContext,
let llmod = module.llvm().expect("can't lto pre-translated modules").llmod;
info!("using {:?} as a base module", module.llmod_id);

// See comments in ThinLTO for what this is doing
let mut cu1 = ptr::null_mut();
let mut cu2 = ptr::null_mut();
unsafe {
llvm::LLVMRustLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
if !cu2.is_null() {
let msg = format!("multiple source DICompileUnits found");
return Err(write::llvm_err(&diag_handler, msg))
}
}

// For all other modules we translated we'll need to link them into our own
// bitcode. All modules were translated in their own LLVM context, however,
// and we want to move everything to the same LLVM context. Currently the
Expand Down Expand Up @@ -265,14 +276,19 @@ fn fat_lto(cgcx: &CodegenContext,
}
cgcx.save_temp_bitcode(&module, "lto.input");

// Internalize everything that *isn't* in our whitelist to help strip out
// more modules and such
unsafe {
// Internalize everything that *isn't* in our whitelist to help strip
// out more modules and such
let ptr = symbol_white_list.as_ptr();
llvm::LLVMRustRunRestrictionPass(llmod,
ptr as *const *const libc::c_char,
symbol_white_list.len() as libc::size_t);
cgcx.save_temp_bitcode(&module, "lto.after-restriction");

// More documentation about this in ThinLTO below, but it suffices to
// say that this arises during normal LTO as well.
llvm::LLVMRustLTOPatchDICompileUnit(llmod, cu1);
cgcx.save_temp_bitcode(&module, "lto.after-patch");
}

if cgcx.no_landing_pads {
Expand Down Expand Up @@ -636,7 +652,7 @@ impl ThinModule {
// an error.
let mut cu1 = ptr::null_mut();
let mut cu2 = ptr::null_mut();
llvm::LLVMRustThinLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
llvm::LLVMRustLTOGetDICompileUnit(llmod, &mut cu1, &mut cu2);
if !cu2.is_null() {
let msg = format!("multiple source DICompileUnits found");
return Err(write::llvm_err(&diag_handler, msg))
Expand Down Expand Up @@ -712,7 +728,7 @@ impl ThinModule {
// not too much) but for now at least gets LLVM to emit valid DWARF (or
// so it appears). Hopefully we can remove this once upstream bugs are
// fixed in LLVM.
llvm::LLVMRustThinLTOPatchDICompileUnit(llmod, cu1);
llvm::LLVMRustLTOPatchDICompileUnit(llmod, cu1);
cgcx.save_temp_bitcode(&mtrans, "thin-lto-after-patch");
timeline.record("patch");

Expand Down
32 changes: 17 additions & 15 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ pub const RELOC_MODEL_ARGS : [(&'static str, llvm::RelocMode); 7] = [
("ropi-rwpi", llvm::RelocMode::ROPI_RWPI),
];

pub const CODE_GEN_MODEL_ARGS : [(&'static str, llvm::CodeModel); 5] = [
("default", llvm::CodeModel::Default),
pub const CODE_GEN_MODEL_ARGS: &[(&str, llvm::CodeModel)] = &[
("small", llvm::CodeModel::Small),
("kernel", llvm::CodeModel::Kernel),
("medium", llvm::CodeModel::Medium),
Expand Down Expand Up @@ -170,20 +169,23 @@ pub fn target_machine_factory(sess: &Session)
let ffunction_sections = sess.target.target.options.function_sections;
let fdata_sections = ffunction_sections;

let code_model_arg = match sess.opts.cg.code_model {
Some(ref s) => &s,
None => &sess.target.target.options.code_model,
};

let code_model = match CODE_GEN_MODEL_ARGS.iter().find(
|&&arg| arg.0 == code_model_arg) {
Some(x) => x.1,
_ => {
sess.err(&format!("{:?} is not a valid code model",
code_model_arg));
sess.abort_if_errors();
bug!();
let code_model_arg = sess.opts.cg.code_model.as_ref().or(
sess.target.target.options.code_model.as_ref(),
);

let code_model = match code_model_arg {
Some(s) => {
match CODE_GEN_MODEL_ARGS.iter().find(|arg| arg.0 == s) {
Some(x) => x.1,
_ => {
sess.err(&format!("{:?} is not a valid code model",
code_model_arg));
sess.abort_if_errors();
bug!();
}
}
}
None => llvm::CodeModel::None,
};

let singlethread = sess.target.target.options.singlethread;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,

let ops = unsafe {
[llvm::LLVMRustDIBuilderCreateOpDeref(),
llvm::LLVMRustDIBuilderCreateOpPlus(),
llvm::LLVMRustDIBuilderCreateOpPlusUconst(),
byte_offset_of_var_in_env as i64,
llvm::LLVMRustDIBuilderCreateOpDeref()]
};
Expand Down
2 changes: 1 addition & 1 deletion src/llvm
Submodule llvm updated 14811 files
19 changes: 13 additions & 6 deletions src/rustllvm/ArchiveWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ struct RustArchiveIterator {
enum class LLVMRustArchiveKind {
Other,
GNU,
MIPS64,
BSD,
COFF,
};
Expand All @@ -51,8 +50,6 @@ static Archive::Kind fromRust(LLVMRustArchiveKind Kind) {
switch (Kind) {
case LLVMRustArchiveKind::GNU:
return Archive::K_GNU;
case LLVMRustArchiveKind::MIPS64:
return Archive::K_MIPS64;
case LLVMRustArchiveKind::BSD:
return Archive::K_BSD;
case LLVMRustArchiveKind::COFF:
Expand Down Expand Up @@ -232,12 +229,22 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers,
LLVMRustSetLastError(toString(MOrErr.takeError()).c_str());
return LLVMRustResult::Failure;
}
#if LLVM_VERSION_GE(6, 0)
MOrErr->MemberName = sys::path::filename(MOrErr->MemberName);
#endif
Members.push_back(std::move(*MOrErr));
}
}
auto Pair = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false);
if (!Pair.second)
auto Result = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false);
#if LLVM_VERSION_GE(6, 0)
if (!Result)
return LLVMRustResult::Success;
LLVMRustSetLastError(toString(std::move(Result)).c_str());
#else
if (!Result.second)
return LLVMRustResult::Success;
LLVMRustSetLastError(Pair.second.message().c_str());
LLVMRustSetLastError(Result.second.message().c_str());
#endif

return LLVMRustResult::Failure;
}
Loading