Skip to content

Commit

Permalink
rust: update to 1.32.0.
Browse files Browse the repository at this point in the history
* Add support for all ppc64 targets.
* Use bundled LLVM instead of system wide LLVM. Rust statically
  links against LLVM anyway and we can avoid some bugs this way
  (such as Rust failing to compile Firefox, see
  rust-lang/rust#57762

Co-authored-by: q66 <daniel@octaforge.org>

[ci skip]
  • Loading branch information
Rasmus Thomsen committed Jan 24, 2019
1 parent 4f7fe5b commit 6dbcf3a
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 29 deletions.
58 changes: 58 additions & 0 deletions srcpkgs/rust/files/patches/internal-llvm/llvm-001-musl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
From: Andrea Brancaleoni <miwaxe@gmail.com>
Date: Tue, 8 Sep 2015 22:03:02 +0200
Subject: [PATCH 3/3] musl

---
include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
lib/Support/DynamicLibrary.cpp | 2 +-
lib/Support/Unix/Signals.inc | 6 +++---
utils/unittest/googletest/src/gtest.cc | 1 +
5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
index e0a1ee3..465b65a 100644
--- a/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/include/llvm/Analysis/TargetLibraryInfo.h
@@ -18,6 +18,15 @@
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"

+#undef fopen64
+#undef fseeko64
+#undef fstat64
+#undef fstatvfs64
+#undef ftello64
+#undef lstat64
+#undef stat64
+#undef tmpfile64
+
namespace llvm {
/// VecDesc - Describes a possible vectorization of a function.
/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
index 5780764..1d548c1 100644
--- a/utils/unittest/googletest/src/gtest.cc
+++ b/utils/unittest/googletest/src/gtest.cc
@@ -120,6 +120,7 @@

#if GTEST_CAN_STREAM_RESULTS_
# include <arpa/inet.h> // NOLINT
+# include <sys/socket.h> // NOLINT
# include <netdb.h> // NOLINT
#endif

--
2.5.1

--- llvm-5.0.0.src/lib/Support/Unix/DynamicLibrary.inc.orig
+++ llvm-5.0.0.src/lib/Support/Unix/DynamicLibrary.inc
@@ -103,7 +103,7 @@

// This macro returns the address of a well-known, explicit symbol
#define EXPLICIT_SYMBOL(SYM) \
- if (!strcmp(SymbolName, #SYM)) return &SYM
+ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM

// Under glibc we have a weird situation. The stderr/out/in symbols are both
// macros and global variables because of standards requirements. So, we
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 750d323a6060ad92c3d247f85d6555041f55b4a5 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Thu, 4 Oct 2018 15:26:59 -0500
Subject: [PATCH] Add support for powerpc64-*-linux-musl targets

This patch ensures that 64-bit PowerPC musl targets use ELFv2 ABI on both
endians. It additionally adds a test that big endian PPC64 uses ELFv2 on
musl.
---
lib/Target/PowerPC/PPCTargetMachine.cpp | 4 ++++
test/CodeGen/PowerPC/ppc64-elf-abi.ll | 1 +
2 files changed, 5 insertions(+)

diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
index 34410393ef6..c583fba8cab 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -199,6 +199,10 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
case Triple::ppc64le:
return PPCTargetMachine::PPC_ABI_ELFv2;
case Triple::ppc64:
+ // musl uses ELFv2 ABI on both endians.
+ if (TT.getEnvironment() == Triple::Musl)
+ return PPCTargetMachine::PPC_ABI_ELFv2;
+
return PPCTargetMachine::PPC_ABI_ELFv1;
default:
return PPCTargetMachine::PPC_ABI_UNKNOWN;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 1c95f5a34c14f08d65cdd198827e3a2fcb63cf39 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tom@tromey.com>
Date: Tue, 22 Jan 2019 11:13:53 -0700
Subject: [PATCH] Fix issue 57762

Issue 57762 points out a compiler crash when the compiler was built
using a stock LLVM 7. LLVM 7 was released without a necessary fix for
a bug in the DWARF discriminant code.

This patch changes rustc to use the fallback mode on (non-Rust) LLVM 7.

Closes #57762
---
src/librustc_codegen_llvm/debuginfo/metadata.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 6deedd0b5ea3..a354eef6887a 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -1164,7 +1164,11 @@ fn use_enum_fallback(cx: &CodegenCx) -> bool {
// On MSVC we have to use the fallback mode, because LLVM doesn't
// lower variant parts to PDB.
return cx.sess().target.target.options.is_like_msvc
- || llvm_util::get_major_version() < 7;
+ || llvm_util::get_major_version() < 7
+ // LLVM version 7 did not release with an important bug fix;
+ // but the required patch is in the equivalent Rust LLVM.
+ // See /~https://github.com/rust-lang/rust/issues/57762.
+ || (llvm_util::get_major_version() == 7 && unsafe { !llvm::LLVMRustIsRustLLVM() });
}

// Describes the members of an enum value: An enum is described as a union of
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 1c95f5a34c14f08d65cdd198827e3a2fcb63cf39 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tom@tromey.com>
Date: Tue, 22 Jan 2019 11:13:53 -0700
Subject: [PATCH] Fix issue 57762

Issue 57762 points out a compiler crash when the compiler was built
using a stock LLVM 7. LLVM 7 was released without a necessary fix for
a bug in the DWARF discriminant code.

This patch changes rustc to use the fallback mode on (non-Rust) LLVM 7.

Closes #57762
---
src/librustc_codegen_llvm/debuginfo/metadata.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 6deedd0b5ea3..a354eef6887a 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -1164,7 +1164,11 @@ fn use_enum_fallback(cx: &CodegenCx) -> bool {
// On MSVC we have to use the fallback mode, because LLVM doesn't
// lower variant parts to PDB.
return cx.sess().target.target.options.is_like_msvc
- || llvm_util::get_major_version() < 7;
+ || llvm_util::get_major_version() < 7
+ // LLVM version 7 did not release with an important bug fix;
+ // but the required patch is in the equivalent Rust LLVM.
+ // See /~https://github.com/rust-lang/rust/issues/57762.
+ || (llvm_util::get_major_version() == 7 && unsafe { !llvm::LLVMRustIsRustLLVM() });
}

// Describes the members of an enum value: An enum is described as a union of
105 changes: 76 additions & 29 deletions srcpkgs/rust/template
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# Template file for 'rust'
pkgname=rust
version=1.31.1
version=1.32.0
revision=1
_rust_dist_version=1.31.0
_rust_dist_version=1.32.0
_cargo_dist_version=0.32.0
# NB. if you push any(!) new version, don't forget to put a build
# output of musl to https://alpha.de.repo.voidlinux.org/distfiles/
wrksrc="rustc-${version}-src"
lib32disabled=yes
patch_args="-Np1"
build_style=configure
# unset LDFLAGS, otherwise cross builds to the same arch will fail
make_build_args="dist VERBOSE=1"
hostmakedepends="cmake curl pkg-config python"
makedepends="libffi-devel llvm ncurses-devel libxml2-devel zlib-devel"
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel
$(vopt_if internal_llvm python-devel llvm)"
depends="rust-std"
short_desc="Safe, concurrent, practical systems language"
maintainer="Enno Boland <gottox@voidlinux.org>"
homepage="https://www.rust-lang.org/"
license="MIT, Apache-2.0"
homepage="https://www.rust-lang.org/"
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
checksum=91d2fc22f08d986adab7a54eb3a6a9b99e490f677d2d092e5b9e4e069c23686a
checksum=4c594c7712a0e7e8eae6526c464bf6ea1d82f77b4f61717c3fc28fb27ba2224a
lib32disabled=yes
patch_args="-Np1"

build_options="internal_llvm"

if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo llvm"
hostmakedepends+=" cargo $(vopt_if internal_llvm '' llvm)"

# These are required for building the buildhost's stage0/1
hostmakedepends+=" libffi-devel libxml2-devel
Expand All @@ -36,8 +40,8 @@ else
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
checksum+="
7ca7360b9243b7117bbb5281b563fdf2bfae61d223ad858199aabc438c828926
b5cadf379e82905459dea5359c7111b30cfbba33a17b6960e3beb72ce79b7db9
1fa1c8b4b976919e229c8f3ca070ed2235e6f1cecf4967041ef0b8a29a75d517
bfc82c04c46a58ae09be1f32a11a11000830c257969afbf2a270e6eb36d6533a
4dfb1cca7730b38920c04731be0e9d47ec520b3365059b4ccd9c0948346787ea"
;;
x86_64)
Expand All @@ -47,8 +51,8 @@ else
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
checksum+="
5c4581f0fc05f0f5076db6231b0c1a4d27eb61c0b36bfb42d97243ad8f4e43a0
fe67a62c7a63acbf2458a36d7689ef41903187a472f0c28850f1fca7ea478da8
75c31f32e19548c1608611d08b82b87560e02f15caac7b2663a8189a4609977c
9f2705a3ed3217c13fd55569406c52f590030752f57520312e135223ae930caf
7e46150e431eaafef9439c9cd958aa8d980a0a70f0bb052473f0a75023930dcc"
;;
i686)
Expand All @@ -58,23 +62,71 @@ else
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
checksum+="
549116e23dce8687f69327f5ea2c717c93175d24d82d456fab37160f800f8ce8
14de38321f6f2c64496e77bac793ad5511d37696b9c33283bb6f395dc590c4d9
45e633c985c259a13d3b096662241bd8255a86ed4917e0fec396e7071c04c734
69bd6064f605c1d0d7d41070efea1e329d75755b04fbc5a13ffc53efdc3a97c7
200cf76636ccbb153d5c430a5c0f3ad5af206899f76470e3cd046679a5a4ab3f"
;;
ppc64le)
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
https://void-ppc64.octaforge.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
checksum+="
e41bce347e11e9c4868fec2892778e51ed8f3383bd6ee59dd991376c1dea56a9
b281c20115467429573da6b2b5b7a8863f29e203d7919989e71d91e6914d3bbe
bf426e52beb08e0f663b00b23a89053e713ec15c8e6d69b3f5ae85fe23ad7e18"
;;
ppc64le-musl)
distfiles+="
https://void-ppc64.octaforge.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
https://void-ppc64.octaforge.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
https://void-ppc64.octaforge.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
checksum+="
bacb713d86be555af4410d685aab475ac63ad66e358f6b00c058253fba275187
24b6b79356c7bf113ad34f43c14a7a6cec92b9008b05ab58624ce7a353b0e6d0
d9d91997a781753474e89dbb9b7dbbef2f6cfad9387def076d51d654f6bc21fa"
;;
ppc64-musl)
distfiles+="
https://void-ppc64.octaforge.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
https://void-ppc64.octaforge.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
https://void-ppc64.octaforge.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
checksum+="
fd090e1329687c1b8e3320b40f0b13640444f93cbb7c235d8491c140337c27df
791d046ecb3203d90263cddb5f53eafdeb042a55923fea35bbb8db223c892603
ec846d1e9674f60dbd4416d54f74a618288114cea4907b61363adc71b3c8c26f"
;;
esac
fi

