Skip to content

Commit c49e2d0

Browse files
author
Rasmus Thomsen
committed
rust: update to 1.32.0.
* 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 <[email protected]> [ci skip]
1 parent 4f7fe5b commit c49e2d0

7 files changed

+228
-29
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
From faca3fbd15d0c3108493c3c54cd93138e049ac43 Mon Sep 17 00:00:00 2001
2+
From: Andrea Brancaleoni <[email protected]>
3+
Date: Tue, 8 Sep 2015 22:03:02 +0200
4+
Subject: [PATCH 3/3] musl
5+
6+
---
7+
include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++
8+
lib/Support/DynamicLibrary.cpp | 2 +-
9+
lib/Support/Unix/Signals.inc | 6 +++---
10+
utils/unittest/googletest/src/gtest.cc | 1 +
11+
5 files changed, 17 insertions(+), 6 deletions(-)
12+
13+
diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h
14+
index e0a1ee3..465b65a 100644
15+
--- a/include/llvm/Analysis/TargetLibraryInfo.h
16+
+++ b/include/llvm/Analysis/TargetLibraryInfo.h
17+
@@ -18,6 +18,15 @@
18+
#include "llvm/IR/Module.h"
19+
#include "llvm/Pass.h"
20+
21+
+#undef fopen64
22+
+#undef fseeko64
23+
+#undef fstat64
24+
+#undef fstatvfs64
25+
+#undef ftello64
26+
+#undef lstat64
27+
+#undef stat64
28+
+#undef tmpfile64
29+
+
30+
namespace llvm {
31+
/// VecDesc - Describes a possible vectorization of a function.
32+
/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
33+
diff --git a/utils/unittest/googletest/src/gtest.cc b/utils/unittest/googletest/src/gtest.cc
34+
index 5780764..1d548c1 100644
35+
--- a/utils/unittest/googletest/src/gtest.cc
36+
+++ b/utils/unittest/googletest/src/gtest.cc
37+
@@ -120,6 +120,7 @@
38+
39+
#if GTEST_CAN_STREAM_RESULTS_
40+
# include <arpa/inet.h> // NOLINT
41+
+# include <sys/socket.h> // NOLINT
42+
# include <netdb.h> // NOLINT
43+
#endif
44+
45+
--
46+
2.5.1
47+
48+
--- llvm-5.0.0.src/lib/Support/Unix/DynamicLibrary.inc.orig
49+
+++ llvm-5.0.0.src/lib/Support/Unix/DynamicLibrary.inc
50+
@@ -103,7 +103,7 @@
51+
52+
// This macro returns the address of a well-known, explicit symbol
53+
#define EXPLICIT_SYMBOL(SYM) \
54+
- if (!strcmp(SymbolName, #SYM)) return &SYM
55+
+ if (!strcmp(SymbolName, #SYM)) return (void *)&SYM
56+
57+
// Under glibc we have a weird situation. The stderr/out/in symbols are both
58+
// macros and global variables because of standards requirements. So, we
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 750d323a6060ad92c3d247f85d6555041f55b4a5 Mon Sep 17 00:00:00 2001
2+
From: "A. Wilcox" <[email protected]>
3+
Date: Thu, 4 Oct 2018 15:26:59 -0500
4+
Subject: [PATCH] Add support for powerpc64-*-linux-musl targets
5+
6+
This patch ensures that 64-bit PowerPC musl targets use ELFv2 ABI on both
7+
endians. It additionally adds a test that big endian PPC64 uses ELFv2 on
8+
musl.
9+
---
10+
lib/Target/PowerPC/PPCTargetMachine.cpp | 4 ++++
11+
test/CodeGen/PowerPC/ppc64-elf-abi.ll | 1 +
12+
2 files changed, 5 insertions(+)
13+
14+
diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
15+
index 34410393ef6..c583fba8cab 100644
16+
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
17+
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
18+
@@ -199,6 +199,10 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
19+
case Triple::ppc64le:
20+
return PPCTargetMachine::PPC_ABI_ELFv2;
21+
case Triple::ppc64:
22+
+ // musl uses ELFv2 ABI on both endians.
23+
+ if (TT.getEnvironment() == Triple::Musl)
24+
+ return PPCTargetMachine::PPC_ABI_ELFv2;
25+
+
26+
return PPCTargetMachine::PPC_ABI_ELFv1;
27+
default:
28+
return PPCTargetMachine::PPC_ABI_UNKNOWN;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 1c95f5a34c14f08d65cdd198827e3a2fcb63cf39 Mon Sep 17 00:00:00 2001
2+
From: Tom Tromey <[email protected]>
3+
Date: Tue, 22 Jan 2019 11:13:53 -0700
4+
Subject: [PATCH] Fix issue 57762
5+
6+
Issue 57762 points out a compiler crash when the compiler was built
7+
using a stock LLVM 7. LLVM 7 was released without a necessary fix for
8+
a bug in the DWARF discriminant code.
9+
10+
This patch changes rustc to use the fallback mode on (non-Rust) LLVM 7.
11+
12+
Closes #57762
13+
---
14+
src/librustc_codegen_llvm/debuginfo/metadata.rs | 6 +++++-
15+
1 file changed, 5 insertions(+), 1 deletion(-)
16+
17+
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
18+
index 6deedd0b5ea3..a354eef6887a 100644
19+
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
20+
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
21+
@@ -1164,7 +1164,11 @@ fn use_enum_fallback(cx: &CodegenCx) -> bool {
22+
// On MSVC we have to use the fallback mode, because LLVM doesn't
23+
// lower variant parts to PDB.
24+
return cx.sess().target.target.options.is_like_msvc
25+
- || llvm_util::get_major_version() < 7;
26+
+ || llvm_util::get_major_version() < 7
27+
+ // LLVM version 7 did not release with an important bug fix;
28+
+ // but the required patch is in the equivalent Rust LLVM.
29+
+ // See https://github.com/rust-lang/rust/issues/57762.
30+
+ || (llvm_util::get_major_version() == 7 && unsafe { !llvm::LLVMRustIsRustLLVM() });
31+
}
32+
33+
// Describes the members of an enum value: An enum is described as a union of
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 1c95f5a34c14f08d65cdd198827e3a2fcb63cf39 Mon Sep 17 00:00:00 2001
2+
From: Tom Tromey <[email protected]>
3+
Date: Tue, 22 Jan 2019 11:13:53 -0700
4+
Subject: [PATCH] Fix issue 57762
5+
6+
Issue 57762 points out a compiler crash when the compiler was built
7+
using a stock LLVM 7. LLVM 7 was released without a necessary fix for
8+
a bug in the DWARF discriminant code.
9+
10+
This patch changes rustc to use the fallback mode on (non-Rust) LLVM 7.
11+
12+
Closes #57762
13+
---
14+
src/librustc_codegen_llvm/debuginfo/metadata.rs | 6 +++++-
15+
1 file changed, 5 insertions(+), 1 deletion(-)
16+
17+
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
18+
index 6deedd0b5ea3..a354eef6887a 100644
19+
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
20+
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
21+
@@ -1164,7 +1164,11 @@ fn use_enum_fallback(cx: &CodegenCx) -> bool {
22+
// On MSVC we have to use the fallback mode, because LLVM doesn't
23+
// lower variant parts to PDB.
24+
return cx.sess().target.target.options.is_like_msvc
25+
- || llvm_util::get_major_version() < 7;
26+
+ || llvm_util::get_major_version() < 7
27+
+ // LLVM version 7 did not release with an important bug fix;
28+
+ // but the required patch is in the equivalent Rust LLVM.
29+
+ // See https://github.com/rust-lang/rust/issues/57762.
30+
+ || (llvm_util::get_major_version() == 7 && unsafe { !llvm::LLVMRustIsRustLLVM() });
31+
}
32+
33+
// Describes the members of an enum value: An enum is described as a union of

srcpkgs/rust/template

Lines changed: 76 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
# Template file for 'rust'
22
pkgname=rust
3-
version=1.31.1
3+
version=1.32.0
44
revision=1
5-
_rust_dist_version=1.31.0
5+
_rust_dist_version=1.32.0
66
_cargo_dist_version=0.32.0
77
# NB. if you push any(!) new version, don't forget to put a build
88
# output of musl to https://alpha.de.repo.voidlinux.org/distfiles/
99
wrksrc="rustc-${version}-src"
10-
lib32disabled=yes
11-
patch_args="-Np1"
1210
build_style=configure
11+
# unset LDFLAGS, otherwise cross builds to the same arch will fail
1312
make_build_args="dist VERBOSE=1"
1413
hostmakedepends="cmake curl pkg-config python"
15-
makedepends="libffi-devel llvm ncurses-devel libxml2-devel zlib-devel"
14+
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel
15+
$(vopt_if internal_llvm python-devel llvm)"
1616
depends="rust-std"
1717
short_desc="Safe, concurrent, practical systems language"
1818
maintainer="Enno Boland <[email protected]>"
19-
homepage="https://www.rust-lang.org/"
2019
license="MIT, Apache-2.0"
20+
homepage="https://www.rust-lang.org/"
2121
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
22-
checksum=91d2fc22f08d986adab7a54eb3a6a9b99e490f677d2d092e5b9e4e069c23686a
22+
checksum=4c594c7712a0e7e8eae6526c464bf6ea1d82f77b4f61717c3fc28fb27ba2224a
23+
lib32disabled=yes
24+
patch_args="-Np1"
25+
26+
build_options="internal_llvm"
2327

2428
if [ "$CROSS_BUILD" ]; then
25-
hostmakedepends+=" cargo llvm"
29+
hostmakedepends+=" cargo $(vopt_if internal_llvm '' llvm)"
2630

2731
# These are required for building the buildhost's stage0/1
2832
hostmakedepends+=" libffi-devel libxml2-devel
@@ -36,8 +40,8 @@ else
3640
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
3741
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
3842
checksum+="
39-
7ca7360b9243b7117bbb5281b563fdf2bfae61d223ad858199aabc438c828926
40-
b5cadf379e82905459dea5359c7111b30cfbba33a17b6960e3beb72ce79b7db9
43+
1fa1c8b4b976919e229c8f3ca070ed2235e6f1cecf4967041ef0b8a29a75d517
44+
bfc82c04c46a58ae09be1f32a11a11000830c257969afbf2a270e6eb36d6533a
4145
4dfb1cca7730b38920c04731be0e9d47ec520b3365059b4ccd9c0948346787ea"
4246
;;
4347
x86_64)
@@ -47,8 +51,8 @@ else
4751
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
4852
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
4953
checksum+="
50-
5c4581f0fc05f0f5076db6231b0c1a4d27eb61c0b36bfb42d97243ad8f4e43a0
51-
fe67a62c7a63acbf2458a36d7689ef41903187a472f0c28850f1fca7ea478da8
54+
75c31f32e19548c1608611d08b82b87560e02f15caac7b2663a8189a4609977c
55+
9f2705a3ed3217c13fd55569406c52f590030752f57520312e135223ae930caf
5256
7e46150e431eaafef9439c9cd958aa8d980a0a70f0bb052473f0a75023930dcc"
5357
;;
5458
i686)
@@ -58,23 +62,71 @@ else
5862
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
5963
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
6064
checksum+="
61-
549116e23dce8687f69327f5ea2c717c93175d24d82d456fab37160f800f8ce8
62-
14de38321f6f2c64496e77bac793ad5511d37696b9c33283bb6f395dc590c4d9
65+
45e633c985c259a13d3b096662241bd8255a86ed4917e0fec396e7071c04c734
66+
69bd6064f605c1d0d7d41070efea1e329d75755b04fbc5a13ffc53efdc3a97c7
6367
200cf76636ccbb153d5c430a5c0f3ad5af206899f76470e3cd046679a5a4ab3f"
6468
;;
69+
ppc64le)
70+
distfiles+="
71+
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
72+
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
73+
https://void-ppc64.octaforge.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
74+
checksum+="
75+
e41bce347e11e9c4868fec2892778e51ed8f3383bd6ee59dd991376c1dea56a9
76+
b281c20115467429573da6b2b5b7a8863f29e203d7919989e71d91e6914d3bbe
77+
bf426e52beb08e0f663b00b23a89053e713ec15c8e6d69b3f5ae85fe23ad7e18"
78+
;;
79+
ppc64le-musl)
80+
distfiles+="
81+
https://void-ppc64.octaforge.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
82+
https://void-ppc64.octaforge.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
83+
https://void-ppc64.octaforge.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
84+
checksum+="
85+
bacb713d86be555af4410d685aab475ac63ad66e358f6b00c058253fba275187
86+
24b6b79356c7bf113ad34f43c14a7a6cec92b9008b05ab58624ce7a353b0e6d0
87+
d9d91997a781753474e89dbb9b7dbbef2f6cfad9387def076d51d654f6bc21fa"
88+
;;
89+
ppc64-musl)
90+
distfiles+="
91+
https://void-ppc64.octaforge.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
92+
https://void-ppc64.octaforge.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
93+
https://void-ppc64.octaforge.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
94+
checksum+="
95+
fd090e1329687c1b8e3320b40f0b13640444f93cbb7c235d8491c140337c27df
96+
791d046ecb3203d90263cddb5f53eafdeb042a55923fea35bbb8db223c892603
97+
ec846d1e9674f60dbd4416d54f74a618288114cea4907b61363adc71b3c8c26f"
98+
;;
6599
esac
66100
fi
67101

