Re: [Patch] offload-defaulted: Config option to silently ignore uninstalled offload compilers
On Wed, Apr 28, 2021 at 06:56:37PM +0200, Tobias Burnus wrote: > On 28.04.21 16:13, Matthias Klose wrote: > > > On 4/27/21 12:22 PM, Tobias Burnus wrote: > > > Hence, the distro behaviour is only active when configured with > > > --enable-offload-defaulted. > > please document that option in gcc/doc/install.texi. > > Like attached? Or do you have some other wording suggestions? > > Tobias > > - > Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München > Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank > Thürauf > doc/install.texi: Document --enable-offload-defaulted config option > > Document configure --enable-offload-defaulted option added in > commit r12-218-gfe5bfa6704179f8db7d1ae0b485439e9896df8eb > > gcc/ChangeLog: > > * doc/install.texi (--enable-offload-defaulted): Document. > > diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi > index 4c38244ae58..e5e26571eb1 100644 > --- a/gcc/doc/install.texi > +++ b/gcc/doc/install.texi > @@ -2239,6 +2239,12 @@ specifying paths @var{path1}, @dots{}, @var{pathN}. > > --enable-offload-targets=x86_64-intelmicemul-linux-gnu=/path/to/x86_64/compiler,nvptx-none > @end smallexample > > +@item --enable-offload-defaulted > + > +Tell GCC that configured but not installed offload compilers and libgomp > +plugins are silently ignored. Useful for distribution compilers where > +those are in separate optional packages. I'd add at the end "and where the presence or absence of those optional packages should determine the actual supported offloading target set rather than the GCC configure time selection". LGTM otherwise. Jakub
Re: [Patch] offload-defaulted: Config option to silently ignore uninstalled offload compilers
On 4/28/21 6:56 PM, Tobias Burnus wrote: > On 28.04.21 16:13, Matthias Klose wrote: > >> On 4/27/21 12:22 PM, Tobias Burnus wrote: >>> Hence, the distro behaviour is only active when configured with >>> --enable-offload-defaulted. >> please document that option in gcc/doc/install.texi. > > Like attached? Or do you have some other wording suggestions? looks fine.
Re: [Patch] offload-defaulted: Config option to silently ignore uninstalled offload compilers
On 28.04.21 16:13, Matthias Klose wrote: On 4/27/21 12:22 PM, Tobias Burnus wrote: Hence, the distro behaviour is only active when configured with --enable-offload-defaulted. please document that option in gcc/doc/install.texi. Like attached? Or do you have some other wording suggestions? Tobias - Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf doc/install.texi: Document --enable-offload-defaulted config option Document configure --enable-offload-defaulted option added in commit r12-218-gfe5bfa6704179f8db7d1ae0b485439e9896df8eb gcc/ChangeLog: * doc/install.texi (--enable-offload-defaulted): Document. diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 4c38244ae58..e5e26571eb1 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -2239,6 +2239,12 @@ specifying paths @var{path1}, @dots{}, @var{pathN}. --enable-offload-targets=x86_64-intelmicemul-linux-gnu=/path/to/x86_64/compiler,nvptx-none @end smallexample +@item --enable-offload-defaulted + +Tell GCC that configured but not installed offload compilers and libgomp +plugins are silently ignored. Useful for distribution compilers where +those are in separate optional packages. + @item --with-hsa-runtime=@var{pathname} @itemx --with-hsa-runtime-include=@var{pathname} @itemx --with-hsa-runtime-lib=@var{pathname}
Re: [Patch] offload-defaulted: Config option to silently ignore uninstalled offload compilers
On 4/27/21 12:22 PM, Tobias Burnus wrote: > This is based on Jakub's patch* which is used with many distributions – and > is has > to be maintained by all of them; otherwise issues like lp #1878760 might > creep in, > as discussed in #gcc yesterday. - As I am a huge fan of reducing code > duplication > and local patches, I propose to add it to GCC proper behind a configure flag. > > The patch idea is: offloading support is configured for one or multiple > offload > devices > but compilation silently ignores a target if its offload compiler is not > found at > compile time and also dlopen errors of the associated libgomp plugin is also > silently ignored such that also the system where the program is run do not > show > a run-time error. > > This makes a lot of sense for distribution compilers – as it permits to > configure > GCC to support offloading to one/multiple offload targets, but the actual > offload compiler and the run-time support can be put into separate, optional > packages. > > (When -foffload=$TARGET is specified explicitly, it still gives > an error if the offload compiler is not installed; this does not not affect > the > libgomp/run-time side.) > > However, for nondistro builds, compilers are usually installed "as is" and not > split into different packages – thus, compilation or run-time issues should > give > an error. > > Hence, the distro behaviour is only active when configured with > --enable-offload-defaulted. > > Comments? OK for mainline? please document that option in gcc/doc/install.texi. Matthias
Re: [Patch] offload-defaulted: Config option to silently ignore uninstalled offload compilers
On Tue, Apr 27, 2021 at 12:22:44PM +0200, Tobias Burnus wrote: > If configured with --enable-offload-defaulted, configured but not installed > offload compilers and libgomp plugins are silently ignored. Useful for > distribution compilers where those are in separate optional packages. > > 2021-04-27 Jakub Jelinek > Tobias Burnus > > ChangeLog: > > * configure.ac (--enable-offload-defaulted): New. > * configure: Regenerate. > > gcc/ChangeLog: > > * configure.ac (OFFLOAD_DEFAULTED): AC_DEFINE if offload-defaulted. > * gcc.c (process_command): New variable. > (driver::maybe_putenv_OFFLOAD_TARGETS): If OFFLOAD_DEFAULTED, > set it if -foffload is defaulted. > * lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define. > (compile_offload_image): If OFFLOAD_DEFAULTED and > OFFLOAD_TARGET_DEFAULT is in the environment, don't fail > if corresponding mkoffload can't be found. > (compile_images_for_offload_targets): Likewise. Free and clear > offload_names if no valid offload is found. > * config.in: Regenerate. > * configure: Regenerate. > > libgomp/ChangeLog: > > * configure.ac (OFFLOAD_DEFAULTED): AC_DEFINE if offload-defaulted. > * target.c (gomp_load_plugin_for_device): If set and if a plugin > can't be dlopened, silently assume it has no devices. > * Makefile.in: Regenerate. > * config.h.in: Regenerate. > * configure: Regenerate. > > lto-plugin/ChangeLog: > > * Makefile.in: Regenerate. > * configure: Regenerate. > > zlib/ChangeLog: > > * configure: Regenerate. I would probably not regenerate configure/Makefiles that haven't been touched, so lto-plugin/* and zlib/* above. Otherwise LGTM. Jakub
[Patch] offload-defaulted: Config option to silently ignore uninstalled offload compilers
This is based on Jakub's patch* which is used with many distributions – and is has to be maintained by all of them; otherwise issues like lp #1878760 might creep in, as discussed in #gcc yesterday. - As I am a huge fan of reducing code duplication and local patches, I propose to add it to GCC proper behind a configure flag. The patch idea is: offloading support is configured for one or multiple offload devices but compilation silently ignores a target if its offload compiler is not found at compile time and also dlopen errors of the associated libgomp plugin is also silently ignored such that also the system where the program is run do not show a run-time error. This makes a lot of sense for distribution compilers – as it permits to configure GCC to support offloading to one/multiple offload targets, but the actual offload compiler and the run-time support can be put into separate, optional packages. (When -foffload=$TARGET is specified explicitly, it still gives an error if the offload compiler is not installed; this does not not affect the libgomp/run-time side.) However, for nondistro builds, compilers are usually installed "as is" and not split into different packages – thus, compilation or run-time issues should give an error. Hence, the distro behaviour is only active when configured with --enable-offload-defaulted. Comments? OK for mainline? Tobias * https://src.fedoraproject.org/rpms/gcc/blob/rawhide/f/gcc11-foffload-default.patch - Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf offload-defaulted: Config option to silently ignore uninstalled offload compilers If configured with --enable-offload-defaulted, configured but not installed offload compilers and libgomp plugins are silently ignored. Useful for distribution compilers where those are in separate optional packages. 2021-04-27 Jakub Jelinek Tobias Burnus ChangeLog: * configure.ac (--enable-offload-defaulted): New. * configure: Regenerate. gcc/ChangeLog: * configure.ac (OFFLOAD_DEFAULTED): AC_DEFINE if offload-defaulted. * gcc.c (process_command): New variable. (driver::maybe_putenv_OFFLOAD_TARGETS): If OFFLOAD_DEFAULTED, set it if -foffload is defaulted. * lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define. (compile_offload_image): If OFFLOAD_DEFAULTED and OFFLOAD_TARGET_DEFAULT is in the environment, don't fail if corresponding mkoffload can't be found. (compile_images_for_offload_targets): Likewise. Free and clear offload_names if no valid offload is found. * config.in: Regenerate. * configure: Regenerate. libgomp/ChangeLog: * configure.ac (OFFLOAD_DEFAULTED): AC_DEFINE if offload-defaulted. * target.c (gomp_load_plugin_for_device): If set and if a plugin can't be dlopened, silently assume it has no devices. * Makefile.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. lto-plugin/ChangeLog: * Makefile.in: Regenerate. * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate. configure | 14 ++ configure.ac | 8 gcc/config.in | 6 ++ gcc/configure | 10 -- gcc/configure.ac | 5 + gcc/gcc.c | 17 - gcc/lto-wrapper.c | 26 -- libgomp/Makefile.in| 2 +- libgomp/config.h.in| 3 +++ libgomp/configure | 6 ++ libgomp/configure.ac | 5 + libgomp/target.c | 4 lto-plugin/Makefile.in | 4 ++-- lto-plugin/configure | 34 ++ zlib/configure | 6 +++--- 15 files changed, 123 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index 088e735c5db..b923b0bb9cc 100644 --- a/configure.ac +++ b/configure.ac @@ -300,6 +300,14 @@ AC_ARG_ENABLE(offload-targets, fi ], [enable_offload_targets=]) +AC_ARG_ENABLE(offload-defaulted, +[AS_HELP_STRING([--enable-offload-defaulted] + [If enabled, configured but not installed offload compilers and + libgomp plugins are silently ignored. Useful for distribution + compilers where those are in separate optional packages.])], +[enable_offload_defaulted=$enableval], +[enable_offload_defaulted=]) + # Handle --enable-gold, --enable-ld. # --disable-gold [--enable-ld] # Build only ld. Default option. diff --git a/gcc/configure.ac b/gcc/configure.ac index 96a6f62b0d3..22305e37071 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1139,6 +1139,11 @@ else [Define this to enable support for offloading.]) fi +if test "x$enable_offload_defaulted" = xyes; then + AC_DEFINE(OFFLOAD_DEFAULTED, 1, +[Define to 1 to if -foffload is defaulted]) +fi + AC_ARG_WITH(multilib-list, [AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, SH and x86-64 only)])], :, diff --git a/gcc/gcc.c b/gcc/gcc.c index 7837553958b..bd561ac570f 100644 --- a/gcc/gcc.