# In rust terminology 'build' is the build host ($CBUILD) and `target`
# and `host` are the triplets that are supposed to run the built binaries
# ($CTARGET)
case $XBPS_MACHINE in
ppc64le) _build_triplet=powerpc64le-unknown-linux-gnu;;
ppc64le-musl) _build_triplet=powerpc64le-unknown-linux-musl;;
ppc64-musl) _build_triplet=powerpc64-unknown-linux-musl;;
*-musl) _build_triplet=${XBPS_MACHINE%-musl}-unknown-linux-musl;;
*) _build_triplet=${XBPS_MACHINE}-unknown-linux-gnu;;
esac

post_extract() {
rm -rf src/llvm
if [ "$build_option_internal_llvm" ]; then
# patches for Rust's bundled LLVM
pushd src/llvm
for x in ${FILESDIR}/patches/internal_llvm/llvm-*.patch; do
msg_normal "Applying $x to llvm\n"
patch -sNp1 -i ${x}
done
popd
else
rm -rf src/llvm
# patches for system LLVM
for x in ${FILESDIR}/patches/sys-llvm/*.patch; do
msg_normal "Applying patch $x\n"
patch -sNp1 -i ${x}
done
fi

if [ -z "$CROSS_BUILD" ]; then
mkdir -p stage0
Expand All @@ -83,7 +135,7 @@ post_extract() {
rm ../rust-std-*/rust-std-*/manifest.in
cp -bflr ../rust-std-*/rust-std-*/* stage0
case "$XBPS_MACHINE" in
*-musl) cp -bflr ../cargo stage0/bin;;
*-musl|ppc64*) cp -bflr ../cargo stage0/bin;;
*)
rm ../cargo-*/cargo/manifest.in
cp -flr ../cargo-*/cargo/* stage0
Expand All @@ -107,14 +159,15 @@ do_configure() {
--disable-rpath
--disable-docs
--disable-codegen-tests
--llvm-root=/usr
--set=target.${_build_triplet}.llvm-config=/usr/bin/llvm-config
"

# Disable jemalloc for now. It increases the size of small programs
# significantly (hello world without jemalloc 130KB vs with jemalloc
# 300KB) and provides worse performance in some cases.
configure_args+=" --disable-jemalloc"
if ! [ "$build_option_internal_llvm" ]; then
configure_args+="
--llvm-root=/usr
--set=target.${_build_triplet}.llvm-config=/usr/bin/llvm-config
--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
"
fi

if [ "$CROSS_BUILD" ]; then
configure_args+="
Expand All @@ -129,12 +182,6 @@ do_configure() {
--set=target.${_build_triplet}.ar=${AR_host}
--set=target.${_build_triplet}.linker=${CC_host}
"

# Set 'llvm-config' for the cross target (host) so that we don't build
# LLVM for it again.
configure_args+="
--set=target.${RUST_TARGET}.llvm-config="/usr/bin/llvm-config"
"
else
configure_args+=" --local-rust-root=$wrksrc/stage0"
fi
Expand All @@ -161,7 +208,7 @@ pre_build() {
# for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
# of the cross host.
do_build() {
env CFLAGS_${_build_triplet}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
env CFLAGS_${_build_triplet}="${CFLAGS_host}" LDFLAGS='' make ${makejobs} ${make_build_args}
}

do_install() {
Expand Down

0 comments on commit 6dbcf3a

Please sign in to comment.