From c615bed38784b6f38a30865f48898af821894fae Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Tue, 16 Feb 2021 15:02:04 +0100 Subject: [PATCH 1/3] Change default Solaris x86 target to x86_64-pc-solaris --- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_target/src/spec/mod.rs | 23 ++----------------- .../rustc_target/src/spec/solaris_base.rs | 1 - .../src/spec/sparcv9_sun_solaris.rs | 1 + .../src/spec/x86_64_pc_solaris.rs | 19 +++++++++++++++ .../src/spec/x86_64_sun_solaris.rs | 1 + src/bootstrap/bootstrap.py | 5 +++- 7 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 compiler/rustc_target/src/spec/x86_64_pc_solaris.rs diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 38da52b88f369..a3900ebcea99c 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1536,7 +1536,7 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType early_error(error_format, &format!("target file {:?} does not exist", path)) }) } - Some(target) => TargetTriple::from_alias(target), + Some(target) => TargetTriple::TargetTriple(target), _ => TargetTriple::from_triple(host_triple()), } } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index b53d851e051bc..039e9a8b2745f 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -736,9 +736,8 @@ supported_targets! { ("armv7r-none-eabi", armv7r_none_eabi), ("armv7r-none-eabihf", armv7r_none_eabihf), - // `x86_64-pc-solaris` is an alias for `x86_64_sun_solaris` for backwards compatibility reasons. - // (See .) - ("x86_64-sun-solaris", "x86_64-pc-solaris", x86_64_sun_solaris), + ("x86_64-pc-solaris", x86_64_pc_solaris), + ("x86_64-sun-solaris", x86_64_sun_solaris), ("sparcv9-sun-solaris", sparcv9_sun_solaris), ("x86_64-unknown-illumos", x86_64_unknown_illumos), @@ -1986,24 +1985,6 @@ impl TargetTriple { Ok(TargetTriple::TargetPath(canonicalized_path)) } - /// Creates a target triple from its alias - pub fn from_alias(triple: String) -> Self { - macro_rules! target_aliases { - ( $(($alias:literal, $target:literal ),)+ ) => { - match triple.as_str() { - $( $alias => TargetTriple::from_triple($target), )+ - _ => TargetTriple::TargetTriple(triple), - } - } - } - - target_aliases! { - // `x86_64-pc-solaris` is an alias for `x86_64_sun_solaris` for backwards compatibility reasons. - // (See .) - ("x86_64-pc-solaris", "x86_64-sun-solaris"), - } - } - /// Returns a string triple for this target. /// /// If this target is a path, the file name (without extension) is returned. diff --git a/compiler/rustc_target/src/spec/solaris_base.rs b/compiler/rustc_target/src/spec/solaris_base.rs index 33e0cf8e96752..59731f25821ff 100644 --- a/compiler/rustc_target/src/spec/solaris_base.rs +++ b/compiler/rustc_target/src/spec/solaris_base.rs @@ -3,7 +3,6 @@ use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { TargetOptions { os: "solaris".to_string(), - vendor: "sun".to_string(), dynamic_linking: true, executables: true, has_rpath: true, diff --git a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs index 9ac56cae9168a..abc46a8c9c3ac 100644 --- a/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs +++ b/compiler/rustc_target/src/spec/sparcv9_sun_solaris.rs @@ -7,6 +7,7 @@ pub fn target() -> Target { base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); // llvm calls this "v9" base.cpu = "v9".to_string(); + base.vendor = "sun".to_string(); base.max_atomic_width = Some(64); Target { diff --git a/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs new file mode 100644 index 0000000000000..75eece74ff97d --- /dev/null +++ b/compiler/rustc_target/src/spec/x86_64_pc_solaris.rs @@ -0,0 +1,19 @@ +use crate::spec::{LinkerFlavor, StackProbeType, Target}; + +pub fn target() -> Target { + let mut base = super::solaris_base::opts(); + base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); + base.cpu = "x86-64".to_string(); + base.vendor = "pc".to_string(); + base.max_atomic_width = Some(64); + base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) }; + + Target { + llvm_target: "x86_64-pc-solaris".to_string(), + pointer_width: 64, + data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + .to_string(), + arch: "x86_64".to_string(), + options: base, + } +} diff --git a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs index 0fe462ec83cbc..63e524fa8a9a2 100644 --- a/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs +++ b/compiler/rustc_target/src/spec/x86_64_sun_solaris.rs @@ -4,6 +4,7 @@ pub fn target() -> Target { let mut base = super::solaris_base::opts(); base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); base.cpu = "x86-64".to_string(); + base.vendor = "sun".to_string(); base.max_atomic_width = Some(64); base.stack_probes = StackProbeType::InlineOrCall { min_llvm_version_for_inline: (11, 0, 1) }; diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index a438e920b7bc6..62bf4ffd380a0 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`: From c3226accbeb3ec34e10a4001af96278a37651b34 Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Wed, 17 Feb 2021 11:27:34 +0100 Subject: [PATCH 2/3] Update supported platforms doc --- src/doc/rustc/src/platform-support.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index a4ace91730ec3..d3b88c019f019 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 From 47f291ec2d9d6e4820cca517e69b3efddec40c20 Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Fri, 19 Feb 2021 11:50:30 +0100 Subject: [PATCH 3/3] Update Docker to use the correct target --- .../host-x86_64/dist-various-2/Dockerfile | 8 ++--- .../dist-various-2/build-solaris-toolchain.sh | 29 ++++++++++++++----- src/ci/docker/scripts/illumos-toolchain.sh | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) 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 6cfacc3b8ce68..7bb3cb1451688 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 14fb399aff5e2..ee76fafb1f948 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 8cb5712657947..3f1d5f3426abf 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,