From a83e6c7328f3fe8c78445fdb8088d7a7fa6f8897 Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Mon, 16 Mar 2020 23:15:34 -0700 Subject: [PATCH 1/2] 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. --- src/librustc_codegen_ssa/back/link.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index a4eef2374c241..d7081e60bd1fc 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -839,7 +839,13 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { "emcc" } } - LinkerFlavor::Gcc => "cc", + LinkerFlavor::Gcc => { + if cfg!(target_os = "solaris") { + "gcc" + } else { + "cc" + } + } LinkerFlavor::Ld => "ld", LinkerFlavor::Msvc => "link.exe", LinkerFlavor::Lld(_) => "lld", From 1c191c304aa5629e31c93bec395fe4255ecca9ce Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Tue, 17 Mar 2020 15:04:29 -0700 Subject: [PATCH 2/2] review feedback: add a comment describing the situation --- src/librustc_codegen_ssa/back/link.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index d7081e60bd1fc..fb6154eb39261 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -841,6 +841,12 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { } 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"