From 25f733b769ed3c525b1618b580163074527d90c3 Mon Sep 17 00:00:00 2001 From: Ken Faiczak Date: Tue, 17 Oct 2017 08:58:04 -0400 Subject: [PATCH 1/7] add support for extra_files --- client/arg.cpp | 37 +++++++++++++++++----- client/local.cpp | 4 --- client/remote.cpp | 72 ++++++++++++++++++++---------------------- configure.ac | 2 +- daemon/serve.cpp | 55 +++++++++++++++++++++----------- daemon/workit.cpp | 4 --- services/comm.cpp | 17 +++++++++- services/comm.h | 7 +++-- services/job.cpp | 9 ++++++ services/job.h | 80 ++++++++++++++++++++++++++++++++++++++++++----- 10 files changed, 203 insertions(+), 84 deletions(-) diff --git a/client/arg.cpp b/client/arg.cpp index d45bcf323..d013eaf29 100644 --- a/client/arg.cpp +++ b/client/arg.cpp @@ -176,7 +176,6 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, list 1 trace() << "scanning arguments" << endl; @@ -195,6 +194,8 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, listhave_dwo_file; + uint32_t extra_files = crmsg->extra_files; delete crmsg; assert(!job.outputFile().empty()); if (status == 0) { receive_file(job.outputFile(), cserver); - if (have_dwo_file) { - string dwo_output = job.outputFile().substr(0, job.outputFile().find_last_of('.')) + ".dwo"; - receive_file(dwo_output, cserver); + uint32_t i(0); + while (extra_files) + { + ++i; + extra_files >>= 1; + if (extra_files & 0x01) + { + std::string file(job.ExtraOutputFileEnum((CompileJob::ExFileEnum)i)); + //printf("get extra file [%d] = %s\n", i, file.c_str()); + receive_file(file, cserver); + } } } @@ -704,11 +712,10 @@ maybe_build_local(MsgChannel *local_daemon, UseCSMsg *usecs, CompileJob &job, struct stat st; msg.out_uncompressed = 0; - if (!stat(job.outputFile().c_str(), &st)) { - msg.out_uncompressed += st.st_size; - } - if (!stat((job.outputFile().substr(0, job.outputFile().find_last_of('.')) + ".dwo").c_str(), &st)) { - msg.out_uncompressed += st.st_size; + for (auto i : job.outputFiles()) { + if (stat(i.second.c_str(), &st)) { + msg.out_uncompressed += st.st_size; + } } msg.user_msec = ru.ru_utime.tv_sec * 1000 + ru.ru_utime.tv_usec / 1000; @@ -738,6 +745,10 @@ static int minimalRemoteVersion( const CompileJob& job) version = max(version, 35); } + if (job.extraOutputEnabled()) { + version = max(version, 37); + } + return version; } @@ -746,7 +757,6 @@ int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments & srand(time(0) + getpid()); int torepeat = 1; - bool has_split_dwarf = job.dwarfFissionEnabled(); // older compilers do not support the options we need to make it reproducible #if defined(__GNUC__) && ( ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 3) ) || (__GNUC__ >=4) ) @@ -942,10 +952,9 @@ int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments & if (-1 == ::unlink(jobs[0].outputFile().c_str())){ log_perror("unlink outputFile failed") << "\t" << jobs[0].outputFile() << endl; } - if (has_split_dwarf) { - string dwo_file = jobs[0].outputFile().substr(0, jobs[0].outputFile().find_last_of('.')) + ".dwo"; - if (-1 == ::unlink(dwo_file.c_str())){ - log_perror("unlink failed") << "\t" << dwo_file << endl; + for (auto i : job.outputFiles()) { + if (-1 == ::unlink(i.second.c_str())){ + log_perror("unlink failed") << "\t" << i.second << endl; } } exit_codes[0] = -1; // overwrite @@ -963,45 +972,32 @@ int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments & rename(jobs[0].outputFile().c_str(), (jobs[0].outputFile() + ".caught").c_str()); rename(preproc, (string(preproc) + ".caught").c_str()); - if (has_split_dwarf) { - string dwo_file = jobs[0].outputFile().substr(0, jobs[0].outputFile().find_last_of('.')) + ".dwo"; - rename(dwo_file.c_str(), (dwo_file + ".caught").c_str()); + for (auto i : job.outputFiles()) { + rename(i.second.c_str(), (i.second + ".caught").c_str()); } exit_codes[0] = -1; // overwrite break; } } - if (-1 == ::unlink(jobs[i].outputFile().c_str())){ - log_perror("unlink failed") << "\t" << jobs[i].outputFile() << endl; - } - if (has_split_dwarf) { - string dwo_file = jobs[i].outputFile().substr(0, jobs[i].outputFile().find_last_of('.')) + ".dwo"; - if (-1 == ::unlink(dwo_file.c_str())){ - log_perror("unlink failed") << "\t" << dwo_file << endl; + for (auto i : job.outputFiles()) { + if (-1 == ::unlink(i.second.c_str())){ + log_perror("unlink failed") << "\t" << i.second << endl; } } delete umsgs[i]; } } else { - if (-1 == ::unlink(jobs[0].outputFile().c_str())){ - log_perror("unlink failed") << "\t" << jobs[0].outputFile() << endl; - } - if (has_split_dwarf) { - string dwo_file = jobs[0].outputFile().substr(0, jobs[0].outputFile().find_last_of('.')) + ".dwo"; - if (-1 == ::unlink(dwo_file.c_str())){ - log_perror("unlink failed") << "\t" << dwo_file << endl; + for (auto i : job.outputFiles()) { + if (-1 == ::unlink(i.second.c_str())){ + log_perror("unlink failed") << "\t" << i.second << endl; } } for (int i = 1; i < torepeat; i++) { - if (-1 == ::unlink(jobs[i].outputFile().c_str())){ - log_perror("unlink failed") << "\t" << jobs[i].outputFile() << endl; - } - if (has_split_dwarf) { - string dwo_file = jobs[i].outputFile().substr(0, jobs[i].outputFile().find_last_of('.')) + ".dwo"; - if (-1 == ::unlink(dwo_file.c_str())){ - log_perror("unlink failed") << "\t" << dwo_file << endl; + for (auto i : job.outputFiles()) { + if (-1 == ::unlink(i.second.c_str())){ + log_perror("unlink failed") << "\t" << i.second << endl; } } delete umsgs[i]; diff --git a/configure.ac b/configure.ac index eb4e7c3e4..671b17b4e 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ if test "$GCC" = yes; then -Wshadow -Wpointer-arith $cast_align -Wwrite-strings \ -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes \ -Wnested-externs $CFLAGS" - CXXFLAGS=" -g -W -Wall -Wpointer-arith $cast_align $wshadow -Wwrite-strings $CXXFLAGS" + CXXFLAGS=" -std=gnu++11 -g -W -Wall -Wpointer-arith $cast_align $wshadow -Wwrite-strings $CXXFLAGS" AC_MSG_NOTICE([Adding gcc options: $CFLAGS]) fi diff --git a/daemon/serve.cpp b/daemon/serve.cpp index 815231a51..472a740cd 100644 --- a/daemon/serve.cpp +++ b/daemon/serve.cpp @@ -86,6 +86,7 @@ static void write_output_file( const string& file, MsgChannel* client ) int obj_fd = -1; try { obj_fd = open(file.c_str(), O_RDONLY | O_LARGEFILE); + log_info() << "Write output file " << file << endl; if (obj_fd == -1) { log_error() << "open failed" << endl; @@ -175,7 +176,7 @@ int handle_connection(const string &basedir, CompileJob *job, Msg *msg = 0; // The current read message unsigned int job_id = 0; - string tmp_path, obj_file, dwo_file; + string tmp_path, obj_file; try { if (job->environmentVersion().size()) { @@ -260,7 +261,6 @@ int handle_connection(const string &basedir, CompileJob *job, } obj_file = output_dir + '/' + file_name; - dwo_file = obj_file.substr(0, obj_file.find_last_of('.')) + ".dwo"; ret = work_it(*job, job_stat, client, rmsg, tmp_path, job_working_dir, relative_file_path, mem_limit, client->fd); } @@ -272,6 +272,23 @@ int handle_connection(const string &basedir, CompileJob *job, ret = work_it(*job, job_stat, client, rmsg, build_path, "", file_name, mem_limit, client->fd); } + // check the extra output files, even if error, seems gcno et can be before the error + // so the .o is removed ... but the others remain + for (uint32_t i=CompileJob::eExFile_START;i<=CompileJob::eExFile_END; i++) + { + std::string file; + struct stat st; + file = obj_file.substr(0, obj_file.find_last_of('.')) + CompileJob::ef_ext[i]; + /* this way we don't bother parsing any args ... + * but any file that exists ... we will send back + */ + //printf("try file ef[%d]= %s\n", i, file.c_str()); + if (!stat(file.c_str(), &st)) { + job_stat[JobStatistics::out_uncompressed] += st.st_size; + job->setExtraOutputFileRemote((CompileJob::ExFileEnum)i, file); + printf(" exists ef[%d]= %s\n", i, file.c_str()); + } + } if (ret) { if (ret == EXIT_OUT_OF_MEMORY) { // we catch that as special case @@ -281,18 +298,20 @@ int handle_connection(const string &basedir, CompileJob *job, } } - if (!client->send_msg(rmsg)) { - log_info() << "write of result failed" << endl; - throw myexception(EXIT_DISTCC_FAILED); - } struct stat st; if (!stat(obj_file.c_str(), &st)) { job_stat[JobStatistics::out_uncompressed] += st.st_size; } - if (!stat(dwo_file.c_str(), &st)) { - job_stat[JobStatistics::out_uncompressed] += st.st_size; + // old model + rmsg.have_dwo_file = job->dwarfFissionEnabled(); + // now ensure we set those in the message + rmsg.extra_files = job->ExtraOutputFiles(); + + if (!client->send_msg(rmsg)) { + log_info() << "write of result failed" << endl; + throw myexception(EXIT_DISTCC_FAILED); } /* wake up parent and tell him that compile finished */ @@ -303,10 +322,12 @@ int handle_connection(const string &basedir, CompileJob *job, } if (rmsg.status == 0) { - write_output_file(obj_file, client); - if (rmsg.have_dwo_file) { - write_output_file(dwo_file, client); + // reset the orig output file with the right one, then we can loop through them all + job->setOutputFile(obj_file); + for (auto i : job->outputFiles()) { + write_output_file(i.second, client); } + } throw myexception(rmsg.status); @@ -315,14 +336,10 @@ int handle_connection(const string &basedir, CompileJob *job, delete client; client = 0; - if (!obj_file.empty()) { - if (-1 == unlink(obj_file.c_str())){ - log_perror("unlink failure") << "\t" << obj_file << endl; - } - } - if (!dwo_file.empty()) { - if (-1 == unlink(dwo_file.c_str())){ - log_perror("unlink failure") << "\t" << dwo_file << endl; + job->setOutputFile(obj_file); + for (auto i : job->outputFiles()) { + if (-1 == unlink(i.second.c_str())){ + log_perror("unlink failure") << "\t" << i.second << endl; } } if (!tmp_path.empty()) { diff --git a/daemon/workit.cpp b/daemon/workit.cpp index 21caf2da1..51d3d837a 100644 --- a/daemon/workit.cpp +++ b/daemon/workit.cpp @@ -102,10 +102,6 @@ int work_it(CompileJob &j, unsigned int job_stat[], MsgChannel *client, CompileR std::list list = j.remoteFlags(); appendList(list, j.restFlags()); - if (j.dwarfFissionEnabled()) { - list.push_back("-gsplit-dwarf"); - } - int sock_err[2]; int sock_out[2]; int sock_in[2]; diff --git a/services/comm.cpp b/services/comm.cpp index 9cb796b06..2bfbf8bc0 100644 --- a/services/comm.cpp +++ b/services/comm.cpp @@ -1669,7 +1669,10 @@ void CompileFileMsg::fill_from_channel(MsgChannel *c) *c >> outputFile; *c >> dwarfFissionEnabled; job->setOutputFile(outputFile); - job->setDwarfFissionEnabled(dwarfFissionEnabled); + if (dwarfFissionEnabled) + { + job->setExtraOutputFileEnum(CompileJob::eExFile_dwarfFission); + } } } @@ -1770,7 +1773,15 @@ void CompileResultMsg::fill_from_channel(MsgChannel *c) uint32_t dwo = 0; *c >> dwo; have_dwo_file = dwo; + if (have_dwo_file) // cas with old daemon, and we're obviously a new client + { + extra_files = CompileJob::eExFile_dwarfFission; + } + } + if (IS_PROTOCOL_38(c)) { + *c >> extra_files; } + } void CompileResultMsg::send_to_channel(MsgChannel *c) const @@ -1783,6 +1794,10 @@ void CompileResultMsg::send_to_channel(MsgChannel *c) const if (IS_PROTOCOL_35(c)) { *c << (uint32_t) have_dwo_file; } + if (IS_PROTOCOL_38(c)) { + *c << extra_files; + } + } void JobBeginMsg::fill_from_channel(MsgChannel *c) diff --git a/services/comm.h b/services/comm.h index 9518e4526..fc82110a2 100644 --- a/services/comm.h +++ b/services/comm.h @@ -36,7 +36,7 @@ #include "job.h" // if you increase the PROTOCOL_VERSION, add a macro below and use that -#define PROTOCOL_VERSION 37 +#define PROTOCOL_VERSION 38 // if you increase the MIN_PROTOCOL_VERSION, comment out macros below and clean up the code #define MIN_PROTOCOL_VERSION 21 @@ -62,6 +62,7 @@ #define IS_PROTOCOL_35(c) ((c)->protocol >= 35) #define IS_PROTOCOL_36(c) ((c)->protocol >= 36) #define IS_PROTOCOL_37(c) ((c)->protocol >= 37) +#define IS_PROTOCOL_38(c) ((c)->protocol >= 38) enum MsgType { // so far unknown @@ -533,7 +534,8 @@ class CompileResultMsg : public Msg : Msg(M_COMPILE_RESULT) , status(0) , was_out_of_memory(false) - , have_dwo_file(false) {} + , have_dwo_file(false) + , extra_files(0) {} virtual void fill_from_channel(MsgChannel *c); virtual void send_to_channel(MsgChannel *c) const; @@ -543,6 +545,7 @@ class CompileResultMsg : public Msg std::string err; bool was_out_of_memory; bool have_dwo_file; + uint32_t extra_files; }; class JobBeginMsg : public Msg diff --git a/services/job.cpp b/services/job.cpp index ae01d4a1d..cd2695911 100644 --- a/services/job.cpp +++ b/services/job.cpp @@ -28,6 +28,15 @@ using namespace std; +const std::string CompileJob::ef_ext[] = { + {".xxx"}, // unused, can be .o or other stdout + {".dwo"}, + {".gcno"}, + {".i"}, + {".ii"}, + {".s"} +}; + list CompileJob::flags(Argument_Type argumentType) const { list args; diff --git a/services/job.h b/services/job.h index eab666697..e56dd01b2 100644 --- a/services/job.h +++ b/services/job.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -46,6 +47,7 @@ class ArgumentsList : public std::list > class CompileJob { public: + typedef std::map OutputFiles; typedef enum { Lang_C, Lang_CXX, @@ -62,9 +64,21 @@ class CompileJob Flag_Ol2 = 0x10 } Flag; + /* extra files are processed in this order */ + enum ExFileEnum { + eExFile_stdOutput = 0, // unused + eExFile_START = 1, + eExFile_dwarfFission = 1, + eExFile_coverage = 2, + eExFile_st_i = 3, + eExFile_st_ii = 4, + eExFile_st_s = 5, + eExFile_END = 5 + } ; + const static std::string ef_ext[]; + CompileJob() : m_id(0) - , m_dwarf_fission(false) { setTargetPlatform(); } @@ -132,22 +146,71 @@ class CompileJob void setOutputFile(const std::string &file) { - m_output_file = file; + m_output_files[0] = file; } std::string outputFile() const { - return m_output_file; + return m_output_files.at(0); } - void setDwarfFissionEnabled(bool flag) + const OutputFiles& outputFiles() const + { + return m_output_files; + } + + void setExtraOutputFile(uint32_t index, const std::string &file) + { + //printf("setExtraOutputFile[%d] = %s\n", index, file.c_str()); + m_output_files[index] = file; + } + std::string ExtraOutputFileExt(const std::string &ext) + { + std::string file = outputFile().substr(0, outputFile().find_last_of('.')) + ext; + return file; + } + void setExtraOutputFileExt(uint32_t index, const std::string &ext) + { + setExtraOutputFile(index, ExtraOutputFileExt(ext)); + } + void setExtraOutputFileEnum(ExFileEnum index) + { + setExtraOutputFileExt(index, ef_ext[index]); + } + void setExtraOutputFileRemote(ExFileEnum index, const std::string &file) + { + setExtraOutputFile(index, file); + m_extra_files |= (1 << index); + } + std::string ExtraOutputFileEnum(ExFileEnum index) { - m_dwarf_fission = flag; + return ExtraOutputFileExt(ef_ext[index]); + } + uint32_t ExtraOutputFiles() const + { + return m_extra_files; } bool dwarfFissionEnabled() const { - return m_dwarf_fission; + return m_output_files.find(eExFile_dwarfFission) != m_output_files.end(); + } + bool extraOutputEnabled() const + { + uint32_t c(0); + for (auto i : m_output_files) { + ++c; + } + + if (dwarfFissionEnabled()) { + if (c >= 3) { + return true; + } + } + else if (c >= 2) { + return true; + } + return false; } void setWorkingDirectory(const std::string& dir) @@ -195,10 +258,11 @@ class CompileJob std::string m_compiler_name; std::string m_environment_version; ArgumentsList m_flags; - std::string m_input_file, m_output_file; + std::string m_input_file; + uint32_t m_extra_files = 0; + OutputFiles m_output_files; std::string m_working_directory; std::string m_target_platform; - bool m_dwarf_fission; }; inline void appendList(std::list &list, const std::list &toadd) From cee58f7de92366519571acd1ded64712744e910f Mon Sep 17 00:00:00 2001 From: Ken Faiczak Date: Tue, 17 Oct 2017 23:13:23 -0400 Subject: [PATCH 2/7] make a few changes for the protocol 38 and a few log messages reowkr the -pipe in conjunction with -save-temps --- client/arg.cpp | 4 +- client/remote.cpp | 5 ++- daemon/serve.cpp | 2 +- daemon/workit.cpp | 18 ++++++-- tests/test.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 8 deletions(-) diff --git a/client/arg.cpp b/client/arg.cpp index d013eaf29..dce69d104 100644 --- a/client/arg.cpp +++ b/client/arg.cpp @@ -728,7 +728,7 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, listextra_files; + //log_info() << "extra_files: " << extra_files << std::endl; delete crmsg; assert(!job.outputFile().empty()); @@ -605,7 +606,7 @@ static int build_remote_int(CompileJob &job, UseCSMsg *usecs, MsgChannel *local_ if (extra_files & 0x01) { std::string file(job.ExtraOutputFileEnum((CompileJob::ExFileEnum)i)); - //printf("get extra file [%d] = %s\n", i, file.c_str()); + log_info() << "get extra file [" << i << "] = " << file << std::endl; receive_file(file, cserver); } } @@ -746,7 +747,7 @@ static int minimalRemoteVersion( const CompileJob& job) } if (job.extraOutputEnabled()) { - version = max(version, 37); + version = max(version, 38); } return version; diff --git a/daemon/serve.cpp b/daemon/serve.cpp index 472a740cd..85a5fcb34 100644 --- a/daemon/serve.cpp +++ b/daemon/serve.cpp @@ -286,7 +286,7 @@ int handle_connection(const string &basedir, CompileJob *job, if (!stat(file.c_str(), &st)) { job_stat[JobStatistics::out_uncompressed] += st.st_size; job->setExtraOutputFileRemote((CompileJob::ExFileEnum)i, file); - printf(" exists ef[%d]= %s\n", i, file.c_str()); + log_info() << " exists ef[" << i << "]= " << file << std::endl; } } diff --git a/daemon/workit.cpp b/daemon/workit.cpp index 51d3d837a..aad8009fe 100644 --- a/daemon/workit.cpp +++ b/daemon/workit.cpp @@ -242,21 +242,33 @@ int work_it(CompileJob &j, unsigned int job_stat[], MsgChannel *client, CompileR } bool hasPipe = false; + bool hasSaveTemps = false; + // we could ignore this, except the silly gcc-4.8 thing with tthe caret fails the tests due + // to having -pipe and -save-temps=obj for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { + if (*it == "-save-temps=obj") { + hasSaveTemps = true; + } + } + for (std::list::const_iterator it = list.begin(); + it != list.end(); ++it) { + bool ignore = false; if (*it == "-pipe") { hasPipe = true; + ignore = hasSaveTemps; + } + if (!ignore) { + argv[i++] = strdup(it->c_str()); } - - argv[i++] = strdup(it->c_str()); } if (!clang) { argv[i++] = strdup("-fpreprocessed"); } - if (!hasPipe) { + if (!hasPipe && !hasSaveTemps) { argv[i++] = strdup("-pipe"); } diff --git a/tests/test.sh b/tests/test.sh index 9bbb69b81..0d934ae54 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -84,6 +84,19 @@ if test -n "$debug_fission_disabled"; then skipped_tests="$skipped_tests split-dwarf(g++)" fi +coverage_disabled= +$GXX -E -fprofile-arcs -ftest-coverage messages.cpp 2>/dev/null >/dev/null || coverage_disabled=1 +if test -n "$coverage_disabled"; then + skipped_tests="$skipped_tests coverage(g++)" +fi + +save_temps_disabled= +$GXX -E -save-temps=obj messages.cpp 2>/dev/null >/dev/null || save_temps_disabled=1 +if test -n "$save_temps_disabled"; then + skipped_tests="$skipped_tests save_temps(g++)" +fi + + abort_tests() { for logfile in "$testdir"/*.log*; do @@ -311,6 +324,20 @@ run_ice() split_dwarf=$(echo $output | sed 's/\.[^.]*//g').dwo shift fi + coverage= + if test "$1" = "coverage"; then + coverage=$(echo $output | sed 's/\.[^.]*//g').gcno + shift + fi + save_temps_s= + save_temps_i= + save_temps_ii= + if test "$1" = "save_temps"; then + save_temps_i=$(echo $output | sed 's/\.[^.]*//g').i + save_temps_ii=$(echo $output | sed 's/\.[^.]*//g').ii + save_temps_s=$(echo $output | sed 's/\.[^.]*//g').s + shift + fi if [[ $expected_exit -gt 128 ]]; then $@ @@ -328,6 +355,14 @@ run_ice() if test -n "$split_dwarf"; then mv "$split_dwarf" "$split_dwarf".localice fi + if test -n "$coverage"; then + mv "$coverage" "$coverage".localice + fi + if test -n "$save_temps_s"; then + mv "$save_temps_s" "$save_temps_s".localice + mv "$save_temps_i" "$save_temps_i".localice 2>/dev/null + mv "$save_temps_ii" "$save_temps_ii".localice 2>/dev/null + fi cat "$testdir"/stderr.localice >> "$testdir"/stderr.log flush_logs check_logs_for_generic_errors @@ -354,6 +389,14 @@ run_ice() if test -n "$split_dwarf"; then mv "$split_dwarf" "$split_dwarf".remoteice fi + if test -n "$coverage"; then + mv "$coverage" "$coverage".remoteice + fi + if test -n "$save_temps_s"; then + mv "$save_temps_s" "$save_temps_s".remoteice + mv "$save_temps_i" "$save_temps_i".remoteice 2>/dev/null + mv "$save_temps_ii" "$save_temps_ii".remoteice 2>/dev/null + fi cat "$testdir"/stderr.remoteice >> "$testdir"/stderr.log flush_logs check_logs_for_generic_errors @@ -461,6 +504,38 @@ run_ice() fi fi fi + # not sure how these differ? seems some prefix, so just test they exist + if test -n "$coverage"; then + if test -s "$coverage".localice; then + if test -z "$chroot_disabled"; then + if ! test -s "$coverage".remoteice; then + echo "No coverage gcno file ($coverage.remoteice)" + stop_ice 0 + abort_tests + fi + fi + else + echo "No coverage gcno file ($coverage.localice)" + stop_ice 0 + abort_tests + fi + fi + # note thiese differ a bit based on the args passed to compiler + if test -n "$save_temps_s"; then + if test -s "$save_temps_s".localice; then + if test -z "$chroot_disabled"; then + if ! test -s "$save_temps_s".remoteice; then + echo "No assembler file file ($save_temps_s.remoteice)" + stop_ice 0 + abort_tests + fi + fi + else + echo "No assembler file file ($save_temps_s.localice)" + stop_ice 0 + abort_tests + fi + fi if test $localice_exit -ne 0; then echo "Command failed as expected." echo @@ -474,6 +549,14 @@ run_ice() if test -n "$split_dwarf"; then rm -f "$split_dwarf" "$split_dwarf".localice "$split_dwarf".remoteice "$split_dwarf".readelf.txt "$split_dwarf".local.readelf.txt "$split_dwarf".remote.readelf.txt fi + if test -n "$coverage"; then + rm -f "$coverage" "$coverage".localice "$coverage".remoteice + fi + if test -n "$save_temps_s"; then + rm -f "$save_temps_s" "$save_temps_s".localice "$save_temps_s".remoteice + rm -f "$save_temps_i" "$save_temps_i".localice "$save_temps_i".remoteice 2 Date: Wed, 18 Oct 2017 08:11:09 -0400 Subject: [PATCH 3/7] update a few variables that shadowed others (noticed in travis build) --- client/remote.cpp | 28 ++++++++++++++-------------- daemon/workit.cpp | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/remote.cpp b/client/remote.cpp index 584409533..56ac41a16 100644 --- a/client/remote.cpp +++ b/client/remote.cpp @@ -953,9 +953,9 @@ int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments & if (-1 == ::unlink(jobs[0].outputFile().c_str())){ log_perror("unlink outputFile failed") << "\t" << jobs[0].outputFile() << endl; } - for (auto i : job.outputFiles()) { - if (-1 == ::unlink(i.second.c_str())){ - log_perror("unlink failed") << "\t" << i.second << endl; + for (auto it : job.outputFiles()) { + if (-1 == ::unlink(it.second.c_str())){ + log_perror("unlink failed") << "\t" << it.second << endl; } } exit_codes[0] = -1; // overwrite @@ -973,32 +973,32 @@ int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments & rename(jobs[0].outputFile().c_str(), (jobs[0].outputFile() + ".caught").c_str()); rename(preproc, (string(preproc) + ".caught").c_str()); - for (auto i : job.outputFiles()) { - rename(i.second.c_str(), (i.second + ".caught").c_str()); + for (auto it : job.outputFiles()) { + rename(it.second.c_str(), (it.second + ".caught").c_str()); } exit_codes[0] = -1; // overwrite break; } } - for (auto i : job.outputFiles()) { - if (-1 == ::unlink(i.second.c_str())){ - log_perror("unlink failed") << "\t" << i.second << endl; + for (auto it : job.outputFiles()) { + if (-1 == ::unlink(it.second.c_str())){ + log_perror("unlink failed") << "\t" << it.second << endl; } } delete umsgs[i]; } } else { - for (auto i : job.outputFiles()) { - if (-1 == ::unlink(i.second.c_str())){ - log_perror("unlink failed") << "\t" << i.second << endl; + for (auto it : job.outputFiles()) { + if (-1 == ::unlink(it.second.c_str())){ + log_perror("unlink failed") << "\t" << it.second << endl; } } for (int i = 1; i < torepeat; i++) { - for (auto i : job.outputFiles()) { - if (-1 == ::unlink(i.second.c_str())){ - log_perror("unlink failed") << "\t" << i.second << endl; + for (auto it : job.outputFiles()) { + if (-1 == ::unlink(it.second.c_str())){ + log_perror("unlink failed") << "\t" << it.second << endl; } } delete umsgs[i]; diff --git a/daemon/workit.cpp b/daemon/workit.cpp index aad8009fe..2652bcbc9 100644 --- a/daemon/workit.cpp +++ b/daemon/workit.cpp @@ -254,12 +254,12 @@ int work_it(CompileJob &j, unsigned int job_stat[], MsgChannel *client, CompileR } for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { - bool ignore = false; + bool skip = false; if (*it == "-pipe") { hasPipe = true; - ignore = hasSaveTemps; + skip = hasSaveTemps; } - if (!ignore) { + if (!skip) { argv[i++] = strdup(it->c_str()); } } From 45da67928ddaae7f1de1bd86850ccd09135b580c Mon Sep 17 00:00:00 2001 From: Ken Faiczak Date: Wed, 18 Oct 2017 08:33:33 -0400 Subject: [PATCH 4/7] fixup issues with mac c++ though need to get rid of all using namespace std is better but for another commit --- daemon/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 8b050bcc1..70b049ab8 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -568,7 +568,7 @@ bool Daemon::setup_listen_fds() myaddr.sin_port = htons(daemon_port); myaddr.sin_addr.s_addr = INADDR_ANY; - if (bind(tcp_listen_fd, (struct sockaddr *)&myaddr, + if (::bind(tcp_listen_fd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { log_perror("bind()"); sleep(2); @@ -602,7 +602,7 @@ bool Daemon::setup_listen_fds() myaddr.sun_family = AF_UNIX; - mode_t old_umask = -1U; + mode_t old_umask = (mode_t)-1U; if (getenv("ICECC_TEST_SOCKET") == NULL) { #ifdef HAVE_LIBCAP_NG @@ -650,17 +650,17 @@ bool Daemon::setup_listen_fds() } } - if (bind(unix_listen_fd, (struct sockaddr*)&myaddr, sizeof(myaddr)) < 0) { + if (::bind(unix_listen_fd, (struct sockaddr*)&myaddr, sizeof(myaddr)) < 0) { log_perror("bind()"); - if (old_umask != -1U) { + if (old_umask != (mode_t)-1U) { umask(old_umask); } return false; } - if (old_umask != -1U) { + if (old_umask != (mode_t)-1U) { umask(old_umask); } From ca30b0f25cb98c8effd80c22c4db6487189fc524 Mon Sep 17 00:00:00 2001 From: Ken Faiczak Date: Wed, 18 Oct 2017 09:53:54 -0400 Subject: [PATCH 5/7] fixup more bind issues --- scheduler/scheduler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scheduler/scheduler.cpp b/scheduler/scheduler.cpp index 524e8c4fe..428ae549c 100755 --- a/scheduler/scheduler.cpp +++ b/scheduler/scheduler.cpp @@ -1701,7 +1701,7 @@ static int open_broad_listener(int port) myaddr.sin_port = htons(port); myaddr.sin_addr.s_addr = INADDR_ANY; - if (bind(listen_fd, (struct sockaddr *) &myaddr, sizeof(myaddr)) < 0) { + if (::bind(listen_fd, (struct sockaddr *) &myaddr, sizeof(myaddr)) < 0) { log_perror("bind()"); return -1; } @@ -1738,7 +1738,7 @@ static int open_tcp_listener(short port) myaddr.sin_port = htons(port); myaddr.sin_addr.s_addr = INADDR_ANY; - if (bind(fd, (struct sockaddr *) &myaddr, sizeof(myaddr)) < 0) { + if (::bind(fd, (struct sockaddr *) &myaddr, sizeof(myaddr)) < 0) { log_perror("bind()"); return -1; } From b67a60d81475dc532da22c0711c2a821ffa8a3e0 Mon Sep 17 00:00:00 2001 From: Ken Faiczak Date: Wed, 18 Oct 2017 12:20:52 -0400 Subject: [PATCH 6/7] update typo in comment and static cast on broken mode_t for mac/c++ vs C-cast --- daemon/main.cpp | 4 ++-- daemon/workit.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 70b049ab8..c542ab9da 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -602,7 +602,7 @@ bool Daemon::setup_listen_fds() myaddr.sun_family = AF_UNIX; - mode_t old_umask = (mode_t)-1U; + mode_t old_umask = static_cast(-1U); if (getenv("ICECC_TEST_SOCKET") == NULL) { #ifdef HAVE_LIBCAP_NG @@ -653,7 +653,7 @@ bool Daemon::setup_listen_fds() if (::bind(unix_listen_fd, (struct sockaddr*)&myaddr, sizeof(myaddr)) < 0) { log_perror("bind()"); - if (old_umask != (mode_t)-1U) { + if (old_umask != static_cast(-1U)) { umask(old_umask); } diff --git a/daemon/workit.cpp b/daemon/workit.cpp index 2652bcbc9..a729c61f3 100644 --- a/daemon/workit.cpp +++ b/daemon/workit.cpp @@ -244,7 +244,7 @@ int work_it(CompileJob &j, unsigned int job_stat[], MsgChannel *client, CompileR bool hasPipe = false; bool hasSaveTemps = false; - // we could ignore this, except the silly gcc-4.8 thing with tthe caret fails the tests due + // we could ignore this, except the silly gcc-4.8 thing with the caret fails the tests due // to having -pipe and -save-temps=obj for (std::list::const_iterator it = list.begin(); it != list.end(); ++it) { From 3d2f477320ecc044d0ad87332945595923898628 Mon Sep 17 00:00:00 2001 From: Ken Faiczak Date: Mon, 22 Jan 2018 11:43:25 -0500 Subject: [PATCH 7/7] update to latest protocol and fix other issues --- client/arg.cpp | 2 +- client/remote.cpp | 2 +- services/comm.cpp | 4 ++-- services/comm.h | 3 ++- services/job.h | 1 - tests/test.sh | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/arg.cpp b/client/arg.cpp index dce69d104..d9a3313e0 100644 --- a/client/arg.cpp +++ b/client/arg.cpp @@ -727,7 +727,7 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, list> extra_files; } @@ -1794,7 +1794,7 @@ void CompileResultMsg::send_to_channel(MsgChannel *c) const if (IS_PROTOCOL_35(c)) { *c << (uint32_t) have_dwo_file; } - if (IS_PROTOCOL_38(c)) { + if (IS_PROTOCOL_39(c)) { *c << extra_files; } diff --git a/services/comm.h b/services/comm.h index fc82110a2..8855bd8ff 100644 --- a/services/comm.h +++ b/services/comm.h @@ -36,7 +36,7 @@ #include "job.h" // if you increase the PROTOCOL_VERSION, add a macro below and use that -#define PROTOCOL_VERSION 38 +#define PROTOCOL_VERSION 39 // if you increase the MIN_PROTOCOL_VERSION, comment out macros below and clean up the code #define MIN_PROTOCOL_VERSION 21 @@ -63,6 +63,7 @@ #define IS_PROTOCOL_36(c) ((c)->protocol >= 36) #define IS_PROTOCOL_37(c) ((c)->protocol >= 37) #define IS_PROTOCOL_38(c) ((c)->protocol >= 38) +#define IS_PROTOCOL_39(c) ((c)->protocol >= 39) enum MsgType { // so far unknown diff --git a/services/job.h b/services/job.h index e56dd01b2..c4b69622e 100644 --- a/services/job.h +++ b/services/job.h @@ -161,7 +161,6 @@ class CompileJob void setExtraOutputFile(uint32_t index, const std::string &file) { - //printf("setExtraOutputFile[%d] = %s\n", index, file.c_str()); m_output_files[index] = file; } std::string ExtraOutputFileExt(const std::string &ext) diff --git a/tests/test.sh b/tests/test.sh index 0d934ae54..876b738ca 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -520,7 +520,7 @@ run_ice() abort_tests fi fi - # note thiese differ a bit based on the args passed to compiler + # note these differ a bit based on the args passed to compiler if test -n "$save_temps_s"; then if test -s "$save_temps_s".localice; then if test -z "$chroot_disabled"; then