From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 72C02385772D for ; Fri, 15 Sep 2023 09:41:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72C02385772D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-CSE-ConnectionGUID: 4lE6gpY7S5eyajgrh508sQ== X-CSE-MsgGUID: wKWRZukgQqKzCTpqt7MbWA== X-IronPort-AV: E=Sophos;i="6.02,148,1688457600"; d="scan'208";a="16967438" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 15 Sep 2023 01:41:48 -0800 IronPort-SDR: KEaYOUN7uMxHUHI5TlISgXfYfSpNTc66fBc0YkK/lyeCExrhHvrVHWHSqaqoXzDXFdooSQN79P TiTq75pVsLmWfU0sRuwSFAbe9oMDefqFzT/na0HuFmtQVnPVpDrpF15xslCcutyA7N9Xon01xs 4srzNk7Vx7gN3ffm4a4zV2oWrNfvM6EKIp3VS1GLavr19vv45S6J4X+P7Im92LctU1oHTJ1LKs FBGlzyVcU6TtkfKrBtFaLA5NlcJaGprJEJ68jx1F4E+L+JwR0WMEpTZHEsyPSq4Lyfl/3j3kjb RpY= From: Thomas Schwinge To: Tobias Burnus , Jakub Jelinek CC: Subject: Re: [Patch][v5] OpenMP: Move omp requires checks to libgomp In-Reply-To: <16ca2aa4-7e73-cf9d-9482-dd59f5b0cdae@codesourcery.com> References: <07fec82a-41cf-fdc5-6307-c068dd95ef1a@mentor.com> <7f9c91c1-a479-f94f-ac14-1d6827ce671b@codesourcery.com> <5576fa00-0ddd-8046-17c1-d1cea82bdcf5@codesourcery.com> <77331328-4961-9dab-db58-b5b03daf218c@codesourcery.com> <16ca2aa4-7e73-cf9d-9482-dd59f5b0cdae@codesourcery.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Fri, 15 Sep 2023 11:41:36 +0200 Message-ID: <87h6nvydrj.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! On 2022-07-01T15:06:05+0200, Tobias Burnus wrote: > OpenMP: Move omp requires checks to libgomp This became commit r13-1458-g683f11843974f0bdf42f79cdcbb0c2b43c7b81b0 "OpenMP: Move omp requires checks to libgomp". As of this, when I need to debug an offloading-compilation ICE, for example, and start with 'gcc -save-temps -v', I can no longer just re-run the offloading-compilation's 'lto1' invocation, because: $ [...]/gcc/lto1 [...] -foffload-abi=3Dlp64 -fopenmp [...] [...] lto1: fatal error: GCC_OFFLOAD_OMP_REQUIRES_FILE unset compilation terminated. That's because I missed setting the environment variable: GCC_OFFLOAD_OMP_REQUIRES_FILE=3D./declare-variant-1.xnvptx-none.mkofflo= ad.omp_requires ..., which appears a number of lines earlier in the '-v' log. Couldn't we easily overcome this issue by turning the environment variable 'GCC_OFFLOAD_OMP_REQUIRES_FILE' into some new internal-use command-line flag, like '-foffload-abi'? That is, communication mechanics via '[...].mkoffload.omp_requires' files would stay the same, just how we communicate the file name changes: command-line flag instead of environment variable. For reference: > --- a/gcc/config/gcn/mkoffload.cc > +++ b/gcc/config/gcn/mkoffload.cc > @@ -1077,9 +1080,27 @@ main (int argc, char **argv) > unsetenv ("COMPILER_PATH"); > unsetenv ("LIBRARY_PATH"); > > + char *omp_requires_file; > + if (save_temps) > + omp_requires_file =3D concat (dumppfx, ".mkoffload.omp_requires", N= ULL); > + else > + omp_requires_file =3D make_temp_file (".mkoffload.omp_requires"); > + > /* Run the compiler pass. */ > + xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=3D", omp_requires_= file, NULL)); > fork_execute (cc_argv[0], CONST_CAST (char **, cc_argv), true, ".g= cc_args"); > obstack_free (&cc_argv_obstack, NULL); > + unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE"); > + > + in =3D fopen (omp_requires_file, "rb"); > + if (!in) > + fatal_error (input_location, "cannot open omp_requires file %qs", > + omp_requires_file); > + uint32_t omp_requires; > + if (fread (&omp_requires, sizeof (omp_requires), 1, in) !=3D 1) > + fatal_error (input_location, "cannot read omp_requires file %qs", > + omp_requires_file); > + fclose (in); > --- a/gcc/config/nvptx/mkoffload.cc > +++ b/gcc/config/nvptx/mkoffload.cc > @@ -583,19 +586,37 @@ main (int argc, char **argv) > unsetenv ("COMPILER_PATH"); > unsetenv ("LIBRARY_PATH"); > > + char *omp_requires_file; > + if (save_temps) > + omp_requires_file =3D concat (dumppfx, ".mkoffload.omp_requires", N= ULL); > + else > + omp_requires_file =3D make_temp_file (".mkoffload.omp_requires"); > + > + xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=3D", omp_requires_= file, NULL)); > fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true, > ".gcc_args"); > obstack_free (&argv_obstack, NULL); > + unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE"); > > xputenv (concat ("GCC_EXEC_PREFIX=3D", execpath, NULL)); > xputenv (concat ("COMPILER_PATH=3D", cpath, NULL)); > xputenv (concat ("LIBRARY_PATH=3D", lpath, NULL)); > > + in =3D fopen (omp_requires_file, "rb"); > + if (!in) > + fatal_error (input_location, "cannot open omp_requires file %qs", > + omp_requires_file); > + uint32_t omp_requires; > + if (fread (&omp_requires, sizeof (omp_requires), 1, in) !=3D 1) > + fatal_error (input_location, "cannot read omp_requires file %qs", > + omp_requires_file); > + fclose (in); > --- a/gcc/lto-cgraph.cc > +++ b/gcc/lto-cgraph.cc > @@ -1821,6 +1906,18 @@ input_offload_tables (bool do_force_output) > lto_destroy_simple_input_block (file_data, LTO_section_offload_tab= le, > ib, data, len); > } > +#ifdef ACCEL_COMPILER > + char *omp_requires_file =3D getenv ("GCC_OFFLOAD_OMP_REQUIRES_FILE"); > + if (omp_requires_file =3D=3D NULL || omp_requires_file[0] =3D=3D '\0') > + fatal_error (input_location, "GCC_OFFLOAD_OMP_REQUIRES_FILE unset"); > + FILE *f =3D fopen (omp_requires_file, "wb"); > + if (!f) > + fatal_error (input_location, "Cannot open omp_requires file %qs", > + omp_requires_file); > + uint32_t req_mask =3D omp_requires_mask & ~OMP_REQUIRES_TARGET_USED; > + fwrite (&req_mask, sizeof (req_mask), 1, f); > + fclose (f); > +#endif > } Gr=C3=BC=C3=9Fe Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955