From 7d74c0993c044e40aa53c65c45ba7b4735d4f398 Mon Sep 17 00:00:00 2001
From: Alex Crichton <alex@alexcrichton.com>
Date: Fri, 7 Jul 2017 14:18:19 -0700
Subject: [PATCH] Clean up CI configuration and add s390x

We can't test s390x because qemu segfaults but we can at least verify that it
compiles.

Closes #650
---
 .travis.yml                                  | 95 ++++++--------------
 Cargo.lock                                   | 10 +--
 Cargo.toml                                   |  2 +-
 ci/docker/s390x-unknown-linux-gnu/Dockerfile |  9 ++
 ci/run.sh                                    |  5 ++
 src/unix/notbsd/linux/s390x.rs               |  2 +-
 6 files changed, 46 insertions(+), 77 deletions(-)
 create mode 100644 ci/docker/s390x-unknown-linux-gnu/Dockerfile

diff --git a/.travis.yml b/.travis.yml
index b7721b5e..4a397979 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,5 @@
 language: rust
+rust: stable
 sudo: required
 dist: trusty
 services:
@@ -22,109 +23,63 @@ env:
 matrix:
   include:
     # 1.0.0 compat
-    - os: linux
-      env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
+    - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
       rust: 1.0.0
       script: cargo build
       install:
 
     # build documentation
-    - os: linux
-      env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
+    - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
       rust: nightly
       script: sh ci/dox.sh
 
     # stable compat
-    - os: linux
-      env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
-      rust: stable
-    - os: linux
-      env: TARGET=i686-unknown-linux-gnu
-      rust: stable
+    - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
+    - env: TARGET=i686-unknown-linux-gnu
     - os: osx
       env: TARGET=x86_64-apple-darwin NO_ADD=1
-      rust: stable
     - os: osx
       env: TARGET=i686-apple-darwin
-      rust: stable
-    - os: linux
-      env: TARGET=arm-linux-androideabi
-      rust: stable
-    - os: linux
-      env: TARGET=aarch64-linux-android
-      rust: stable
-    - os: linux
-      env: TARGET=i686-linux-android
-      rust: stable
-    # as of 2017/05/03 x86_64-linux-android are not on stable
-    - os: linux
-      env: TARGET=x86_64-linux-android
-      rust: beta
-    - os: linux
-      env: TARGET=x86_64-unknown-linux-musl
-      rust: stable
-    - os: linux
-      env: TARGET=i686-unknown-linux-musl
-      rust: stable
-    - os: linux
-      env: TARGET=arm-unknown-linux-gnueabihf
-      rust: stable
-    - os: linux
-      env: TARGET=aarch64-unknown-linux-gnu
-      rust: stable
+    - env: TARGET=arm-linux-androideabi
+    - env: TARGET=aarch64-linux-android
+    - env: TARGET=i686-linux-android
+    - env: TARGET=x86_64-linux-android
+    - env: TARGET=x86_64-unknown-linux-musl
+    - env: TARGET=i686-unknown-linux-musl
+    - env: TARGET=arm-unknown-linux-gnueabihf
+    - env: TARGET=aarch64-unknown-linux-gnu
     - os: osx
       osx_image: xcode8.2
       env: TARGET=i386-apple-ios
-      rust: stable
     - os: osx
       osx_image: xcode8.2
       env: TARGET=x86_64-apple-ios
-      rust: stable
-    - os: linux
-      env: TARGET=x86_64-rumprun-netbsd
-      rust: stable
-    - os: linux
-      env: TARGET=powerpc-unknown-linux-gnu
-      rust: stable
-    - os: linux
-      env: TARGET=powerpc64-unknown-linux-gnu
-      rust: beta
-    - os: linux
-      env: TARGET=mips-unknown-linux-musl
-      rust: stable
-    - os: linux
-      env: TARGET=mipsel-unknown-linux-musl
-      rust: stable
-    - os: linux
-      env: TARGET=mips64-unknown-linux-gnuabi64
-      rust: beta
-    - os: linux
-      env: TARGET=mips-unknown-linux-gnu
-      rust: beta
+    - env: TARGET=x86_64-rumprun-netbsd
+    - env: TARGET=powerpc-unknown-linux-gnu
+    - env: TARGET=powerpc64-unknown-linux-gnu
+    - env: TARGET=mips-unknown-linux-musl
+    - env: TARGET=mipsel-unknown-linux-musl
+    - env: TARGET=mips64-unknown-linux-gnuabi64
+    - env: TARGET=mips-unknown-linux-gnu
+    - env: TARGET=s390x-unknown-linux-gnu
 
     # beta
