From: John Ravi Date: Sat, 29 Aug 2020 07:06:28 +0000 (+0000) Subject: 1. renamed libcody lto functions to invoke functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eebf96f8710cb03aac7e3572bf2a7e5a603c9ec;p=thirdparty%2Fgcc.git 1. renamed libcody lto functions to invoke functions 2. invoke (send to libcody) all the lto trans commands at once --- diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 60ed3192c86d..516c6217c29c 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -1919,6 +1919,8 @@ cont: } auto *mapper = get_mapper (main_source_loc); + mapper->Cork(); + /* Execute the LTRANS stage for each input file (or prepare a makefile to invoke this in parallel). */ for (i = 0; i < nr; ++i) @@ -1962,55 +1964,42 @@ cont: } else { - //fprintf(stderr, "\tRAVI PRINT: %s ", new_argv[0]); - mapper->Cork(); - // TODO: better way to figure out the number of arguments? for (j = 1; new_argv[j] != NULL; ++j); fprintf(stderr, "argc: %d\n", j); - //std::vector v_new_argv(new_argv, new_argv + j); - //mapper->LTOCompile(v_new_argv); - mapper->LTOCompile(new_argv, j); - const char **arg_it = new_argv + 1; - - while(*arg_it != NULL) - { - //fprintf(stderr, "\tRAVI PRINT: %s\n", *arg_it); - fprintf(stderr, " \'%s\' ", *arg_it); - //mapper->LTOCompile(*arg_it); - arg_it++; - } - ////fprintf(stderr, "\n"); - auto response = mapper->Uncork(); - auto r_iter = response.begin (); - - while(r_iter != response.end()) { - Cody::Packet const &p = *r_iter; - - if(p.GetCode() == Cody::Client::PC_LTO_COMPILED) { - if(strcmp(p.GetString().c_str(), "success") == 0) { - // fprintf(stderr, "\tlto compilation succeeded\n"); - } - else { - fprintf(stderr, "\tlto compilation failure message: %s\n", p.GetString().c_str()); - } - } - else { - fprintf(stderr, "\tlto compilation unknown failure\n"); - } - - ++r_iter; - } - - //fprintf(stderr, "\tRAVI PRINT: %s\n", new_argv[0]); - //fork_execute (new_argv[0], CONST_CAST (char **, new_argv), - // true); - maybe_unlink (input_name); + mapper->InvokeSubProcess(new_argv, j); + + // TODO: unlink input file somewhere + // maybe_unlink (input_name); } output_names[i] = output_name; } + + auto response = mapper->Uncork(); + auto r_iter = response.begin (); + + while(r_iter != response.end()) { + Cody::Packet const &p = *r_iter; + + if(p.GetCode() == Cody::Client::PC_INVOKED) { + if(strcmp(p.GetString().c_str(), "success") == 0) { + fprintf(stderr, "\tlto compilation succeeded\n"); + } + else { + fprintf(stderr, "\tlto compilation failure message: %s\n", p.GetString().c_str()); + } + } + else { + fprintf(stderr, "\tlto compilation unknown failure\n"); + } + + ++r_iter; + } + + fprintf(stderr, "\n"); + if (parallel) { struct pex_obj *pex; diff --git a/gcc/mapper-resolver.cc b/gcc/mapper-resolver.cc index 35de17d1db20..d8e1b57afc79 100644 --- a/gcc/mapper-resolver.cc +++ b/gcc/mapper-resolver.cc @@ -244,14 +244,14 @@ module_resolver::IncludeTranslateRequest (Cody::Server *s, return 0; } -int module_resolver::LTOCompileRequest (Cody::Server *s, std::vector &args) { +int module_resolver::InvokeSubProcessRequest (Cody::Server *s, std::vector &args) { char **new_argv = (char **)malloc((args.size()) * sizeof(char *)); new_argv[args.size()-1] = NULL; int i = 0; for (std::vector::iterator arg = args.begin() ; arg != args.end(); ++arg, ++i) { - // ignore "LTO-COMPILE" + // ignore "INVOKE" if(i == 0) continue; //new_argv[i++] = (char *)malloc(args[i].length() * sizeof(char)); @@ -265,7 +265,7 @@ int module_resolver::LTOCompileRequest (Cody::Server *s, std::vectorLTOResponse("success"); + s->InvokedResponse("success"); return 0; } diff --git a/gcc/mapper.h b/gcc/mapper.h index 306ee5cccb60..49118d123bc1 100644 --- a/gcc/mapper.h +++ b/gcc/mapper.h @@ -78,7 +78,7 @@ public: virtual int IncludeTranslateRequest (Cody::Server *s, std::string &include) override; - virtual int LTOCompileRequest (Cody::Server *s, std::vector &args) + virtual int InvokeSubProcessRequest (Cody::Server *s, std::vector &args) override; private: