From 2cf8929b32259d42c66de9636e9cb4b316a04e0c Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Wed, 29 Oct 2014 17:40:02 -0700 Subject: [PATCH] rustc: Respect CC variable at runtime This really should be passed in either from sniffing CFG_CC during configure, or with a --cc-program flag to the configure script, but an escape hatch is required for platforms with nothing called `cc' on PATH. --- src/librustc/back/link.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index d47ca892b13b1..43ca51af2badc 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -33,6 +33,7 @@ use std::io::{fs, TempDir, Command}; use std::io; use std::mem; use std::str; +use std::os; use std::string::String; use flate; use serialize::hex::ToHex; @@ -370,10 +371,13 @@ pub fn get_cc_prog(sess: &Session) -> String { // It would be flexible to use cc (system's default C compiler) // instead of hard-coded gcc. // For Windows, there is no cc command, so we add a condition to make it use gcc. - match sess.targ_cfg.os { - abi::OsWindows => "gcc", - _ => "cc", - }.to_string() + match os::getenv("CC") { + Some(cc) => cc, + None => match sess.targ_cfg.os { + abi::OsWindows => "gcc", + _ => "cc", + }.to_string() + } } pub fn remove(sess: &Session, path: &Path) {