summaryrefslogtreecommitdiff
path: root/src/trans/codegen_c.cpp
diff options
context:
space:
mode:
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");