about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/bootstrap.py5
-rw-r--r--src/ci/docker/host-x86_64/dist-various-2/Dockerfile8
-rwxr-xr-xsrc/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh29
-rw-r--r--src/ci/docker/scripts/illumos-toolchain.sh2
-rw-r--r--src/doc/rustc/src/platform-support.md4
-rw-r--r--src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs28
-rw-r--r--src/test/ui/lint/unaligned_references_external_macro.rs14
-rw-r--r--src/test/ui/lint/unaligned_references_external_macro.stderr26
8 files changed, 100 insertions, 16 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index a438e920b7b..62bf4ffd380 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -240,13 +240,16 @@ def default_build_triple(verbose):
         else:
             ostype = 'unknown-linux-gnu'
     elif ostype == 'SunOS':
-        ostype = 'sun-solaris'
+        ostype = 'pc-solaris'
         # On Solaris, uname -m will return a machine classification instead
         # of a cpu type, so uname -p is recommended instead.  However, the
         # output from that option is too generic for our purposes (it will
         # always emit 'i386' on x86/amd64 systems).  As such, isainfo -k
         # must be used instead.
         cputype = require(['isainfo', '-k']).decode(default_encoding)
+        # sparc cpus have sun as a target vendor
+        if 'sparc' in cputype:
+            ostype = 'sun-solaris'
     elif ostype.startswith('MINGW'):
         # msys' `uname` does not print gcc configuration, but prints msys
         # configuration. so we cannot believe `uname -m`:
diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile
index 6cfacc3b8ce..7bb3cb14516 100644
--- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile
+++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile
@@ -39,9 +39,9 @@ ENV \
     AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \
     CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \
     CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
-    AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \
-    CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
-    CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ \
+    AR_x86_64_pc_solaris=x86_64-pc-solaris2.10-ar \
+    CC_x86_64_pc_solaris=x86_64-pc-solaris2.10-gcc \
+    CXX_x86_64_pc_solaris=x86_64-pc-solaris2.10-g++ \
     CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-8 \
     CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-8 \
     AR_x86_64_fortanix_unknown_sgx=ar \
@@ -100,7 +100,7 @@ ENV TARGETS=$TARGETS,aarch64-fuchsia
 ENV TARGETS=$TARGETS,wasm32-unknown-unknown
 ENV TARGETS=$TARGETS,wasm32-wasi
 ENV TARGETS=$TARGETS,sparcv9-sun-solaris
-ENV TARGETS=$TARGETS,x86_64-sun-solaris
+ENV TARGETS=$TARGETS,x86_64-pc-solaris
 ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
 ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx
 ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda
diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh
index 14fb399aff5..ee76fafb1f9 100755
--- a/src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh
+++ b/src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh
@@ -9,6 +9,19 @@ APT_ARCH=$3
 BINUTILS=2.28.1
 GCC=6.5.0
 
+# Choose correct target based on the $ARCH
+case "$ARCH" in
+x86_64)
+  TARGET=x86_64-pc-solaris2.10
+  ;;
+sparcv9)
+  TARGET=sparcv9-sun-solaris2.10
+  ;;
+*)
+  printf 'ERROR: unknown architecture: %s\n' "$ARCH"
+  exit 1
+esac
+
 # First up, build binutils
 mkdir binutils
 cd binutils
@@ -16,7 +29,7 @@ cd binutils
 curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf -
 mkdir binutils-build
 cd binutils-build
-hide_output ../binutils-$BINUTILS/configure --target=$ARCH-sun-solaris2.10
+hide_output ../binutils-$BINUTILS/configure --target=$TARGET
 hide_output make -j10
 hide_output make install
 
@@ -62,13 +75,13 @@ patch -p0  << 'EOF'
 -extern size_t strnlen(const char *, size_t);
 EOF
 
