summaryrefslogtreecommitdiff
path: root/src/trans/codegen_c.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-05-11 08:02:00 +0800
committerJohn Hodge <tpg@mutabah.net>2018-05-11 08:02:00 +0800
commit174c4f47160dba499c84986d15180fe4307d4adc (patch)
tree9d4f154d404efed09c54e27041eaaa9852773e3b /src/trans/codegen_c.cpp
parent3b8d8f1a392a2cb5cad1d57d08ced693a0d197d8 (diff)
parentba9b4c4da6b9117529370f402e1015bf1730ccb2 (diff)
downloadmrust-174c4f47160dba499c84986d15180fe4307d4adc.tar.gz
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r--src/trans/codegen_c.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 0171f19f..5df20334 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -559,12 +559,24 @@ namespace {
switch( m_compiler )
{
case Compiler::Gcc:
- if( getenv("CC") ) {
- args.push_back( getenv("CC") );
- }
- else {
- //args.push_back( Target_GetCurSpec().m_c_compiler + "-gcc" );
- args.push_back( "gcc" );
+ // Pick the compiler
+ // - from `CC-${TRIPLE}` environment variable
+ // - from the $CC environment variable
+ // - `gcc-${TRIPLE}` (if available)
+ // - `gcc` as fallback
+ {
+ ::std::string varname = "CC-" + Target_GetCurSpec().m_c_compiler;
+ if( getenv(varname.c_str()) ) {
+ args.push_back( getenv(varname.c_str()) );
+ }
+ else if( getenv("CC") ) {
+ args.push_back( getenv("CC") );
+ }
+ else {
+ // TODO: Determine if the compiler can't be found, and fall back to `gcc` if that's the case
+ args.push_back( Target_GetCurSpec().m_c_compiler + "-gcc" );
+ //args.push_back( "gcc" );
+ }
}
args.push_back("-ffunction-sections");
args.push_back("-pthread");