]> git.lizzy.rs Git - rust.git/commitdiff
use "gcc" instead of "cc" on *-sun-solaris systems when linking
authorJoshua M. Clulow <jmc@oxide.computer>
Tue, 17 Mar 2020 06:15:34 +0000 (23:15 -0700)
committerJoshua M. Clulow <jmc@oxide.computer>
Tue, 17 Mar 2020 06:15:34 +0000 (23:15 -0700)
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

index a4eef2374c2413105be033eee2605b50f7cb2d96..d7081e60bd1fcce09c5e1c0c3d1a4e94d52cd392 100644 (file)
@@ -839,7 +839,13 @@ fn infer_from(
                             "emcc"
                         }
                     }
-                    LinkerFlavor::Gcc => "cc",
+                    LinkerFlavor::Gcc => {
+                        if cfg!(target_os = "solaris") {
+                            "gcc"
+                        } else {
+                            "cc"
+                        }
+                    }
                     LinkerFlavor::Ld => "ld",
                     LinkerFlavor::Msvc => "link.exe",
                     LinkerFlavor::Lld(_) => "lld",