aboutsummaryrefslogtreecommitdiffstats
path: root/testing/rust
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2017-04-08 23:53:16 +0200
committerJakub Jirutka <jakub@jirutka.cz>2017-04-09 15:41:28 +0200
commit60dcefecf12e7926c72ac932e8aaf1d1945341e5 (patch)
tree053144b2094fbaa999eccddc7b8bb25f5e445f01 /testing/rust
parent2da58e99823d6c81ca41dbc3d8334a47a10af5ea (diff)
downloadaports-60dcefecf12e7926c72ac932e8aaf1d1945341e5.tar.bz2
aports-60dcefecf12e7926c72ac932e8aaf1d1945341e5.tar.xz
testing/rust: add check for static/dynamic PIC
Diffstat (limited to 'testing/rust')
-rw-r--r--testing/rust/APKBUILD21
-rw-r--r--testing/rust/allow-crt-static-on-stable.patch9
-rwxr-xr-xtesting/rust/check-rustc88
3 files changed, 109 insertions, 9 deletions
diff --git a/testing/rust/APKBUILD b/testing/rust/APKBUILD
index 8f5ffd5e87..7655f2174a 100644
--- a/testing/rust/APKBUILD
+++ b/testing/rust/APKBUILD
@@ -37,8 +37,8 @@ source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz
move-py-scripts-to-share.patch
change-rpath-to-rustlib.patch
fix-jemalloc-musl.patch
+ check-rustc
"
-options="!check"
builddir="$srcdir/rustc-$pkgver-src"
_ctarget="$CARCH-unknown-linux-musl"
@@ -100,12 +100,14 @@ build() {
}
check() {
- cd "$builddir"
-
- make check \
- LD_LIBRARY_PATH="$_stage0dir/lib" \
- RUST_BACKTRACE=1 \
- VERBOSE=1
+ "$srcdir"/check-rustc "$builddir/build/$_ctarget/stage2/bin/rustc"
+
+# XXX: There's some problem with these tests, we will figure it out later.
+# cd "$builddir"
+# make check \
+# LD_LIBRARY_PATH="$_stage0dir/lib" \
+# RUST_BACKTRACE=1 \
+# VERBOSE=1
}
package() {
@@ -178,10 +180,11 @@ e9b10d58ae5b51b09dd31a1dbf7367917bd40a05ecb4ba3e0e7ac229a0352d3ceb77de80f7c0120f
4df33353b6be1af822220ca03f9ec5a3b6421c9b10ec17b864be586ba495c6210bac70d904b0e0b35eff62ef2c9a681ded526e5cbd37e326dc3146742aa659de cargo-6e0c18cccc8b0c06fba8a8d76486f81a792fb420-x86_64-unknown-linux-musl.tar.gz
2002faf08cca3be702f25618bc17453c5e76644a6ff6b0739b642c2c0f8536ec7f09c98182aff6b2dcc87c77b0929f2f8f732b8242a8f80d94b3824c8cd0d0fe dont-require-filecheck.patch
a87ffe129debcb9fa958c6d007ffa4a87927890030e0694ee5ab1929ea0c5a48dad86b4e8b71550dcfeda29b644dbb23d8b232bda62439f198a404cf658c68b0 support-dynamically-linked-musl.patch
-57ea7651bc0b0fa5340b9c5de0492ddc8bfaf4f1003298bf27dea57ee562cdd0f3947e091b154388535ce511e001e052f12d48805f7ffece7f04178ad409623f allow-crt-static-on-stable.patch
+7e2a282332d22d22a0d48da34cc9e83db7acbf38787bc3b18c49dd2cdc112ca76ebfa40e5b9629a80ae73632b4b0fea278b9ff4cdc56ddb7dd265958b509afab allow-crt-static-on-stable.patch
541aac679dfdbe5383f884e0493462dd33908308c7b294170b24339d6b9c1e723088c80764125116f24707a67eeeedadceaa9628ca6d2b8c7d0ca9253bf62135 static-pie.patch
f436fddf7ab70ca5f1424081f5b75450270b200b3d997231323863e11addf76e1d65831a7ca09e3a5b7904ce828766c1f70b08326a175890298f28e5bc8646ef fix-linux_musl_base.patch
37416e1fa0bc0c8651cd060a645d6245ff7e2082279ab5e13495c5ee412c71915469019cfbec95a0fd9a7fc144475079a3ad16f0eba7a2f5c8dd99e0002f3225 llvm-with-ffi.patch
19cc2725d68db3e359e0e3016028374e5818a97fdba24d0103f7d1706601c8b17c4dd95a3152e64f982f98e95ad3e949acddbea8a39ed0ba8dd4f702acc2704d move-py-scripts-to-share.patch
8d6206f8c50856724cf7b4c1854ec82547f040358a1c7d44abeacc27a5c205a963b1fec51e58ec06c68d85bd2f68a9e6e27ebe457f39e8dd043de17758f5063f change-rpath-to-rustlib.patch
-a330fa913faeadb98cb95e644f434ddef4fbbea32bcd11b6621fb9e08f7b0d8c71fae702207465489af3cf793eade0af694a8c515fc1bed49624da25103a4862 fix-jemalloc-musl.patch"
+a330fa913faeadb98cb95e644f434ddef4fbbea32bcd11b6621fb9e08f7b0d8c71fae702207465489af3cf793eade0af694a8c515fc1bed49624da25103a4862 fix-jemalloc-musl.patch
+770cf8d2d3d55647ba551ae98314af6b6c09e5994cfae0c2ef7ee05ccbf8efa05308887d61a017ab53dee18723db3a5177ce145e43af20326cf156dd2bd0e360 check-rustc"
diff --git a/testing/rust/allow-crt-static-on-stable.patch b/testing/rust/allow-crt-static-on-stable.patch
index c193c0c0ac..2646b3ef94 100644
--- a/testing/rust/allow-crt-static-on-stable.patch
+++ b/testing/rust/allow-crt-static-on-stable.patch
@@ -30,3 +30,12 @@ Build dynamically linked binary with rustc or cargo:
}
return crt_static;
+--- a/src/test/compile-fail/crt-static-gated.rs
++++ b/src/test/compile-fail/crt-static-gated.rs
+@@ -10,5 +10,6 @@
+
+ // compile-flags:-C target-feature=+crt-static
+ // error-pattern: specifying the `crt-static` target feature is only allowed
++// ignore-test we just want this feature and no one will stop us!
+
+ fn main() {}
diff --git a/testing/rust/check-rustc b/testing/rust/check-rustc
new file mode 100755
index 0000000000..015730dc0e
--- /dev/null
+++ b/testing/rust/check-rustc
@@ -0,0 +1,88 @@
+#!/bin/sh
+set -eu
+
+RUSTC="$1"
+TMPDIR="$(pwd)/.tmp-${0##*/}-$RANDOM"
+failed=0
+
+
+_rustc() {
+ printf '\n$ rustc %s\n' "$*"
+ "$RUSTC" "$@"
+}
+
+die() {
+ printf '\033[1;31mERROR:\033[0m %s\n' "$1" >&2 # bold red
+ exit 1
+}
+
+fail() {
+ printf '\033[1;31mFAIL:\033[0m %s\n' "$1" >&2 # bold red
+ failed=$(( failed + 1 ))
+}
+
+# Checks if the given file is a statically linked binary.
+is_static() {
+ ! readelf -l "$1" | grep -Fq INTERP \
+ && ! readelf -d "$1" | grep -Fq NEEDED
+}
+
+assert_dynamic() {
+ test -f "$1" && ! is_static "$1" || {
+ fail "$1 is not a dynamic executable!"
+ readelf -ld "$1"
+ }
+}
+
+assert_ok() {
+ "$1" || fail "$1 exited with status $?"
+}
+
+assert_pie() {
+ readelf -d "$1" | grep FLAGS_1 | grep -q PIE || {
+ fail "$1 is not a PIE executable!"
+ readelf -d "$1"
+ }
+}
+
+assert_static() {
+ test -f "$1" && is_static "$1" || {
+ fail "$1 is not a static executable!"
+ readelf -ld "$1"
+ }
+}
+
+
+#-------------------- M a i n --------------------
+
+test -d "$TMPDIR" && die "$TMPDIR already exists!"
+mkdir -p "$TMPDIR"
+trap "rm -R '$TMPDIR'" EXIT
+
+cd "$TMPDIR"
+
+cat >> hello_world.rs <<-EOF
+ fn main() {
+ println!("Hello, world!");
+ }
+EOF
+
+_rustc hello_world.rs
+assert_ok ./hello_world
+assert_static hello_world
+assert_pie hello_world
+rm -f hello_world
+
+_rustc -C target-feature=-crt-static hello_world.rs
+assert_ok ./hello_world
+assert_dynamic hello_world
+assert_pie hello_world
+rm -f hello_world
+
+_rustc -C target-feature=+crt-static hello_world.rs
+assert_ok ./hello_world
+assert_static hello_world
+assert_pie hello_world
+rm -f hello_world
+
+[ "$failed" -eq 0 ] || die "$failed assertion(s) has failed"