public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Simplify omp-device-properties.h creation (PR bootstrap/92314)
@ 2019-11-01 23:38 Jakub Jelinek
  2020-04-29  9:07 ` Harden and adjust 'gcc/configure' parsing of '--enable-offload-targets' (was: [committed] Simplify omp-device-properties.h creation (PR bootstrap/92314)) Thomas Schwinge
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2019-11-01 23:38 UTC (permalink / raw)
  To: gcc-patches

Hi!

Apparently my recent change broke quite a lot of setups where people were
configuring --enable-offload-targets= without having the corresponding
offloading compiler already installed.
The following patch simplifies it by removing the need to have it installed
again for compiler building (it is still needed for testing as before),
by adding new tmake_files with the needed rules and building everything
while building the host compiler.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested also with
x86_64-intelmicemul-linux-gnu and nvptx-none offloading, committed to trunk.

2019-11-02  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/92314
	* configure.ac: Don't look for omp-device-properties files from
	installed offloading compilers.  Instead add tmake_file snippets
	for configured offloading targets and use files they generate.
	* Makefile.in (install): Don't depend on
	install-omp-device-properties.
	(install-omp-device-properties): Remove goal.
	* config/i386/t-omp-device: New file.
	* config/i386/t-intelmic (omp-device-properties): Remove goal.
	* config/nvptx/t-omp-device: New file.
	* config/nvptx/t-nvptx (omp-device-properties): Remove goal.
	* configure: Regenerated.

--- gcc/configure.ac.jj	2019-10-31 11:05:50.461137028 +0100
+++ gcc/configure.ac	2019-11-01 21:22:58.417920544 +0100
@@ -1026,18 +1026,22 @@ AC_SUBST(real_target_noncanonical)
 AC_SUBST(accel_dir_suffix)
 
 for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
-  tgt_dir=`echo $tgt | sed -n 's/.*=//p'`
   tgt=`echo $tgt | sed 's/=.*//'`
 
   if echo "$tgt" | grep "^hsa" > /dev/null ; then
     enable_hsa=1
   else
     enable_offloading=1
-    if test -n "$tgt_dir"; then
-      omp_device_property="${tgt_dir}/lib/gcc/\$(real_target_noncanonical)/\$(version)/accel/${tgt}/omp-device-properties"
-    else
-      omp_device_property="\$(libsubdir)/accel/${tgt}/omp-device-properties"
-    fi
+    case "$tgt" in
+      *-intelmicemul-*)
+	omp_device_property=omp-device-properties-i386
+	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
+	;;
+      nvptx*-*)
+	omp_device_property=omp-device-properties-nvptx
+	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/nvptx/t-omp-device"
+	;;
+    esac
     omp_device_properties="${omp_device_properties} ${tgt}=${omp_device_property}"
     omp_device_property_deps="${omp_device_property_deps} ${omp_device_property}"
   fi
@@ -2065,7 +2069,7 @@ do
 		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
 	fi
 done
-tmake_file="${tmake_file_}"
+tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
 
 out_object_file=`basename $out_file .c`.o
 common_out_object_file=`basename $common_out_file .c`.o
--- gcc/Makefile.in.jj	2019-10-31 11:05:50.491136565 +0100
+++ gcc/Makefile.in	2019-11-01 21:04:12.720107538 +0100
@@ -3476,10 +3476,6 @@ ifeq ($(enable_plugin),yes)
 install: install-plugin
 endif
 
-ifeq ($(enable_as_accelerator),yes)
-install: install-omp-device-properties
-endif
-
 install-strip: override INSTALL_PROGRAM = $(INSTALL_STRIP_PROGRAM)
 ifneq ($(STRIP),)
 install-strip: STRIPPROG = $(STRIP)
@@ -3665,11 +3661,6 @@ install-driver: installdirs xgcc$(exeext
 	  fi; \
 	fi
 
-# Install omp-device-properties file for accelerator compilers.
-install-omp-device-properties: omp-device-properties installdirs
-	$(INSTALL_DATA) omp-device-properties \
-	  $(DESTDIR)$(libsubdir)/omp-device-properties
-
 # Install the info files.
 # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
 # to do the install.
--- gcc/config/i386/t-omp-device.jj	2019-11-01 21:02:23.010782525 +0100
+++ gcc/config/i386/t-omp-device	2019-11-01 21:02:45.117445012 +0100
@@ -0,0 +1,6 @@
+omp-device-properties-i386: $(srcdir)/config/i386/i386-options.c
+	echo kind: cpu > $@
+	echo arch: x86 x86_64 i386 i486 i586 i686 ia32 >> $@
+	echo isa: sse4 `sed -n '/^static struct ix86_target_opts isa2\?_opts\[\] =/,/^};/p' \
+	  $(srcdir)/config/i386/i386-options.c | \
+	  sed -n 's/",.*$$//;s/\./_/;s/^  { "-m//p'` >> $@
--- gcc/config/i386/t-intelmic.jj	2019-10-31 11:05:50.533135914 +0100
+++ gcc/config/i386/t-intelmic	2019-11-01 21:02:55.715283208 +0100
@@ -8,10 +8,3 @@ ALL_HOST_OBJS += mkoffload.o
 mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS)
 	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	  mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
-
-omp-device-properties: $(srcdir)/config/i386/i386-options.c
-	echo kind: cpu > omp-device-properties
-	echo arch: x86 x86_64 i386 i486 i586 i686 ia32 >> omp-device-properties
-	echo isa: sse4 `sed -n '/^static struct ix86_target_opts isa2\?_opts\[\] =/,/^};/p' \
-	  $(srcdir)/config/i386/i386-options.c | \
-	  sed -n 's/",.*$$//;s/\./_/;s/^  { "-m//p'` >> omp-device-properties
--- gcc/config/nvptx/t-omp-device.jj	2019-11-01 21:02:03.297083500 +0100
+++ gcc/config/nvptx/t-omp-device	2019-11-01 21:01:52.996240773 +0100
@@ -0,0 +1,4 @@
+omp-device-properties-nvptx: $(srcdir)/config/nvptx/nvptx.c
+	echo kind: gpu > $@
+	echo arch: nvptx >> $@
+	echo isa: sm_30 sm_35 >> $@
--- gcc/config/nvptx/t-nvptx.jj	2019-10-31 11:05:50.539135821 +0100
+++ gcc/config/nvptx/t-nvptx	2019-11-01 21:03:24.380845555 +0100
@@ -10,8 +10,3 @@ mkoffload$(exeext): mkoffload.o collect-
 	  mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
 
 MULTILIB_OPTIONS = mgomp
-
-omp-device-properties: $(srcdir)/config/nvptx/nvptx.c
-	echo kind: gpu > omp-device-properties
-	echo arch: nvptx >> omp-device-properties
-	echo isa: sm_30 sm_35 >> omp-device-properties
--- gcc/configure.jj	2019-10-31 11:05:50.608134752 +0100
+++ gcc/configure	2019-11-01 21:23:09.097757470 +0100
@@ -7881,18 +7881,22 @@ fi
 
 
 for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
-  tgt_dir=`echo $tgt | sed -n 's/.*=//p'`
   tgt=`echo $tgt | sed 's/=.*//'`
 
   if echo "$tgt" | grep "^hsa" > /dev/null ; then
     enable_hsa=1
   else
     enable_offloading=1
-    if test -n "$tgt_dir"; then
-      omp_device_property="${tgt_dir}/lib/gcc/\$(real_target_noncanonical)/\$(version)/accel/${tgt}/omp-device-properties"
-    else
-      omp_device_property="\$(libsubdir)/accel/${tgt}/omp-device-properties"
-    fi
+    case "$tgt" in
+      *-intelmicemul-*)
+	omp_device_property=omp-device-properties-i386
+	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
+	;;
+      nvptx*-*)
+	omp_device_property=omp-device-properties-nvptx
+	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/nvptx/t-omp-device"
+	;;
+    esac
     omp_device_properties="${omp_device_properties} ${tgt}=${omp_device_property}"
     omp_device_property_deps="${omp_device_property_deps} ${omp_device_property}"
   fi
@@ -12536,7 +12540,7 @@ do
 		tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
 	fi
 done
-tmake_file="${tmake_file_}"
+tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
 
 out_object_file=`basename $out_file .c`.o
 common_out_object_file=`basename $common_out_file .c`.o
@@ -18864,7 +18868,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18867 "configure"
+#line 18871 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18970,7 +18974,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18973 "configure"
+#line 18977 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Harden and adjust 'gcc/configure' parsing of '--enable-offload-targets' (was: [committed] Simplify omp-device-properties.h creation (PR bootstrap/92314))
  2019-11-01 23:38 [committed] Simplify omp-device-properties.h creation (PR bootstrap/92314) Jakub Jelinek
@ 2020-04-29  9:07 ` Thomas Schwinge
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Schwinge @ 2020-04-29  9:07 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches; +Cc: Andrew Stubbs, Julian Brown, Tobias Burnus