68102
# In rust terminology 'build' is the build host ($CBUILD) and `target`
69103
# and `host` are the triplets that are supposed to run the built binaries
70104
# ($CTARGET)
71105
case $XBPS_MACHINE in
106+
ppc64le) _build_triplet=powerpc64le-unknown-linux-gnu;;
107+
ppc64le-musl) _build_triplet=powerpc64le-unknown-linux-musl;;
108+
ppc64-musl) _build_triplet=powerpc64-unknown-linux-musl;;
72109
*-musl) _build_triplet=${XBPS_MACHINE%-musl}-unknown-linux-musl;;
73110
*) _build_triplet=${XBPS_MACHINE}-unknown-linux-gnu;;
74111
esac
75112

76113
post_extract() {
77-
rm -rf src/llvm
114+
if [ "$build_option_internal_llvm" ]; then
115+
# patches for Rust's bundled LLVM
116+
pushd src/llvm
117+
for x in ${FILESDIR}/patches/internal_llvm/llvm-*.patch; do
118+
msg_normal "Applying $x to llvm\n"
119+
patch -sNp1 -i ${x}
120+
done
121+
popd
122+
else
123+
rm -rf src/llvm
124+
# patches for system LLVM
125+
for x in ${FILESDIR}/patches/sys-llvm/*.patch; do
126+
msg_normal "Applying patch $x\n"
127+
patch -sNp1 -i ${x}
128+
done
129+
fi
78130

79131
if [ -z "$CROSS_BUILD" ]; then
80132
mkdir -p stage0
@@ -83,7 +135,7 @@ post_extract() {
83135
rm ../rust-std-*/rust-std-*/manifest.in
84136
cp -bflr ../rust-std-*/rust-std-*/* stage0
85137
case "$XBPS_MACHINE" in
86-
*-musl) cp -bflr ../cargo stage0/bin;;
138+
*-musl|ppc64*) cp -bflr ../cargo stage0/bin;;
87139
*)
88140
rm ../cargo-*/cargo/manifest.in
89141
cp -flr ../cargo-*/cargo/* stage0
@@ -107,14 +159,15 @@ do_configure() {
107159
--disable-rpath
108160
--disable-docs
109161
--disable-codegen-tests
110-
--llvm-root=/usr
111-
--set=target.${_build_triplet}.llvm-config=/usr/bin/llvm-config
112162
"
113163

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

119172
if [ "$CROSS_BUILD" ]; then
120173
configure_args+="
@@ -129,12 +182,6 @@ do_configure() {
129182
--set=target.${_build_triplet}.ar=${AR_host}
130183
--set=target.${_build_triplet}.linker=${CC_host}
131184
"
132-
133-
# Set 'llvm-config' for the cross target (host) so that we don't build
134-
# LLVM for it again.
135-
configure_args+="
136-
--set=target.${RUST_TARGET}.llvm-config="/usr/bin/llvm-config"
137-
"
138185
else
139186
configure_args+=" --local-rust-root=$wrksrc/stage0"
140187
fi
@@ -161,7 +208,7 @@ pre_build() {
161208
# for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
162209
# of the cross host.
163210
do_build() {
164-
env CFLAGS_${_build_triplet}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
211+
env CFLAGS_${_build_triplet}="${CFLAGS_host}" LDFLAGS='' make ${makejobs} ${make_build_args}
165212
}
166213

167214
do_install() {

0 commit comments

Comments
 (0)