-    - os: linux
-      env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
+    - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
       rust: beta
     - os: osx
       env: TARGET=x86_64-apple-darwin NO_ADD=1
       rust: beta
 
     # nightly
-    - os: linux
-      env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
+    - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
       rust: nightly
     - os: osx
       env: TARGET=x86_64-apple-darwin NO_ADD=1
       rust: nightly
 
     # QEMU based targets that compile in an emulator
-    - os: linux
-      env: TARGET=x86_64-unknown-freebsd
-      rust: stable
-    - os: linux
-      env: TARGET=x86_64-unknown-openbsd QEMU=openbsd.qcow2
-      rust: stable
+    - env: TARGET=x86_64-unknown-freebsd
+    - env: TARGET=x86_64-unknown-openbsd QEMU=openbsd.qcow2
       script: sh ci/run-docker.sh $TARGET
       install:
 
diff --git a/Cargo.lock b/Cargo.lock
index 2bf877b5..6d0bacc8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,7 +3,7 @@ name = "libc-test"
 version = "0.1.0"
 dependencies = [
  "ctest 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.25",
+ "libc 0.2.26",
 ]
 
 [[package]]
@@ -43,12 +43,12 @@ dependencies = [
 
 [[package]]
 name = "libc"
-version = "0.2.24"
+version = "0.2.25"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "libc"
-version = "0.2.25"
+version = "0.2.26"
 
 [[package]]
 name = "log"
@@ -66,7 +66,7 @@ version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -102,7 +102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum ctest 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca66d610c7d9d6b7c51834ceeffe83b40b71be9f6793e350cff093428f73591"
 "checksum gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)" = "120d07f202dcc3f72859422563522b66fe6463a4c513df062874daad05f85f0a"
 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)" = "38f5c2b18a287cf78b4097db62e20f43cace381dc76ae5c0a3073067f78b7ddc"
+"checksum libc 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "b807d3f9f61fec68ffa8b10389fffb9235aa0ffa32935be864b2329de5846b74"
 "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
 "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
 "checksum syntex_syntax 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82b078749c05271b2aebae7230331c903c38128d5a3dec72625d9e3a411a5b69"
diff --git a/Cargo.toml b/Cargo.toml
index 17e98dbb..4984e15e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 
 name = "libc"
-version = "0.2.25"
+version = "0.2.26"
 authors = ["The Rust Project Developers"]
 license = "MIT/Apache-2.0"
 readme = "README.md"
diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile
new file mode 100644
index 00000000..cbcfdf35
--- /dev/null
+++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile
@@ -0,0 +1,9 @@
+FROM ubuntu:17.04
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+        gcc libc6-dev qemu-user ca-certificates \
+        gcc-s390x-linux-gnu libc6-dev-s390x-cross
+
+ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \
+    CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \
+    PATH=$PATH:/rust/bin
diff --git a/ci/run.sh b/ci/run.sh
index 3ddc7b39..54e2129f 100755
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -168,6 +168,11 @@ case "$TARGET" in
     qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test
     ;;
 
+  s390x-unknown-linux-gnu)
+    # TODO: in theory we should execute this, but qemu segfaults immediately :(
+    # qemu-s390x -L /usr/s390x-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test
+    ;;
+
   *-rumprun-netbsd)
     rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/libc-test
     qemu-system-x86_64 -nographic -vga none -m 64 \
diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs
index 35ab8eaa..fb95a07a 100644
--- a/src/unix/notbsd/linux/s390x.rs
+++ b/src/unix/notbsd/linux/s390x.rs
@@ -16,6 +16,7 @@ pub type greg_t = u64;
 pub type clock_t = i64;
 pub type __fsword_t = ::c_long;
 pub type __priority_which_t = ::c_uint;
+pub type __u64 = u64;
 
 s! {
     pub struct aiocb {
@@ -777,7 +778,6 @@ pub const CMSPAR: ::tcflag_t = 0o10000000000;
 pub const VSWTC: usize = 7;
 pub const OLCUC:  ::tcflag_t = 0o000002;
 pub const NLDLY:  ::tcflag_t = 0o000400;
-pub const NL1: ::tcflag_t  = 0x00000100;
 pub const CRDLY:  ::tcflag_t = 0o003000;
 pub const CR1: ::tcflag_t  = 0x00000200;
 pub const CR2: ::tcflag_t  = 0x00000400;
-- 
GitLab