Skip to content

Commit a38c1c4

Browse files
author
Daniel Kroening
authored
Merge pull request #1092 from karkhaz/kk-native-objcopy
Use native objcopy when linking with GCC
2 parents d36c0d0 + f9664aa commit a38c1c4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/goto-cc/gcc_mode.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Author: CM Wintersteiger, 2006
2222
#include <fstream>
2323

2424
#include <util/string2int.h>
25+
#include <util/invariant.h>
2526
#include <util/tempdir.h>
2627
#include <util/config.h>
2728
#include <util/prefix.h>
@@ -502,7 +503,7 @@ int gcc_modet::doit()
502503
else if(cmdline.isset('E'))
503504
{
504505
compiler.mode=compilet::PREPROCESS_ONLY;
505-
assert(false);
506+
UNREACHABLE;
506507
}
507508
else if(cmdline.isset("shared") ||
508509
cmdline.isset('r')) // really not well documented
@@ -524,7 +525,6 @@ int gcc_modet::doit()
524525
debug() << "Compiling and linking a library" << eom; break;
525526
case compilet::COMPILE_LINK_EXECUTABLE:
526527
debug() << "Compiling and linking an executable" << eom; break;
527-
default: assert(false);
528528
}
529529

530530
if(cmdline.isset("i386-win32") ||
@@ -778,7 +778,7 @@ int gcc_modet::preprocess(
778778
new_argv.push_back(src);
779779

780780
// overwrite argv[0]
781-
assert(new_argv.size()>=1);
781+
INVARIANT(new_argv.size()>=1, "No program name in argv");
782782
new_argv[0]=native_tool_name.c_str();
783783

784784
debug() << "RUN:";
@@ -792,7 +792,7 @@ int gcc_modet::preprocess(
792792
/// run gcc or clang with original command line
793793
int gcc_modet::run_gcc()
794794
{
795-
assert(!cmdline.parsed_argv.empty());
795+
PRECONDITION(!cmdline.parsed_argv.empty());
796796

797797
// build new argv
798798
std::vector<std::string> new_argv;
@@ -879,6 +879,11 @@ int gcc_modet::gcc_hybrid_binary()
879879
objcopy_cmd=linker_name(cmdline, base_name);
880880
objcopy_cmd.erase(objcopy_cmd.size()-2);
881881
}
882+
else if(has_suffix(compiler_name(cmdline, base_name), "-gcc"))
883+
{
884+
objcopy_cmd=compiler_name(cmdline, base_name);
885+
objcopy_cmd.erase(objcopy_cmd.size()-3);
886+
}
882887
objcopy_cmd+="objcopy";
883888

884889
int result=run_gcc();

0 commit comments

Comments
 (0)