beta test

Add a clippy-preview subpackage
This commit is contained in:
Josh Stone 2018-08-16 16:35:30 -07:00
parent a55bbef495
commit fe90904f28
7 changed files with 541 additions and 84 deletions

View File

@ -0,0 +1,186 @@
From 4b95b1a4fd035a73998dc21b265ce4594e35f8ae Mon Sep 17 00:00:00 2001
From: Alex Crichton <alex@alexcrichton.com>
Date: Thu, 16 Aug 2018 13:19:04 -0700
Subject: [PATCH] Set more llvm function attributes for __rust_try
This shim is generated elsewhere in the compiler so this commit adds support to
ensure it goes through similar paths as the rest of the compiler to set llvm
function attributes like target features.
cc #53372
---
src/librustc_codegen_llvm/attributes.rs | 52 +++++++++++++++++++------
src/librustc_codegen_llvm/base.rs | 21 ----------
src/librustc_codegen_llvm/callee.rs | 2 +-
src/librustc_codegen_llvm/intrinsic.rs | 2 +
src/librustc_codegen_llvm/mono_item.rs | 2 +-
5 files changed, 44 insertions(+), 35 deletions(-)
diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs
index 3b5f927d52f0..2a79ce2f2285 100644
--- a/src/librustc_codegen_llvm/attributes.rs
+++ b/src/librustc_codegen_llvm/attributes.rs
@@ -11,7 +11,7 @@
use std::ffi::{CStr, CString};
-use rustc::hir::CodegenFnAttrFlags;
+use rustc::hir::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::session::Session;
use rustc::session::config::Sanitizer;
@@ -123,11 +123,37 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
/// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
/// attributes.
-pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) {
- let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(id);
+pub fn from_fn_attrs(
+ cx: &CodegenCx,
+ llfn: ValueRef,
+ id: Option<DefId>,
+) {
+ let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id))
+ .unwrap_or(CodegenFnAttrs::new());
inline(llfn, codegen_fn_attrs.inline);
+ // The `uwtable` attribute according to LLVM is:
+ //
+ // This attribute indicates that the ABI being targeted requires that an
+ // unwind table entry be produced for this function even if we can show
+ // that no exceptions passes by it. This is normally the case for the
+ // ELF x86-64 abi, but it can be disabled for some compilation units.
+ //
+ // Typically when we're compiling with `-C panic=abort` (which implies this
+ // `no_landing_pads` check) we don't need `uwtable` because we can't
+ // generate any exceptions! On Windows, however, exceptions include other
+ // events such as illegal instructions, segfaults, etc. This means that on
+ // Windows we end up still needing the `uwtable` attribute even if the `-C
+ // panic=abort` flag is passed.
+ //
+ // You can also find more info on why Windows is whitelisted here in:
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
+ if !cx.sess().no_landing_pads() ||
+ cx.sess().target.target.options.requires_uwtable {
+ attributes::emit_uwtable(llfn, true);
+ }
+
set_frame_pointer_elimination(cx, llfn);
set_probestack(cx, llfn);
@@ -151,7 +177,7 @@ pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) {
// *in Rust code* may unwind. Foreign items like `extern "C" {
// fn foo(); }` are assumed not to unwind **unless** they have
// a `#[unwind]` attribute.
- } else if !cx.tcx.is_foreign_item(id) {
+ } else if id.map(|id| !cx.tcx.is_foreign_item(id)).unwrap_or(false) {
Some(true)
} else {
None
@@ -188,14 +214,16 @@ pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) {
// Note that currently the `wasm-import-module` doesn't do anything, but
// eventually LLVM 7 should read this and ferry the appropriate import
// module to the output file.
- if cx.tcx.sess.target.target.arch == "wasm32" {
- if let Some(module) = wasm_import_module(cx.tcx, id) {
- llvm::AddFunctionAttrStringValue(
- llfn,
- llvm::AttributePlace::Function,
- cstr("wasm-import-module\0"),
- &module,
- );
+ if let Some(id) = id {
+ if cx.tcx.sess.target.target.arch == "wasm32" {
+ if let Some(module) = wasm_import_module(cx.tcx, id) {
+ llvm::AddFunctionAttrStringValue(
+ llfn,
+ llvm::AttributePlace::Function,
+ cstr("wasm-import-module\0"),
+ &module,
+ );
+ }
}
}
}
diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs
index 223c04f420f3..b0461582ddcb 100644
--- a/src/librustc_codegen_llvm/base.rs
+++ b/src/librustc_codegen_llvm/base.rs
@@ -486,27 +486,6 @@ pub fn codegen_instance<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, instance: Instance<'
cx.stats.borrow_mut().n_closures += 1;
- // The `uwtable` attribute according to LLVM is:
- //
- // This attribute indicates that the ABI being targeted requires that an
- // unwind table entry be produced for this function even if we can show
- // that no exceptions passes by it. This is normally the case for the
- // ELF x86-64 abi, but it can be disabled for some compilation units.
- //
- // Typically when we're compiling with `-C panic=abort` (which implies this
- // `no_landing_pads` check) we don't need `uwtable` because we can't
- // generate any exceptions! On Windows, however, exceptions include other
- // events such as illegal instructions, segfaults, etc. This means that on
- // Windows we end up still needing the `uwtable` attribute even if the `-C
- // panic=abort` flag is passed.
- //
- // You can also find more info on why Windows is whitelisted here in:
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
- if !cx.sess().no_landing_pads() ||
- cx.sess().target.target.options.requires_uwtable {
- attributes::emit_uwtable(lldecl, true);
- }
-
let mir = cx.tcx.instance_mir(instance.def);
mir::codegen_mir(cx, lldecl, &mir, instance, sig);
}
diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs
index 2c01bd42cc77..97f07792ede8 100644
--- a/src/librustc_codegen_llvm/callee.rs
+++ b/src/librustc_codegen_llvm/callee.rs
@@ -97,7 +97,7 @@ pub fn get_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
if instance.def.is_inline(tcx) {
attributes::inline(llfn, attributes::InlineAttr::Hint);
}
- attributes::from_fn_attrs(cx, llfn, instance.def.def_id());
+ attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()));
let instance_def_id = instance.def_id();
diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs
index 9c5c0f730c16..f69fce15dc55 100644
--- a/src/librustc_codegen_llvm/intrinsic.rs
+++ b/src/librustc_codegen_llvm/intrinsic.rs
@@ -10,6 +10,7 @@
#![allow(non_upper_case_globals)]
+use attributes;
use intrinsics::{self, Intrinsic};
use llvm;
use llvm::{ValueRef};
@@ -936,6 +937,7 @@ fn gen_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
Abi::Rust
)));
let llfn = declare::define_internal_fn(cx, name, rust_fn_ty);
+ attributes::from_fn_attrs(cx, llfn, None);
let bx = Builder::new_block(cx, llfn, "entry-block");
codegen(bx);
llfn
diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs
index a528008e3b4b..32d8b24e3c15 100644
--- a/src/librustc_codegen_llvm/mono_item.rs
+++ b/src/librustc_codegen_llvm/mono_item.rs
@@ -183,7 +183,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
if instance.def.is_inline(cx.tcx) {
attributes::inline(lldecl, attributes::InlineAttr::Hint);
}
- attributes::from_fn_attrs(cx, lldecl, instance.def.def_id());
+ attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id()));
cx.instances.borrow_mut().insert(instance, lldecl);
}
--
2.17.1