-mkdir                  /usr/local/$ARCH-sun-solaris2.10/usr
-mv usr/include         /usr/local/$ARCH-sun-solaris2.10/usr/include
-mv usr/lib/$LIB_ARCH/* /usr/local/$ARCH-sun-solaris2.10/lib
-mv     lib/$LIB_ARCH/* /usr/local/$ARCH-sun-solaris2.10/lib
+mkdir                  /usr/local/$TARGET/usr
+mv usr/include         /usr/local/$TARGET/usr/include
+mv usr/lib/$LIB_ARCH/* /usr/local/$TARGET/lib
+mv     lib/$LIB_ARCH/* /usr/local/$TARGET/lib
 
-ln -s usr/include /usr/local/$ARCH-sun-solaris2.10/sys-include
-ln -s usr/include /usr/local/$ARCH-sun-solaris2.10/include
+ln -s usr/include /usr/local/$TARGET/sys-include
+ln -s usr/include /usr/local/$TARGET/include
 
 cd ..
 rm -rf solaris
@@ -84,7 +97,7 @@ mkdir ../gcc-build
 cd ../gcc-build
 hide_output ../gcc-$GCC/configure \
   --enable-languages=c,c++        \
-  --target=$ARCH-sun-solaris2.10  \
+  --target=$TARGET                \
   --with-gnu-as                   \
   --with-gnu-ld                   \
   --disable-multilib              \
diff --git a/src/ci/docker/scripts/illumos-toolchain.sh b/src/ci/docker/scripts/illumos-toolchain.sh
index 8cb57126579..3f1d5f3426a 100644
--- a/src/ci/docker/scripts/illumos-toolchain.sh
+++ b/src/ci/docker/scripts/illumos-toolchain.sh
@@ -18,7 +18,7 @@ x86_64)
         exit 1
 esac
 
-BUILD_TARGET="$ARCH-sun-solaris2.10"
+BUILD_TARGET="$ARCH-pc-solaris2.10"
 
 #
 # The illumos and the Solaris build both use the same GCC-level host triple,
diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md
index a4ace91730e..d3b88c019f0 100644
--- a/src/doc/rustc/src/platform-support.md
+++ b/src/doc/rustc/src/platform-support.md
@@ -133,7 +133,7 @@ target | std | host | notes
 `x86_64-fortanix-unknown-sgx` | ✓ |  | [Fortanix ABI] for 64-bit Intel SGX
 `x86_64-fuchsia` | ✓ |  | 64-bit Fuchsia
 `x86_64-linux-android` | ✓ |  | 64-bit x86 Android
-`x86_64-sun-solaris` | ✓ |  | 64-bit Solaris 10/11, illumos
+`x86_64-pc-solaris` | ✓ |  | 64-bit Solaris 10/11, illumos
 `x86_64-unknown-freebsd` | ✓ | ✓ | 64-bit FreeBSD
 `x86_64-unknown-illumos` | ✓ | ✓ | illumos
 `x86_64-unknown-linux-gnux32` | ✓ |  | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27)
@@ -218,7 +218,7 @@ target | std | host | notes
 `x86_64-apple-ios-macabi` | ✓ |  | Apple Catalyst on x86_64
 `x86_64-apple-tvos` | * | | x86 64-bit tvOS
 `x86_64-linux-kernel` | * |  | Linux kernel modules
-`x86_64-pc-solaris` | ? |  |
+`x86_64-sun-solaris` | ? |  | Deprecated target for 64-bit Solaris 10/11, illumos
 `x86_64-pc-windows-msvc` | ✓ |  | 64-bit Windows XP support
 `x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD
 `x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku
diff --git a/src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs b/src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs
new file mode 100644
index 00000000000..fb486c6b59a
--- /dev/null
+++ b/src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs
@@ -0,0 +1,28 @@
+#[macro_export]
+macro_rules! mac {
+    (
+        $(#[$attrs:meta])*
+        pub struct $ident:ident {
+            $(
+                $(#[$pin:ident])?
+                $field_vis:vis $field:ident: $field_ty:ty
+            ),+ $(,)?
+        }
+    ) => {
+        $(#[$attrs])*
+        pub struct $ident {
+            $(
+                $field_vis $field: $field_ty
+            ),+
+        }
+
+        const _: () = {
+            #[deny(unaligned_references)]
+            fn __f(this: &$ident) {
+                $(
+                    let _ = &this.$field;
+                )+
+            }
+        };
+    };
+}
diff --git a/src/test/ui/lint/unaligned_references_external_macro.rs b/src/test/ui/lint/unaligned_references_external_macro.rs
new file mode 100644
index 00000000000..6ac501fb0e0
--- /dev/null
+++ b/src/test/ui/lint/unaligned_references_external_macro.rs
@@ -0,0 +1,14 @@
+// aux-build:unaligned_references_external_crate.rs
+
+#![allow(safe_packed_borrows)]
+
+extern crate unaligned_references_external_crate;
+
+unaligned_references_external_crate::mac! { //~ERROR reference to packed field is unaligned
+    #[repr(packed)]
+    pub struct X {
+        pub field: u16
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/unaligned_references_external_macro.stderr b/src/test/ui/lint/unaligned_references_external_macro.stderr
new file mode 100644
index 00000000000..140294b65cc
--- /dev/null
+++ b/src/test/ui/lint/unaligned_references_external_macro.stderr
@@ -0,0 +1,26 @@
+error: reference to packed field is unaligned
+  --> $DIR/unaligned_references_external_macro.rs:7:1
+   |
+LL | / unaligned_references_external_crate::mac! {
+LL | |     #[repr(packed)]
+LL | |     pub struct X {
+LL | |         pub field: u16
+LL | |     }
+LL | | }
+   | |_^
+   |
+note: the lint level is defined here
+  --> $DIR/unaligned_references_external_macro.rs:7:1
+   |
+LL | / unaligned_references_external_crate::mac! {
+LL | |     #[repr(packed)]
+LL | |     pub struct X {
+LL | |         pub field: u16
+LL | |     }
+LL | | }
+   | |_^
+   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+