beta test, use LLVM 5 where available

This commit is contained in:
Josh Stone 2018-02-02 17:15:51 -08:00
parent 2581f83cc5
commit 9731a9fcfa
4 changed files with 196 additions and 3 deletions

View File

@ -0,0 +1,57 @@
From 327c3d06258576cc9d9f2e5c0861abc72ebd10ef Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 2 Feb 2018 16:23:04 -0800
Subject: [PATCH] Fix -Wcatch-value from GCC 8
These instances may simply be caught by reference instead.
---
src/tools/asm2wasm.cpp | 2 +-
src/tools/s2wasm.cpp | 2 +-
src/wasm/wasm-s-parser.cpp | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp
index 75a2c4d15e2e..6d14067d240f 100644
--- a/src/tools/asm2wasm.cpp
+++ b/src/tools/asm2wasm.cpp
@@ -87,7 +87,7 @@ int main(int argc, const char *argv[]) {
[&trapMode](Options *o, const std::string &argument) {
try {
trapMode = trapModeFromString(argument);
- } catch (std::invalid_argument e) {
+ } catch (std::invalid_argument &e) {
std::cerr << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
diff --git a/src/tools/s2wasm.cpp b/src/tools/s2wasm.cpp
index 32af57dba5bf..c5e1d52b8d96 100644
--- a/src/tools/s2wasm.cpp
+++ b/src/tools/s2wasm.cpp
@@ -92,7 +92,7 @@ int main(int argc, const char *argv[]) {
[&trapMode](Options *o, const std::string &argument) {
try {
trapMode = trapModeFromString(argument);
- } catch (std::invalid_argument e) {
+ } catch (std::invalid_argument &e) {
std::cerr << "Error: " << e.what() << "\n";
exit(EXIT_FAILURE);
}
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 0de3edf3f6b4..78a150f8146c 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -1408,9 +1408,9 @@ Name SExpressionWasmBuilder::getLabel(Element& s) {
uint64_t offset;
try {
offset = std::stoll(s.c_str(), nullptr, 0);
- } catch (std::invalid_argument) {
+ } catch (std::invalid_argument&) {
throw ParseException("invalid break offset");
- } catch (std::out_of_range) {
+ } catch (std::out_of_range&) {
throw ParseException("out of range break offset");
}
if (offset > nameMapper.labelStack.size()) throw ParseException("invalid label", s.line, s.col);
--
2.14.3

View File

@ -0,0 +1,53 @@
From 7eb7d45c0b0a9dc0454c5f3a3c5e911c7900bbea Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Tue, 23 Jan 2018 13:53:01 -0800
Subject: [PATCH] Let LLVM 5 add DW_OP_deref to indirect args itself
We needed to manually added the `DW_OP_deref` ourselves in earlier LLVM,
but starting with [D31439] in LLVM 5, it appears that LLVM will always
handle this itself. When we were still adding this manually, the
resulting `.debug_loc` had too many derefs, and this failed test
`debuginfo/by-value-self-argument-in-trait-impl.rs`.
[D31439]: https://reviews.llvm.org/D31439
Fixes #47611.
cc @alexcrichton
r? @michaelwoerister
---
src/librustc_trans/mir/mod.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs
index b367eb6548d0..da01592d9118 100644
--- a/src/librustc_trans/mir/mod.rs
+++ b/src/librustc_trans/mir/mod.rs
@@ -487,16 +487,18 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
// The Rust ABI passes indirect variables using a pointer and a manual copy, so we
// need to insert a deref here, but the C ABI uses a pointer and a copy using the
// byval attribute, for which LLVM does the deref itself, so we must not add it.
+ // Starting with D31439 in LLVM 5, it *always* does the deref itself.
let mut variable_access = VariableAccess::DirectVariable {
alloca: place.llval
};
-
- if let PassMode::Indirect(ref attrs) = arg.mode {
- if !attrs.contains(ArgAttribute::ByVal) {
- variable_access = VariableAccess::IndirectVariable {
- alloca: place.llval,
- address_operations: &deref_op,
- };
+ if unsafe { llvm::LLVMRustVersionMajor() < 5 } {
+ if let PassMode::Indirect(ref attrs) = arg.mode {
+ if !attrs.contains(ArgAttribute::ByVal) {
+ variable_access = VariableAccess::IndirectVariable {
+ alloca: place.llval,
+ address_operations: &deref_op,
+ };
+ }
}
}
--
2.14.3

View File

@ -0,0 +1,67 @@
From e2f6b280ea13e48bff86254549988e61eee37139 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 19 Jan 2018 21:43:53 -0800
Subject: [PATCH] Update DW_OP_plus to DW_OP_plus_uconst
LLVM <= 4.0 used a non-standard interpretation of `DW_OP_plus`. In the
DWARF standard, this adds two items on the expressions stack. LLVM's
behavior was more like DWARF's `DW_OP_plus_uconst` -- adding a constant
that follows the op. The patch series starting with [D33892] switched
to the standard DWARF interpretation, so we need to follow.
[D33892]: https://reviews.llvm.org/D33892
---
src/librustc_llvm/ffi.rs | 2 +-
src/librustc_trans/mir/mod.rs | 2 +-
src/rustllvm/RustWrapper.cpp | 9 ++++++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs
index b97e37f4c8fb..f51e51a88b10 100644
--- a/src/librustc_llvm/ffi.rs
+++ b/src/librustc_llvm/ffi.rs
@@ -1546,7 +1546,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);
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs
index 3064e2f7c7af..b367eb6548d0 100644
--- a/src/librustc_trans/mir/mod.rs
+++ b/src/librustc_trans/mir/mod.rs
@@ -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()]
};
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 95130d596e16..0fe533d447bc 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -866,7 +866,14 @@ extern "C" int64_t LLVMRustDIBuilderCreateOpDeref() {
return dwarf::DW_OP_deref;
}
-extern "C" int64_t LLVMRustDIBuilderCreateOpPlus() { return dwarf::DW_OP_plus; }
+extern "C" int64_t LLVMRustDIBuilderCreateOpPlusUconst() {
+#if LLVM_VERSION_GE(5, 0)
+ return dwarf::DW_OP_plus_uconst;
+#else
+ // older LLVM used `plus` to behave like `plus_uconst`.
+ return dwarf::DW_OP_plus;
+#endif
+}
extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Ty, RustStringRef Str) {
RawRustStringOstream OS(Str);
--
2.14.3

View File

@ -62,8 +62,18 @@ ExclusiveArch: %{rust_arches}
%endif
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
# https://github.com/rust-lang/rust/pull/47762
Patch1: rust-1.24.0-beta-prerelease.patch
# https://github.com/rust-lang/rust/pull/47610
Patch2: 0001-Update-DW_OP_plus-to-DW_OP_plus_uconst.patch
# https://github.com/rust-lang/rust/pull/47688
Patch3: 0001-Let-LLVM-5-add-DW_OP_deref-to-indirect-args-itself.patch
# https://github.com/WebAssembly/binaryen/pull/1400
Patch4: 0001-Fix-Wcatch-value-from-GCC-8.patch
# Get the Rust triple for any arch.
%{lua: function rust_triple(arch)
local abi = "gnu"
@ -128,8 +138,8 @@ BuildRequires: cmake >= 2.8.7
%if 0%{?epel}
%global llvm llvm3.9
%endif
%if 0%{?fedora} >= 27
%global llvm llvm4.0
%if 0%{?fedora} >= 28
%global llvm llvm5.0
%endif
%if %defined llvm
%global llvm_root %{_libdir}/%{llvm}
@ -285,6 +295,12 @@ test -f '%{local_rust_root}/bin/rustc'
%setup -q -n %{rustc_package}
%patch1 -p1 -b .beta-prerelease
%patch2 -p1 -b .DW_OP_plus_uconst
%patch3 -p1 -b .DW_OP_deref
pushd src/binaryen
%patch4 -p1 -b .catch-value
popd
# We're disabling jemalloc, but rust-src still wants it.
# rm -rf src/jemalloc/
@ -479,7 +495,7 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
%changelog
* Fri Feb 02 2018 Josh Stone <jistone@redhat.com> - 1.24.0-0.beta.8
- beta test
- beta test, use LLVM 5 where available
* Thu Feb 01 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.23.0-2
- Switch to %%ldconfig_scriptlets