Skip to content

Commit 4d079a8

Browse files
authored
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.
2 parents 6b6c470 + 1c191c3 commit 4d079a8

File tree

1 file changed

+13
-1
lines changed
  • src/librustc_codegen_ssa/back

1 file changed

+13
-1
lines changed

src/librustc_codegen_ssa/back/link.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,19 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
838838
"emcc"
839839
}
840840
}
841-
LinkerFlavor::Gcc => "cc",
841+
LinkerFlavor::Gcc => {
842+
if cfg!(target_os = "solaris") {
843+
// On historical Solaris systems, "cc" may have
844+
// been Sun Studio, which is not flag-compatible
845+
// with "gcc". This history casts a long shadow,
846+
// and many modern illumos distributions today
847+
// ship GCC as "gcc" without also making it
848+
// available as "cc".
849+
"gcc"
850+
} else {
851+
"cc"
852+
}
853+
}
842854
LinkerFlavor::Ld => "ld",
843855
LinkerFlavor::Msvc => "link.exe",
844856
LinkerFlavor::Lld(_) => "lld",

0 commit comments

Comments
 (0)