From ee54be3c9a8099d45d64764f0e50c315d5256a4c Mon Sep 17 00:00:00 2001 From: Shawn Walker-Salas Date: Sat, 11 Feb 2017 09:24:33 -0800 Subject: [PATCH 1/4] Add Solaris as recognized ostype Add cputype recognition for Solaris Fixes #39729 --- src/bootstrap/bootstrap.py | 15 +++++++++++++++ src/libstd/build.rs | 2 ++ src/libunwind/build.rs | 2 ++ 3 files changed, 19 insertions(+) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 27255b6910093..9593e3f0793b3 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -345,6 +345,21 @@ def build_triple(self): ostype = 'unknown-openbsd' elif ostype == 'NetBSD': ostype = 'unknown-netbsd' + elif ostype == 'SunOS': + ostype = 'sun-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. + try: + cputype = subprocess.check_output(['isainfo', + '-k']).strip().decode(default_encoding) + except (subprocess.CalledProcessError, WindowsError): + err = "isainfo not found" + if self.verbose: + raise Exception(err) + sys.exit(err) elif ostype == 'Darwin': ostype = 'apple-darwin' elif ostype.startswith('MINGW'): diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 0fca374f6e6d1..790cd5b65ba30 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -46,6 +46,8 @@ fn main() { } else if target.contains("dragonfly") || target.contains("bitrig") || target.contains("netbsd") || target.contains("openbsd") { println!("cargo:rustc-link-lib=pthread"); + } else if target.contains("solaris") { + println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("apple-darwin") { println!("cargo:rustc-link-lib=System"); } else if target.contains("apple-ios") { diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index f18b694d3d0c7..ea0d76978339d 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -27,6 +27,8 @@ fn main() { println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("openbsd") { println!("cargo:rustc-link-lib=gcc"); + } else if target.contains("solaris") { + println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("bitrig") { println!("cargo:rustc-link-lib=c++abi"); } else if target.contains("dragonfly") { From 33b655e6a8db00d099d1ef37c2f39f73b1248190 Mon Sep 17 00:00:00 2001 From: Shawn Walker-Salas Date: Sat, 11 Feb 2017 20:38:13 -0800 Subject: [PATCH 2/4] fix copy pasta Don't need to catch WindowsError. That was very silly of me. --- src/bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 9593e3f0793b3..7163a6f359cda 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -315,7 +315,7 @@ def build_triple(self): try: ostype = subprocess.check_output(['uname', '-s']).strip().decode(default_encoding) cputype = subprocess.check_output(['uname', '-m']).strip().decode(default_encoding) - except (subprocess.CalledProcessError, WindowsError): + except subprocess.CalledProcessError: if sys.platform == 'win32': return 'x86_64-pc-windows-msvc' err = "uname not found" From 4a618fee1efc279d8fe2386f3c74b7e3f3265aa8 Mon Sep 17 00:00:00 2001 From: Shawn Walker-Salas Date: Sat, 11 Feb 2017 22:55:25 -0800 Subject: [PATCH 3/4] fix exception handling for isainfo execution failure remove unnecessary gcc_s addition in libstd for Solaris --- src/bootstrap/bootstrap.py | 2 +- src/libstd/build.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 7163a6f359cda..a632a82bf7d01 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -355,7 +355,7 @@ def build_triple(self): try: cputype = subprocess.check_output(['isainfo', '-k']).strip().decode(default_encoding) - except (subprocess.CalledProcessError, WindowsError): + except (subprocess.CalledProcessError, OSError): err = "isainfo not found" if self.verbose: raise Exception(err) diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 790cd5b65ba30..0fca374f6e6d1 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -46,8 +46,6 @@ fn main() { } else if target.contains("dragonfly") || target.contains("bitrig") || target.contains("netbsd") || target.contains("openbsd") { println!("cargo:rustc-link-lib=pthread"); - } else if target.contains("solaris") { - println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("apple-darwin") { println!("cargo:rustc-link-lib=System"); } else if target.contains("apple-ios") { From 3807e1f393e3022dcf686e2109eda1fb34eb22c9 Mon Sep 17 00:00:00 2001 From: Shawn Walker-Salas Date: Sun, 12 Feb 2017 11:24:06 -0800 Subject: [PATCH 4/4] fix portability issue in error handling of build_triple --- src/bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index a632a82bf7d01..caf2402f40c4b 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -315,7 +315,7 @@ def build_triple(self): try: ostype = subprocess.check_output(['uname', '-s']).strip().decode(default_encoding) cputype = subprocess.check_output(['uname', '-m']).strip().decode(default_encoding) - except subprocess.CalledProcessError: + except (subprocess.CalledProcessError, OSError): if sys.platform == 'win32': return 'x86_64-pc-windows-msvc' err = "uname not found"