View File

@ -0,0 +1,36 @@
From 8af0dbaf90a3ce7cdbc96552f31f8aec45cc3084 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Tue, 14 Aug 2018 17:17:58 -0700
Subject: [PATCH] backtrace-sys: Use target_pointer_width for
BACKTRACE_ELF_SIZE
The former code used `target.contains("64")` to detect Elf64 targets,
but this is inaccurate in a few cases:
- `s390x-unknown-linux-gnu` is 64-bit
- `sparcv9-sun-solaris` is 64-bit
- `x86_64-unknown-linux-gnux32` is 32-bit
Instead the build script can use `CARGO_CFG_TARGET_POINTER_WIDTH` to
reliably detect 64-bit targets.
---
backtrace-sys/build.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/backtrace-sys/build.rs b/backtrace-sys/build.rs
index a423aade4116..10486d1f850c 100644
--- a/backtrace-sys/build.rs
+++ b/backtrace-sys/build.rs
@@ -40,7 +40,8 @@ fn main() {
build.flag("-fvisibility=hidden");
build.file("src/libbacktrace/elf.c");
- if target.contains("64") {
+ let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
+ if pointer_width == "64" {
build.define("BACKTRACE_ELF_SIZE", "64");
} else {
build.define("BACKTRACE_ELF_SIZE", "32");
--
2.17.1

View File

@ -0,0 +1,74 @@
From 763e72110a913c7aab396a0f687e2ebd3c9e572a Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Thu, 9 Aug 2018 16:35:25 -0700
Subject: [PATCH] rustc_codegen_llvm: Restore the closure env alloca hack for
LLVM 5.
This hack was removed in #50949, but without it I found that building
`std` with full debuginfo would print many LLVM `DW_OP_LLVM_fragment`
errors, then die `LLVM ERROR: Failed to strip malformed debug info`.
It doesn't seem to be a problem for LLVM 6, so we can re-enable the hack
just for older LLVM.
This reverts commit da579ef75e4a8ca11fb98b24a0a3ea0c7ccffeeb.
Fixes #53204.
r? @eddyb
---
src/librustc_codegen_llvm/mir/mod.rs | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs
index 8fdb67f5930c..8bb049be3054 100644
--- a/src/librustc_codegen_llvm/mir/mod.rs
+++ b/src/librustc_codegen_llvm/mir/mod.rs
@@ -574,6 +574,25 @@ fn arg_local_refs(
};
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
+ // Store the pointer to closure data in an alloca for debuginfo
+ // because that's what the llvm.dbg.declare intrinsic expects.
+
+ // FIXME(eddyb) this shouldn't be necessary but SROA seems to
+ // mishandle DW_OP_plus not preceded by DW_OP_deref, i.e. it
+ // doesn't actually strip the offset when splitting the closure
+ // environment into its components so it ends up out of bounds.
+ // (cuviper) It seems to be fine without the alloca on LLVM 6 and later.
+ let env_alloca = !env_ref && unsafe { llvm::LLVMRustVersionMajor() < 6 };
+ let env_ptr = if env_alloca {
+ let scratch = PlaceRef::alloca(bx,
+ bx.cx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
+ "__debuginfo_env_ptr");
+ bx.store(place.llval, scratch.llval, scratch.align);
+ scratch.llval
+ } else {
+ place.llval
+ };
+
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
@@ -585,7 +604,10 @@ fn arg_local_refs(
};
// The environment and the capture can each be indirect.
- let mut ops = if env_ref { &ops[..] } else { &ops[1..] };
+
+ // FIXME(eddyb) see above why we sometimes have to keep
+ // a pointer in an alloca for debuginfo atm.
+ let mut ops = if env_ref || env_alloca { &ops[..] } else { &ops[1..] };
let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
ty
@@ -595,7 +617,7 @@ fn arg_local_refs(
};
let variable_access = VariableAccess::IndirectVariable {
- alloca: place.llval,
+ alloca: env_ptr,
address_operations: &ops
};
declare_local(
--
2.17.1

View File

@ -0,0 +1,37 @@
From e0d8364dadd404a37bc344ef089926745cfdbe20 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Tue, 14 Aug 2018 21:08:42 -0700
Subject: [PATCH] std: Use target_pointer_width for BACKTRACE_ELF_SIZE
The former code used `target.contains("64")` to detect Elf64 targets,
but this is inaccurate in a few cases:
- `s390x-unknown-linux-gnu` is 64-bit
- `sparcv9-sun-solaris` is 64-bit
- `x86_64-unknown-linux-gnux32` is 32-bit
Instead the `std` build script can use `CARGO_CFG_TARGET_POINTER_WIDTH`
to reliably detect 64-bit targets for libbacktrace.
Also update to backtrace-sys 0.1.24 for alexcrichton/backtrace-rs#122.
---
src/libstd/build.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/libstd/build.rs b/src/libstd/build.rs
index 26d93f97e69f..016e7adb4c91 100644
--- a/src/libstd/build.rs
+++ b/src/libstd/build.rs
@@ -104,7 +104,8 @@ fn build_libbacktrace(target: &str) -> Result<(), ()> {
} else {
build.file("../libbacktrace/elf.c");
- if target.contains("64") {
+ let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
+ if pointer_width == "64" {
build.define("BACKTRACE_ELF_SIZE", "64");
} else {
build.define("BACKTRACE_ELF_SIZE", "32");
--
2.17.1

View File

@ -0,0 +1,122 @@
From f4e8d57b6ad6f599de54c020ba185db83cb011a3 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Thu, 16 Aug 2018 11:26:27 -0700
Subject: [PATCH] std: stop backtracing when the frames are full
---
src/libstd/sys/cloudabi/backtrace.rs | 18 ++++++++++--------
src/libstd/sys/redox/backtrace/tracing.rs | 18 ++++++++++--------
src/libstd/sys/unix/backtrace/tracing/gcc_s.rs | 18 ++++++++++--------
3 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/src/libstd/sys/cloudabi/backtrace.rs b/src/libstd/sys/cloudabi/backtrace.rs
index 1b970187558c..2c43b5937ce5 100644
--- a/src/libstd/sys/cloudabi/backtrace.rs
+++ b/src/libstd/sys/cloudabi/backtrace.rs
@@ -64,6 +64,10 @@ extern "C" fn trace_fn(
arg: *mut libc::c_void,
) -> uw::_Unwind_Reason_Code {
let cx = unsafe { &mut *(arg as *mut Context) };
+ if cx.idx >= cx.frames.len() {
+ return uw::_URC_NORMAL_STOP;
+ }
+
let mut ip_before_insn = 0;
let mut ip = unsafe { uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void };
if !ip.is_null() && ip_before_insn == 0 {
@@ -73,14 +77,12 @@ extern "C" fn trace_fn(
}
let symaddr = unsafe { uw::_Unwind_FindEnclosingFunction(ip) };
- if cx.idx < cx.frames.len() {
- cx.frames[cx.idx] = Frame {
- symbol_addr: symaddr as *mut u8,
- exact_position: ip as *mut u8,
- inline_context: 0,
- };
- cx.idx += 1;
- }
+ cx.frames[cx.idx] = Frame {
+ symbol_addr: symaddr as *mut u8,
+ exact_position: ip as *mut u8,
+ inline_context: 0,
+ };
+ cx.idx += 1;
uw::_URC_NO_REASON
}
diff --git a/src/libstd/sys/redox/backtrace/tracing.rs b/src/libstd/sys/redox/backtrace/tracing.rs
index bb70ca360370..c0414b78f8d6 100644
--- a/src/libstd/sys/redox/backtrace/tracing.rs
+++ b/src/libstd/sys/redox/backtrace/tracing.rs
@@ -68,6 +68,10 @@ pub fn unwind_backtrace(frames: &mut [Frame])
extern fn trace_fn(ctx: *mut uw::_Unwind_Context,
arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code {
let cx = unsafe { &mut *(arg as *mut Context) };
+ if cx.idx >= cx.frames.len() {
+ return uw::_URC_NORMAL_STOP;
+ }
+
let mut ip_before_insn = 0;
let mut ip = unsafe {
uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void
@@ -94,14 +98,12 @@ extern fn trace_fn(ctx: *mut uw::_Unwind_Context,
unsafe { uw::_Unwind_FindEnclosingFunction(ip) }
};
- if cx.idx < cx.frames.len() {
- cx.frames[cx.idx] = Frame {
- symbol_addr: symaddr as *mut u8,
- exact_position: ip as *mut u8,
- inline_context: 0,
- };
- cx.idx += 1;
- }
+ cx.frames[cx.idx] = Frame {
+ symbol_addr: symaddr as *mut u8,
+ exact_position: ip as *mut u8,
+ inline_context: 0,
+ };
+ cx.idx += 1;
uw::_URC_NO_REASON
}
diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
index 1b92fc0e6ad0..6e8415686792 100644
--- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
+++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
@@ -68,6 +68,10 @@ pub fn unwind_backtrace(frames: &mut [Frame])
extern fn trace_fn(ctx: *mut uw::_Unwind_Context,
arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code {
let cx = unsafe { &mut *(arg as *mut Context) };
+ if cx.idx >= cx.frames.len() {
+ return uw::_URC_NORMAL_STOP;
+ }
+
let mut ip_before_insn = 0;
let mut ip = unsafe {
uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void
@@ -94,14 +98,12 @@ extern fn trace_fn(ctx: *mut uw::_Unwind_Context,
unsafe { uw::_Unwind_FindEnclosingFunction(ip) }
};
- if cx.idx < cx.frames.len() {
- cx.frames[cx.idx] = Frame {
- symbol_addr: symaddr as *mut u8,
- exact_position: ip as *mut u8,
- inline_context: 0,
- };
- cx.idx += 1;
- }
+ cx.frames[cx.idx] = Frame {
+ symbol_addr: symaddr as *mut u8,
+ exact_position: ip as *mut u8,
+ inline_context: 0,
+ };
+ cx.idx += 1;
uw::_URC_NO_REASON
}
--
2.17.1

View File

@ -1,62 +0,0 @@
From efa11da26a882aaf57f7eae747e48d128c474bf3 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Thu, 26 Jul 2018 17:20:02 -0700
Subject: [PATCH] rustc_metadata: test loading atoi instead of cos
Some platforms don't actually have `libm` already linked in the test
infrastructure, and then `dynamic_lib::tests::test_loading_cosine` would
fail to find the "cos" symbol. Every platform running this test should
have `libc` and "atoi" though, so try to use that symbol instead.
Fixes #45410.
---
src/librustc_metadata/dynamic_lib.rs | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs
index d7da0d00012e..182a071277ec 100644
--- a/src/librustc_metadata/dynamic_lib.rs
+++ b/src/librustc_metadata/dynamic_lib.rs
@@ -90,30 +90,29 @@ mod tests {
use std::mem;
#[test]
- fn test_loading_cosine() {
+ fn test_loading_atoi() {
if cfg!(windows) {
return
}
- // The math library does not need to be loaded since it is already
- // statically linked in
- let libm = match DynamicLibrary::open(None) {
+ // The C library does not need to be loaded since it is already linked in
+ let lib = match DynamicLibrary::open(None) {
Err(error) => panic!("Could not load self as module: {}", error),
- Ok(libm) => libm
+ Ok(lib) => lib
};
- let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
- match libm.symbol("cos") {
- Err(error) => panic!("Could not load function cos: {}", error),
- Ok(cosine) => mem::transmute::<*mut u8, _>(cosine)
+ let atoi: extern fn(*const libc::c_char) -> libc::c_int = unsafe {
+ match lib.symbol("atoi") {
+ Err(error) => panic!("Could not load function atoi: {}", error),
+ Ok(atoi) => mem::transmute::<*mut u8, _>(atoi)
}
};
- let argument = 0.0;
- let expected_result = 1.0;
- let result = cosine(argument);
+ let argument = CString::new("1383428980").unwrap();
+ let expected_result = 0x52757374;
+ let result = atoi(argument.as_ptr());
if result != expected_result {
- panic!("cos({}) != {} but equaled {} instead", argument,
+ panic!("atoi({:?}) != {} but equaled {} instead", argument,
expected_result, result)
}
}

108
rust.spec
View File

@ -9,10 +9,10 @@
# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
# or nightly wants some beta-YYYY-MM-DD
# Note that cargo matches the program version here, not its crate version.
%global bootstrap_rust 1.27.2
%global bootstrap_cargo 1.27.0
%global bootstrap_rust 1.28.0
%global bootstrap_cargo 1.28.0
%global bootstrap_channel %{bootstrap_rust}
%global bootstrap_date 2018-07-20
%global bootstrap_date 2018-08-02
# Only the specified arches will use bootstrap binaries.
#global bootstrap_arches %%{rust_arches}
@ -21,7 +21,7 @@
%bcond_with llvm_static
# We can also choose to just use Rust's bundled LLVM, in case the system LLVM
# is insufficient. Rust currently requires LLVM 3.9+.
# is insufficient. Rust currently requires LLVM 5.0+.
%if 0%{?rhel} && !0%{?epel}
%bcond_without bundled_llvm
%else
@ -34,6 +34,12 @@
# So, tread carefully if you toggle this...
%bcond_without bundled_libgit2
%if 0%{?rhel}
%bcond_without bundled_libssh2
%else
%bcond_with bundled_libssh2
%endif
# LLDB only works on some architectures
%ifarch %{arm} aarch64 %{ix86} x86_64
# LLDB isn't available everywhere...
@ -49,14 +55,15 @@
# Some sub-packages are versioned independently of the rust compiler and runtime itself.
# Also beware that if any of these are not changed in a version bump, then the release
# number should still increase, not be reset to 1!
%global rustc_version 1.28.0
%global cargo_version 1.28.0
%global rustfmt_version 0.8.2
%global rls_version 0.128.0
%global rustc_version 1.29.0
%global cargo_version 1.29.0
%global rustfmt_version 0.99.1
%global rls_version 0.130.0
%global clippy_version 0.0.212
Name: rust
Version: %{rustc_version}
Release: 3%{?dist}
Release: 0.1.beta.4%{?dist}
Summary: The Rust Programming Language
License: (ASL 2.0 or MIT) and (BSD and MIT)
# ^ written as: (rust itself) and (bundled libraries)
@ -70,11 +77,22 @@ ExclusiveArch: %{rust_arches}
%endif
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
# https://github.com/rust-lang/rust/pull/52760
Patch1: rust-52760-test_loading_atoi.patch
# https://github.com/rust-lang/rust/pull/52876
Patch2: rust-52876-const-endianess.patch
Patch1: rust-52876-const-endianess.patch
# https://github.com/rust-lang/rust/pull/53239
Patch2: 0001-rustc_codegen_llvm-Restore-the-closure-env-alloca-ha.patch
# https://github.com/alexcrichton/backtrace-rs/pull/122
# https://github.com/rust-lang/rust/pull/53377
Patch3: 0001-backtrace-sys-Use-target_pointer_width-for-BACKTRACE.patch
Patch4: 0001-std-Use-target_pointer_width-for-BACKTRACE_ELF_SIZE.patch
# https://github.com/rust-lang/rust/pull/53436
Patch5: 0001-std-stop-backtracing-when-the-frames-are-full.patch
# https://github.com/rust-lang/rust/pull/53437
Patch6: 0001-Set-more-llvm-function-attributes-for-__rust_try.patch
# Get the Rust triple for any arch.
%{lua: function rust_triple(arch)
@ -135,10 +153,18 @@ BuildRequires: ncurses-devel
BuildRequires: curl
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(liblzma)
BuildRequires: pkgconfig(libssh2)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(zlib)
%if %without bundled_libgit2
BuildRequires: pkgconfig(libgit2) >= 0.27
%endif
%if %without bundled_libssh2
# needs libssh2_userauth_publickey_frommemory
BuildRequires: pkgconfig(libssh2) >= 1.6.0
%endif
%if 0%{?rhel} && 0%{?rhel} <= 7
%global python python2
%else
@ -148,22 +174,19 @@ BuildRequires: %{python}
%if %with bundled_llvm
BuildRequires: cmake3 >= 3.4.3
Provides: bundled(llvm) = 6.0
Provides: bundled(llvm) = 7.0
%else
BuildRequires: cmake >= 2.8.11
%if 0%{?epel}
%global llvm llvm5.0
%endif
%if 0%{?fedora} >= 29
%global llvm llvm6.0
%endif
%if %defined llvm
%global llvm_root %{_libdir}/%{llvm}
%else
%global llvm llvm
%global llvm_root %{_prefix}
%endif
BuildRequires: %{llvm}-devel >= 3.9
BuildRequires: %{llvm}-devel >= 5.0
%if %with llvm_static
BuildRequires: %{llvm}-static
BuildRequires: libffi-devel
@ -193,7 +216,7 @@ Requires: %{name}-std-static%{?_isa} = %{rustc_version}-%{release}
Requires: /usr/bin/cc
# ALL Rust libraries are private, because they don't keep an ABI.
%global _privatelibs lib(.*-[[:xdigit:]]*|rustc.*)[.]so.*
%global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.*
%global __provides_exclude ^(%{_privatelibs})$
%global __requires_exclude ^(%{_privatelibs})$
%global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$
@ -289,8 +312,9 @@ Summary: Rust's package manager and build tool
Version: %{cargo_version}
%if %with bundled_libgit2
Provides: bundled(libgit2) = 0.27
%else
BuildRequires: pkgconfig(libgit2) >= 0.27
%endif
%if %with bundled_libssh2
Provides: bundled(libssh2) = 1.8.1
%endif
# For tests:
BuildRequires: git
@ -335,6 +359,9 @@ Provides: rls = %{rls_version}
%if %with bundled_libgit2
Provides: bundled(libgit2) = 0.27
%endif
%if %with bundled_libssh2
Provides: bundled(libssh2) = 1.8.1
%endif
Requires: rust-analysis
# /usr/bin/rls is dynamically linked against internal rustc libs
Requires: %{name}%{?_isa} = %{rustc_version}-%{release}
@ -346,6 +373,19 @@ It supports functionality such as 'goto definition', symbol search,
reformatting, and code completion, and enables renaming and refactorings.
%package -n clippy-preview
Summary: Lints to catch common mistakes and improve your Rust code
Version: %{clippy_version}
License: MPLv2.0
Provides: clippy = %{clippy_version}
Requires: cargo
# /usr/bin/clippy-driver is dynamically linked against internal rustc libs
Requires: %{name}%{?_isa} = %{rustc_version}-%{release}
%description -n clippy-preview
A collection of lints to catch common mistakes and improve your Rust code.
%package src
Summary: Sources for the Rust standard library
BuildArch: noarch
@ -379,6 +419,12 @@ test -f '%{local_rust_root}/bin/rustc'
%patch1 -p1
%patch2 -p1
pushd src/vendor/backtrace-sys
%patch3 -p2
popd
%patch4 -p1
%patch5 -p1
%patch6 -p1
%if "%{python}" == "python3"
sed -i.try-py3 -e '/try python2.7/i try python3 "$@"' ./configure
@ -430,6 +476,11 @@ find src/vendor -name .cargo-checksum.json \
export LIBGIT2_SYS_USE_PKG_CONFIG=1
%endif
%if %without bundled_libssh2
# convince libssh2-sys to use the distro libssh2
export LIBSSH2_SYS_USE_PKG_CONFIG=1
%endif
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
%{?library_path:export LIBRARY_PATH="%{library_path}"}
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
@ -506,6 +557,7 @@ find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+'
# Remove unwanted documentation files (we already package them)
rm -f %{buildroot}%{_docdir}/%{name}/README.md
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY
@ -554,6 +606,7 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
# The results are not stable on koji, so mask errors and just log it.
%{python} ./x.py test --no-fail-fast || :
%{python} ./x.py test --no-fail-fast cargo || :
%{python} ./x.py test --no-fail-fast clippy || :
%{python} ./x.py test --no-fail-fast rls || :
%{python} ./x.py test --no-fail-fast rustfmt || :
@ -643,6 +696,13 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
%license src/tools/rls/LICENSE-{APACHE,MIT}
%files -n clippy-preview
%{_bindir}/cargo-clippy
%{_bindir}/clippy-driver
%doc src/tools/clippy/{README.md,CHANGELOG.md}
%license src/tools/clippy/LICENSE
%files src
%dir %{rustlibdir}
%{rustlibdir}/src
@ -653,6 +713,10 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
%changelog
* Thu Aug 16 2018 Josh Stone <jistone@redhat.com> - 1.29.0-0.1.beta.4
- beta test
- Add a clippy-preview subpackage
* Mon Aug 13 2018 Josh Stone <jistone@redhat.com> - 1.28.0-3
- Use llvm6.0 instead of llvm-7 for now