[-- Attachment #1: Type: text/plain, Size: 2872 bytes --]

Hi Jakub!

On 2019-11-02T00:38:02+0100, Jakub Jelinek <jakub@redhat.com> wrote:
> Apparently my recent change broke quite a lot of setups where people were
> configuring --enable-offload-targets= without having the corresponding
> offloading compiler already installed.
> The following patch simplifies it by removing the need to have it installed
> again for compiler building (it is still needed for testing as before),
> by adding new tmake_files with the needed rules and building everything
> while building the host compiler.

ACK, thanks for that re-work.


> --- gcc/configure.ac.jj       2019-10-31 11:05:50.461137028 +0100
> +++ gcc/configure.ac  2019-11-01 21:22:58.417920544 +0100
> @@ -1026,18 +1026,22 @@ AC_SUBST(real_target_noncanonical)
>  AC_SUBST(accel_dir_suffix)
>
>  for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
> -  tgt_dir=`echo $tgt | sed -n 's/.*=//p'`
>    tgt=`echo $tgt | sed 's/=.*//'`
>
>    if echo "$tgt" | grep "^hsa" > /dev/null ; then
>      enable_hsa=1
>    else
>      enable_offloading=1
> -    if test -n "$tgt_dir"; then
> -      omp_device_property="${tgt_dir}/lib/gcc/\$(real_target_noncanonical)/\$(version)/accel/${tgt}/omp-device-properties"
> -    else
> -      omp_device_property="\$(libsubdir)/accel/${tgt}/omp-device-properties"
> -    fi
> +    case "$tgt" in
> +      *-intelmicemul-*)
> +     omp_device_property=omp-device-properties-i386
> +     omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
> +     ;;
> +      nvptx*-*)
> +     omp_device_property=omp-device-properties-nvptx
> +     omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/nvptx/t-omp-device"
> +     ;;
> +    esac
>      omp_device_properties="${omp_device_properties} ${tgt}=${omp_device_property}"
>      omp_device_property_deps="${omp_device_property_deps} ${omp_device_property}"
>    fi

