From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 78F8F3857C53 for ; Tue, 14 Jul 2020 05:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 78F8F3857C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oliva@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4FFC95645C; Tue, 14 Jul 2020 01:46:44 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hpFbfh27sjFA; Tue, 14 Jul 2020 01:46:44 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id D661C56419; Tue, 14 Jul 2020 01:46:43 -0400 (EDT) Received: from livre.home (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 06E5kWkj1360538 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jul 2020 02:46:33 -0300 From: Alexandre Oliva To: Thomas Schwinge Cc: Tobias Burnus , Jakub Jelinek , Richard Biener , , , Subject: Re: drop -aux{dir,base}, revamp -dump{dir,base} Organization: Free thinker, does not speak for AdaCore References: <874krkqte6.fsf@euler.schwinge.homeip.net> <87bll0zg3e.fsf@euler.schwinge.homeip.net> Errors-To: aoliva@lxoliva.fsfla.org Date: Tue, 14 Jul 2020 02:46:32 -0300 In-Reply-To: <87bll0zg3e.fsf@euler.schwinge.homeip.net> (Thomas Schwinge's message of "Tue, 30 Jun 2020 18:13:57 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2020 05:46:46 -0000 On Jun 30, 2020, Thomas Schwinge wrote: >>> I looked for a mkoffload >>> program for it in the GCC source tree and couldn't find one. > See 'gcc/config/i386/intelmic-mkoffload.c'. ;-) Thanks! > :-) Yes, I quickly tested, and found that similar changes are required > there, too. > Can you easily adjust that file as you did for the GCN and nvptx > 'mkoffload's? Due to other workload, resolving it myself would be very > low priority for me, I'm afraid. (But I can easily test anything anybody > else comes up with.) Thanks for the offer. Here's what I've been able to come up with, totally untested. Ok to install after you give it a spin? revamp intelmic-mkoffload aux dump names From: Alexandre Oliva Rework intelmic-mkoffload into the new aux and dump file naming semantics. Obey -save-temps. for gcc/ChangeLog * config/i386/intelmic-mkoffload.c (generate_target_descr_file): Use dumppfx for save_temps files. Pass -dumpbase et al down to the compiler. (generate_target_offloadend_file): Likewise. (generate_host_descr_file): Likewise. (prepare_target_image): Likewise. Move out_obj_filename setting... (main): ... here. Detect -dumpbase, set dumppfx too. --- gcc/config/i386/intelmic-mkoffload.c | 72 +++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c index e108bc0..52c06b9 100644 --- a/gcc/config/i386/intelmic-mkoffload.c +++ b/gcc/config/i386/intelmic-mkoffload.c @@ -245,8 +245,13 @@ compile_for_target (struct obstack *argv_obstack) static const char * generate_target_descr_file (const char *target_compiler) { - const char *src_filename = make_temp_file ("_target_descr.c"); - const char *obj_filename = make_temp_file ("_target_descr.o"); + char *dump_filename = concat (dumppfx, "_target_descr.c", NULL); + const char *src_filename = save_temps + ? dump_filename + : make_temp_file ("_target_descr.c"); + const char *obj_filename = save_temps + ? concat (dumppfx, "_target_descr.o", NULL) + : make_temp_file ("_target_descr.o"); temp_files[num_temps++] = src_filename; temp_files[num_temps++] = obj_filename; FILE *src_file = fopen (src_filename, "w"); @@ -293,6 +298,12 @@ generate_target_descr_file (const char *target_compiler) obstack_ptr_grow (&argv_obstack, "-save-temps"); if (verbose) obstack_ptr_grow (&argv_obstack, "-v"); + obstack_ptr_grow (&argv_obstack, "-dumpdir"); + obstack_ptr_grow (&argv_obstack, ""); + obstack_ptr_grow (&argv_obstack, "-dumpbase"); + obstack_ptr_grow (&argv_obstack, dump_filename); + obstack_ptr_grow (&argv_obstack, "-dumpbase-ext"); + obstack_ptr_grow (&argv_obstack, ".c"); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-shared"); obstack_ptr_grow (&argv_obstack, "-fPIC"); @@ -309,8 +320,13 @@ generate_target_descr_file (const char *target_compiler) static const char * generate_target_offloadend_file (const char *target_compiler) { - const char *src_filename = make_temp_file ("_target_offloadend.c"); - const char *obj_filename = make_temp_file ("_target_offloadend.o"); + char *dump_filename = concat (dumppfx, "_target_offloadend.c", NULL); + const char *src_filename = save_temps + ? dmp_filename + : make_temp_file ("_target_offloadend.c"); + const char *obj_filename = save_temps + ? concat (dumppfx, "_target_offloadend.o", NULL) + : make_temp_file ("_target_offloadend.o"); temp_files[num_temps++] = src_filename; temp_files[num_temps++] = obj_filename; FILE *src_file = fopen (src_filename, "w"); @@ -335,6 +351,12 @@ generate_target_offloadend_file (const char *target_compiler) obstack_ptr_grow (&argv_obstack, "-save-temps"); if (verbose) obstack_ptr_grow (&argv_obstack, "-v"); + obstack_ptr_grow (&argv_obstack, "-dumpdir"); + obstack_ptr_grow (&argv_obstack, ""); + obstack_ptr_grow (&argv_obstack, "-dumpbase"); + obstack_ptr_grow (&argv_obstack, dump_filename); + obstack_ptr_grow (&argv_obstack, "-dumpbase-ext"); + obstack_ptr_grow (&argv_obstack, ".c"); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-shared"); obstack_ptr_grow (&argv_obstack, "-fPIC"); @@ -350,8 +372,13 @@ generate_target_offloadend_file (const char *target_compiler) static const char * generate_host_descr_file (const char *host_compiler) { - const char *src_filename = make_temp_file ("_host_descr.c"); - const char *obj_filename = make_temp_file ("_host_descr.o"); + char *dump_filename = concat (dumppfx, "_host_descr.c", NULL); + const char *src_filename = save_temps + ? dmp_filename + : make_temp_file ("_host_descr.c"); + const char *obj_filename = save_temps + ? concat (dumppfx, "_host_descr.o", NULL) + : make_temp_file ("_host_descr.o"); temp_files[num_temps++] = src_filename; temp_files[num_temps++] = obj_filename; FILE *src_file = fopen (src_filename, "w"); @@ -402,6 +429,12 @@ generate_host_descr_file (const char *host_compiler) obstack_ptr_grow (&argv_obstack, "-save-temps"); if (verbose) obstack_ptr_grow (&argv_obstack, "-v"); + obstack_ptr_grow (&argv_obstack, "-dumpdir"); + obstack_ptr_grow (&argv_obstack, ""); + obstack_ptr_grow (&argv_obstack, "-dumpbase"); + obstack_ptr_grow (&argv_obstack, dump_filename); + obstack_ptr_grow (&argv_obstack, "-dumpbase-ext"); + obstack_ptr_grow (&argv_obstack, ".c"); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-fPIC"); obstack_ptr_grow (&argv_obstack, "-shared"); @@ -443,7 +476,10 @@ prepare_target_image (const char *target_compiler, int argc, char **argv) sprintf (opt1, "-Wl,%s", target_descr_filename); sprintf (opt2, "-Wl,%s", target_offloadend_filename); - const char *target_so_filename = make_temp_file ("_offload_intelmic.so"); + char *dump_filename = concat (dumppfx, ".mkoffload", NULL); + const char *target_so_filename = save_temps + ? concat (dumppfx, "_offload_intelmic.so", NULL) + : make_temp_file ("_offload_intelmic.so"); temp_files[num_temps++] = target_so_filename; struct obstack argv_obstack; obstack_init (&argv_obstack); @@ -452,17 +488,21 @@ prepare_target_image (const char *target_compiler, int argc, char **argv) obstack_ptr_grow (&argv_obstack, "-save-temps"); if (verbose) obstack_ptr_grow (&argv_obstack, "-v"); + obstack_ptr_grow (&argv_obstack, "-dumpdir"); + obstack_ptr_grow (&argv_obstack, ""); + obstack_ptr_grow (&argv_obstack, "-dumpbase"); + obstack_ptr_grow (&argv_obstack, dump_filename); + obstack_ptr_grow (&argv_obstack, "-dumpbase-ext"); + obstack_ptr_grow (&argv_obstack, ""); obstack_ptr_grow (&argv_obstack, "-xlto"); obstack_ptr_grow (&argv_obstack, opt1); for (int i = 1; i < argc; i++) { if (!strcmp (argv[i], "-o") && i + 1 != argc) - out_obj_filename = argv[++i]; + ++i; else obstack_ptr_grow (&argv_obstack, argv[i]); } - if (!out_obj_filename) - fatal_error (input_location, "output file not specified"); obstack_ptr_grow (&argv_obstack, opt2); /* NB: Put -fPIC and -shared the last to create shared library. */ obstack_ptr_grow (&argv_obstack, "-fPIC"); @@ -589,8 +629,20 @@ main (int argc, char **argv) save_temps = true; else if (strcmp (argv[i], "-v") == 0) verbose = true; + else if (strcmp (argv[i], "-dumpbase") == 0 + && i + 1 < argc) + dumppfx = argv[++i]; + else if (strcmp (argv[i], "-o") == 0 + && i + 1 < argc) + out_obj_filename = argv[++i]; } + if (!out_obj_filename) + fatal_error (input_location, "output file not specified"); + + if (!dumppfx) + dumppfx = out_obj_filename; + const char *target_so_filename = prepare_target_image (target_compiler, argc, argv); -- Alexandre Oliva, freedom fighter he/him https://FSFLA.org/blogs/lxo/ Free Software Evangelist Stallman was right, but he's left :( GNU Toolchain Engineer Live long and free, and prosper ethically