about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-03-27 15:09:57 +0100
committerGitHub <noreply@github.com>2020-03-27 15:09:57 +0100
commit4d079a8dd299f4cba1eb04cda67ace0bb6172457 (patch)
tree2a8a68eab43e4fa2f8914fbab0b2cb7aab2c2dee
parent6b6c470beeae7792d0e9e7a2bbe4663a25c999c6 (diff)
parent1c191c304aa5629e31c93bec395fe4255ecca9ce (diff)
downloadrust-4d079a8dd299f4cba1eb04cda67ace0bb6172457.tar.gz
rust-4d079a8dd299f4cba1eb04cda67ace0bb6172457.zip
Rollup merge of #70068 - jclulow:illumos-gcc, r=cramertj
use "gcc" instead of "cc" on *-sun-solaris systems when linking

On illumos and Solaris systems, Rust will use GCC as the link editor.
Rust does this by invoking "cc", which on many (Linux and perhaps BSD)
systems is generally either GCC or a GCC-compatible front-end.  On
historical Solaris systems, "cc" was often the Sun Studio compiler.
This history casts a long shadow, and as such, even most modern
illumos-based operating systems tend to install GCC as "gcc", without
also making it available as "cc".

We should invoke GCC as "gcc" on such systems to ensure we get the right
compiler driver.
-rw-r--r--src/librustc_codegen_ssa/back/link.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
index 672b6e4aa46..1fb08a05803 100644
--- a/src/librustc_codegen_ssa/back/link.rs
+++ b/src/librustc_codegen_ssa/back/link.rs
@@ -838,7 +838,19 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
                             "emcc"
                         }
                     }
-                    LinkerFlavor::Gcc => "cc",
+                    LinkerFlavor::Gcc => {
+                        if cfg!(target_os = "solaris") {
+                            // On historical Solaris systems, "cc" may have
+                            // been Sun Studio, which is not flag-compatible
+                            // with "gcc".  This history casts a long shadow,
+                            // and many modern illumos distributions today
+                            // ship GCC as "gcc" without also making it
+                            // available as "cc".
+                            "gcc"
+                        } else {
+                            "cc"
+                        }
+                    }
                     LinkerFlavor::Ld => "ld",
                     LinkerFlavor::Msvc => "link.exe",
                     LinkerFlavor::Lld(_) => "lld",