Discovered/developed in context of my commit
b6a0ae1d22c9675f4374c2cb2b5c0833bb1461f1 "[gcn] Fix
'omp-device-properties-gcn' handling",
<http://mid.mail-archive.com/87ees6brhe.fsf@euler.schwinge.homeip.net>,
I've now as obvious pushed to master branch commit
d20219b5ab26cd003ae78ac9f82be337fe4df261 "Harden and adjust
'gcc/configure' parsing of '--enable-offload-targets'".

Not sure why you'd diverged here, and in particular omitted the error
case, which right away would've caught this 'amdgcn' vs. 'gcn' problem
introduced by Tobias' commit 955cd057454b323419e06affa7df7d59dc3cd1fb
(r277797) "Add gcc/config/gcn/t-omp-device for OpenMP declare variant
kind/arch/isa".


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Harden-and-adjust-gcc-configure-parsing-of-enable-of.patch --]
[-- Type: text/x-diff, Size: 3804 bytes --]

From d20219b5ab26cd003ae78ac9f82be337fe4df261 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 23 Apr 2020 21:59:07 +0200
Subject: [PATCH] Harden and adjust 'gcc/configure' parsing of
 '--enable-offload-targets'

Fix-up for commit d228ee80f8578be474595a517a228111fac26c5e "re PR
bootstrap/92314 (missing omp-device-properties', needed by
's-omp-device-properties-h')".

	gcc/
	* configure.ac <$enable_offload_targets>: Do parsing as done
	elsewhere.
	* configure: Regenerate.
