From 5abd4efb5d4c75ad24568767849b33f36a60417a Mon Sep 17 00:00:00 2001 From: Zuzana Baranova <xbaranov@fi.muni.cz> Date: Sat, 29 Jun 2019 11:04:35 +0000 Subject: [PATCH] CC: Make ld the default linker and lld optional (with --use-lld). --- divine/cc/native.cpp | 16 ++++++++-------- divine/cc/options.cpp | 4 ++-- divine/cc/options.hpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/divine/cc/native.cpp b/divine/cc/native.cpp index e7e53810b..6d75e2256 100644 --- a/divine/cc/native.cpp +++ b/divine/cc/native.cpp @@ -83,14 +83,7 @@ namespace divine::cc ld_args_c.push_back( _ld_args[i].c_str() ); auto ld_job = drv->getJobs( ld_args_c ).back(); - if ( _po.use_system_ld ) - { - ld_job.args.insert( ld_job.args.begin(), ld_job.name ); - auto r = brick::proc::spawnAndWait( brick::proc::CaptureStderr, ld_job.args ); - if ( !r ) - throw cc::CompileError( "failed to link, ld exited with " + to_string( r ) ); - } - else + if ( _po.use_lld ) { ld_job.args.insert( ld_job.args.begin(), "divcc" ); std::vector< const char * > lld_job_c; @@ -102,6 +95,13 @@ namespace divine::cc if ( !linked ) throw cc::CompileError( "lld failed, not linked" ); } + else + { + ld_job.args.insert( ld_job.args.begin(), ld_job.name ); + auto r = brick::proc::spawnAndWait( brick::proc::CaptureStderr, ld_job.args ); + if ( !r ) + throw cc::CompileError( "failed to link, ld exited with " + to_string( r ) ); + } std::unique_ptr< llvm::Module > mod = link_bitcode(); std::string file_out = _po.outputFile != "" ? _po.outputFile : "a.out"; diff --git a/divine/cc/options.cpp b/divine/cc/options.cpp index f181eb949..793bc6191 100644 --- a/divine/cc/options.cpp +++ b/divine/cc/options.cpp @@ -100,8 +100,8 @@ namespace divine::cc po.toObjectOnly = true; else if ( *it == "-E" ) po.preprocessOnly = true; - else if ( *it == "--use-system-ld" ) - po.use_system_ld = true; + else if ( *it == "--use-lld" ) + po.use_lld = true; else if ( *it == "-g" ) po.opts.emplace_back( "-debug-info-kind=standalone" ); else diff --git a/divine/cc/options.hpp b/divine/cc/options.hpp index f55eb28e6..65b199a00 100644 --- a/divine/cc/options.hpp +++ b/divine/cc/options.hpp @@ -37,7 +37,7 @@ namespace divine::cc bool preprocessOnly = false; bool hasHelp = false; bool hasVersion = false; - bool use_system_ld = false; + bool use_lld = false; }; ParsedOpts parseOpts( std::vector< std::string > rawCCOpts ); -- GitLab