---
 gcc/ChangeLog    |  4 ++++
 gcc/configure    | 13 ++++++++-----
 gcc/configure.ac |  9 ++++++---
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 85d1c2b6f758..3df46e498f57 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
 2020-04-29  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* configure.ac <$enable_offload_targets>: Do parsing as done
+	elsewhere.
+	* configure: Regenerate.
+
 	* configure.ac <$enable_offload_targets>: 'amdgcn' is 'gcn'.
 	* configure: Regenerate.
 
diff --git a/gcc/configure b/gcc/configure
index 83101072aea0..c7bf5d1fdc6b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -7920,18 +7920,21 @@ for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
   else
     enable_offloading=1
     case "$tgt" in
-      *-intelmicemul-*)
+      *-intelmic-* | *-intelmicemul-*)
 	omp_device_property=omp-device-properties-i386
 	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
 	;;
-      amdgcn*-*)
+      amdgcn*)
 	omp_device_property=omp-device-properties-gcn
 	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/gcn/t-omp-device"
 	;;
-      nvptx*-*)
+      nvptx*)
 	omp_device_property=omp-device-properties-nvptx
 	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/nvptx/t-omp-device"
 	;;
+      *)
+	as_fn_error $? "unknown offload target specified" "$LINENO" 5
+	;;
     esac
     omp_device_properties="${omp_device_properties} ${tgt}=${omp_device_property}"
     omp_device_property_deps="${omp_device_property_deps} ${omp_device_property}"
@@ -18985,7 +18988,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18988 "configure"
+#line 18991 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19091,7 +19094,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19094 "configure"
+#line 19097 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b604047ae456..72f79f7ed322 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1045,18 +1045,21 @@ for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do
   else
     enable_offloading=1
     case "$tgt" in
-      *-intelmicemul-*)
+      *-intelmic-* | *-intelmicemul-*)
 	omp_device_property=omp-device-properties-i386
 	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/i386/t-omp-device"
 	;;
-      amdgcn*-*)
+      amdgcn*)
 	omp_device_property=omp-device-properties-gcn
 	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/gcn/t-omp-device"
 	;;
-      nvptx*-*)
+      nvptx*)
 	omp_device_property=omp-device-properties-nvptx
 	omp_device_property_tmake_file="${omp_device_property_tmake_file} \$(srcdir)/config/nvptx/t-omp-device"
 	;;
+      *)
+	AC_MSG_ERROR([unknown offload target specified])
+	;;
     esac
     omp_device_properties="${omp_device_properties} ${tgt}=${omp_device_property}"
     omp_device_property_deps="${omp_device_property_deps} ${omp_device_property}"
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-29  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 23:38 [committed] Simplify omp-device-properties.h creation (PR bootstrap/92314) Jakub Jelinek
2020-04-29  9:07 ` Harden and adjust 'gcc/configure' parsing of '--enable-offload-targets' (was: [committed] Simplify omp-device-properties.h creation (PR bootstrap/92314)) Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).