public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: "Maciej W. Rozycki" <macro@orcam.me.uk>,
	Chung-Lin Tang <cltang@codesourcery.com>,
	Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>,
	"Mike Stump" <mikestump@comcast.net>,
	Iain Sandoe <idsandoe@googlemail.com>,
	Julian Brown <julian@codesourcery.com>
Subject: libgomp: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR91884, PR109951] (was: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951])
Date: Tue, 12 Sep 2023 11:35:41 +0200	[thread overview]
Message-ID: <874jjzzqc2.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <alpine.DEB.2.21.2306030538250.36323@angie.orcam.me.uk>

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

Hi!

On 2023-06-03T21:32:57+0100, "Maciej W. Rozycki" <macro@orcam.me.uk> wrote:
>> Will you, Maciej, please test that this doesn't break your setting?
>
>  Umm, this was implemented for my Western Digital development environment,
> which I don't have access to anymore.  I'll see what I can do, but it may
> be neither easy nor quick.  It's been long ago and I don't have a setup
> with multilibs enabled anymore.  And neither I remember the thorough
> problem analysis I went through that has led me to the conclusions.

I see.  I've therefore myself now done a quick hack to replicate the
original requirement, to verify that given '--with-build-sysroot=',
build-tree testing must have '--sysroot=[...]' appear for every driver
invocation:

    --- gcc/gcc.cc
    +++ gcc/gcc.cc
    @@ -8190,6 +8190,10 @@ driver::main (int argc, char **argv)
       if (!maybe_print_and_exit ())
         return 0;

    +  if (!env.get ("SKIP_VERIFY_SYSROOT"))
    +    if (!(target_system_root && !strcmp (target_system_root, "/boot/..")))
    +      internal_error ("MISSING SYSROOT");
    +
       early_exit = prepare_infiles ();
       if (early_exit)
         return get_exit_code ();

With that, build GCC with '--with-build-sysroot=/boot/..' and with the
environment variable 'SKIP_VERIFY_SYSROOT' set (to ignore any build-time
issues, not relevant to this discussion here), and test without the
'SKIP_VERIFY_SYSROOT' environment variable set (meaning the checking is
active).  I observe that with current (un-altered) GCC sources,
'--sysroot=[...]' doesn't actually appear for all compiler test suites;
the following ones FAIL:

  - 'ada/acats/acats.sum'
  - 'testsuite/g++/g++.sum': 'g++.dg/plugin/plugin.exp' only
  - 'testsuite/gcc/gcc.sum': 'gcc.dg/plugin/plugin.exp' only
  - 'gm2/gm2.sum'
  - 'gnat/gnat.sum'
  - 'obj-c++/obj-c++.sum': 'obj-c++.dg/plugin/plugin.exp' only
  - 'objc/objc.sum': 'objc.dg/plugin/plugin.exp' only

Additionally, the following target library test suite also FAILs:

    'libitm/testsuite/libitm.sum'

(Resolving these is not my objective right now; I suppose these were not
relevant in Maciej's original scenario.)

Otherwise, I observe that my proposed re-work does still achieve the
desired outcome re '--sysroot=[...]', and Iain has long ago confirmed
that it does resolve <https://gcc.gnu.org/PR109951>
"libgomp, testsuite: non-native multilib c++ tests fail on Darwin", so
pushed to master branch commit fb5d27be272b71fb9026224535fc73f125ce3be7
"libgomp: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR91884, PR109951]",
see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-Consider-with-build-sysroot-.-for-target-lib.patch --]
[-- Type: text/x-diff, Size: 9686 bytes --]

From fb5d27be272b71fb9026224535fc73f125ce3be7 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 1 Jun 2023 23:07:37 +0200
Subject: [PATCH] libgomp: Consider '--with-build-sysroot=[...]' for target
 libraries' build-tree testing (instead of build-time 'CC' etc.) [PR91884,
 PR109951]

This is commit c8e759b4215ba4b376c9d468aeffe163b3d520f0 (Subversion r279708)
"libgomp/test: Fix compilation for build sysroot" and follow-up
commit 749bd22ddc50b5112e5ed506ffef7249bf8e6fb3
"libgomp/test: Remove a build sysroot fix regression" done differently,
avoiding build-tree testing use of any random gunk that may appear in
build-time 'CC', 'CXX', 'FC'.

	PR testsuite/91884
	PR testsuite/109951
	libgomp/
	* configure.ac: Revert earlier changes, instead
	'AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)'.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* testsuite/Makefile.in: Likewise.
	* testsuite/lib/libgomp.exp (libgomp_init): Remove
	"Fix up '-funconfigured-libstdc++-v3' in 'GXX_UNDER_TEST'" code.
	If '--with-build-sysroot=[...]' was specified, use it for
	build-tree testing.
	* testsuite/libgomp-site-extra.exp.in (GCC_UNDER_TEST)
	(GXX_UNDER_TEST, GFORTRAN_UNDER_TEST): Don't set.
	(SYSROOT_CFLAGS_FOR_TARGET): Set.
	* testsuite/libgomp.c++/c++.exp (lang_source_re)
	(lang_include_flags): Set for build-tree testing.
	* testsuite/libgomp.oacc-c++/c++.exp (lang_source_re)
	(lang_include_flags): Likewise.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
---
 libgomp/Makefile.in                         |  2 +-
 libgomp/configure                           | 17 ++++-------------
 libgomp/configure.ac                        | 15 +++------------
 libgomp/testsuite/Makefile.in               |  2 +-
 libgomp/testsuite/lib/libgomp.exp           | 18 +++++-------------
 libgomp/testsuite/libgomp-site-extra.exp.in |  4 +---
 libgomp/testsuite/libgomp.c++/c++.exp       |  6 ++++++
 libgomp/testsuite/libgomp.oacc-c++/c++.exp  |  6 ++++++
 8 files changed, 27 insertions(+), 43 deletions(-)

diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 3ef05e6a3cb..431bc87b629 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -368,7 +368,6 @@ CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CPU_COUNT = @CPU_COUNT@
-CXX = @CXX@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
@@ -436,6 +435,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 VERSION = @VERSION@
 XCFLAGS = @XCFLAGS@
 XLDFLAGS = @XLDFLAGS@
diff --git a/libgomp/configure b/libgomp/configure
index a12b30f1b0f..498bc084a86 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -656,6 +656,7 @@ tmake_file
 XLDFLAGS
 XCFLAGS
 config_path
+SYSROOT_CFLAGS_FOR_TARGET
 FLOCK
 CPU_COUNT
 LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_FALSE
@@ -679,7 +680,6 @@ libtool_VERSION
 ac_ct_FC
 FCFLAGS
 FC
-CXX
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
@@ -11808,22 +11808,11 @@ fi
 
 
 
-# We optionally test libgomp C++ support, and for that want to use the proper
-# C++ driver, 'g++' (or 'xg++' for build-tree testing).  Given that build of
-# target libstdc++-v3 depends on target libgomp (see '../Makefile.def'), we
-# cannot make build of target libgomp depend on target libstdc++-v3: circular
-# dependency.  We thus cannot instantiate 'AC_PROG_CXX' here: we'd get
-# '-funconfigured-libstdc++-v3' (see '../configure.ac').  Therefore, just
-# capture 'CXX', and we'll fix this up at 'make check' time (see
-# 'testsuite/lib/libgomp.exp:libgomp_init').
-
-
 # Create a spec file, so that compile/link tests don't fail
 test -f libgfortran.spec || touch libgfortran.spec
 FCFLAGS="$FCFLAGS -L."
 
-# We need 'gfortran' to compile parts of the library, and test libgomp Fortran
-# support.
+# We need gfortran to compile parts of the library
 # We can't use AC_PROG_FC because it expects a fully working gfortran.
 #AC_PROG_FC(gfortran)
 case `echo $GFORTRAN` in
@@ -16580,6 +16569,8 @@ fi
 
 fi
 
+
+
 # Get target configury.
 . ${srcdir}/configure.tgt
 CFLAGS="$save_CFLAGS $XCFLAGS"
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 1aad83a79da..49f7fb0dc82 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -151,22 +151,11 @@ AC_SUBST(enable_static)
 
 AM_MAINTAINER_MODE
 
-# We optionally test libgomp C++ support, and for that want to use the proper
-# C++ driver, 'g++' (or 'xg++' for build-tree testing).  Given that build of
-# target libstdc++-v3 depends on target libgomp (see '../Makefile.def'), we
-# cannot make build of target libgomp depend on target libstdc++-v3: circular
-# dependency.  We thus cannot instantiate 'AC_PROG_CXX' here: we'd get
-# '-funconfigured-libstdc++-v3' (see '../configure.ac').  Therefore, just
-# capture 'CXX', and we'll fix this up at 'make check' time (see
-# 'testsuite/lib/libgomp.exp:libgomp_init').
-AC_SUBST(CXX)
-
 # Create a spec file, so that compile/link tests don't fail
 test -f libgfortran.spec || touch libgfortran.spec
 FCFLAGS="$FCFLAGS -L."
 
-# We need 'gfortran' to compile parts of the library, and test libgomp Fortran
-# support.
+# We need gfortran to compile parts of the library
 # We can't use AC_PROG_FC because it expects a fully working gfortran.
 #AC_PROG_FC(gfortran)
 case `echo $GFORTRAN` in
@@ -356,6 +345,8 @@ if test -z "$FLOCK"; then
   AC_CHECK_PROG(FLOCK, perl, $srcdir/testsuite/flock)
 fi
 
+AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
+
 # Get target configury.
 . ${srcdir}/configure.tgt
 CFLAGS="$save_CFLAGS $XCFLAGS"
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index d743e464cdc..4155350cf80 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -147,7 +147,6 @@ CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CPU_COUNT = @CPU_COUNT@
-CXX = @CXX@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
@@ -215,6 +214,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 VERSION = @VERSION@
 XCFLAGS = @XCFLAGS@
 XLDFLAGS = @XLDFLAGS@
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index a143b5d0def..cab926a798b 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -91,19 +91,6 @@ proc libgomp_init { args } {
       setenv LANG C.ASCII
     }
 
-    if { $blddir != "" } {
-	# Fix up '-funconfigured-libstdc++-v3' in 'GXX_UNDER_TEST' (see
-	# '../../configure.ac').
-	set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-	if { [file exists $flags_file] } {
-	    set flags [exec sh $flags_file --build-includes]
-	    verbose -log "GXX_UNDER_TEST = $GXX_UNDER_TEST"
-	    set GXX_UNDER_TEST [string map [list \
-	      " -funconfigured-libstdc++-v3 " " $flags " \
-					   ] $GXX_UNDER_TEST]
-	    verbose -log "GXX_UNDER_TEST = $GXX_UNDER_TEST"
-	}
-    }
     if ![info exists GCC_UNDER_TEST] then {
 	if [info exists TOOL_EXECUTABLE] {
 	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
@@ -185,6 +172,11 @@ proc libgomp_init { args } {
 
     set ALWAYS_CFLAGS ""
     if { $blddir != "" } {
+	# If '--with-build-sysroot=[...]' was specified, use it for build-tree
+	# testing.
+	global SYSROOT_CFLAGS_FOR_TARGET
+	lappend ALWAYS_CFLAGS "additional_flags=${SYSROOT_CFLAGS_FOR_TARGET}"
+
         lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
         # targets that use libgomp.a%s in their specs need a -B option
         # for uninstalled testing.
diff --git a/libgomp/testsuite/libgomp-site-extra.exp.in b/libgomp/testsuite/libgomp-site-extra.exp.in
index c824d85f7ed..8de14f48976 100644
--- a/libgomp/testsuite/libgomp-site-extra.exp.in
+++ b/libgomp/testsuite/libgomp-site-extra.exp.in
@@ -1,4 +1,2 @@
 set FLOCK {@FLOCK@}
-set GCC_UNDER_TEST {@CC@}
-set GXX_UNDER_TEST {@CXX@}
-set GFORTRAN_UNDER_TEST {@FC@}
+set SYSROOT_CFLAGS_FOR_TARGET {@SYSROOT_CFLAGS_FOR_TARGET@}
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 8b4563b1d0d..ed096e17b9c 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -15,6 +15,10 @@ if { $blddir != "" } {
     verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
 }
+if { $blddir != "" } {
+    set lang_source_re {^.*\.[cC]$}
+    set lang_include_flags [exec sh ${blddir}/../libstdc++-v3/scripts/testsuite_flags --build-includes]
+}
 lappend ALWAYS_CFLAGS "compiler=$GXX_UNDER_TEST"
 
 # If a testcase doesn't have special options, use these.
@@ -44,6 +48,8 @@ set_ld_library_path_env_vars
 dg-runtest $tests "" $DEFAULT_CFLAGS
 
 if { $blddir != "" } {
+    unset lang_source_re
+    unset lang_include_flags
     unset libstdc++_library_path
     unset lang_library_paths
 }
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 79df401c99a..7b2315e406f 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -25,6 +25,10 @@ if { $blddir != "" } {
     verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
 }
+if { $blddir != "" } {
+    set lang_source_re {^.*\.[cC]$}
+    set lang_include_flags [exec sh ${blddir}/../libstdc++-v3/scripts/testsuite_flags --build-includes]
+}
 lappend ALWAYS_CFLAGS "compiler=$GXX_UNDER_TEST"
 
 # Initialize dg.
@@ -121,6 +125,8 @@ foreach offload_target [concat [split $offload_targets ","] "disable"] {
 unset offload_target
 
 if { $blddir != "" } {
+    unset lang_source_re
+    unset lang_include_flags
     unset libstdc++_library_path
     unset lang_library_paths
 }
-- 
2.34.1


  reply	other threads:[~2023-09-12  9:35 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11 18:12 [PATCH 0/4] Fix library testsuite compilation for build sysroot Maciej W. Rozycki
2019-11-11 18:12 ` [PATCH 1/4] libatomic/test: Fix " Maciej W. Rozycki
2019-11-11 18:12 ` [PATCH 2/4] libffi/test: " Maciej W. Rozycki
2019-11-11 18:23 ` [golang-dev] [PATCH 0/4] Fix library testsuite " Ulderico Cirello
2019-11-11 18:29   ` Kaz Kylheku (libffi)
2019-11-11 18:42     ` Ian Lance Taylor
2019-11-11 18:35   ` Ian Lance Taylor
2019-11-11 18:45     ` Maciej W. Rozycki
2019-11-11 23:29       ` Ian Lance Taylor
2019-11-11 18:44   ` Maciej W. Rozycki
2019-11-26 15:56 ` [PING][PATCH " Maciej W. Rozycki
2019-12-02 14:49 ` [PING^2][PATCH " Maciej W. Rozycki
2019-12-09 21:30 ` [PING^3][PATCH " Maciej W. Rozycki
2019-12-17  0:06 ` [PING^4][PATCH " Maciej W. Rozycki
2019-12-21  1:30   ` Mike Stump
2019-12-22  1:34     ` Maciej W. Rozycki
2020-01-03 11:34       ` Julian Brown
2020-01-06 15:25         ` Maciej W. Rozycki
2020-01-09 21:00           ` Tobias Burnus
2020-01-14 13:43           ` Chung-Lin Tang
2020-01-21  3:21             ` Maciej W. Rozycki
2020-01-31 22:36               ` Maciej W. Rozycki
2020-02-11  8:35                 ` Chung-Lin Tang
2020-02-11 21:31                   ` Maciej W. Rozycki
2023-06-02  9:52             ` Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] Thomas Schwinge
2023-06-03 20:32               ` Maciej W. Rozycki
2023-09-12  9:35                 ` Thomas Schwinge [this message]
2023-09-12  9:35               ` Pass 'SYSROOT_CFLAGS_FOR_TARGET' down to target libraries [PR109951] (was: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]) Thomas Schwinge
2020-01-06 15:47     ` [PING^5][PATCH 0/4] Fix library testsuite compilation for build sysroot Maciej W. Rozycki
2020-01-13 21:20     ` [PING^6][PATCH " Maciej W. Rozycki
2020-01-21  2:44     ` [PING^7][PATCH " Maciej W. Rozycki
2020-01-26 21:07       ` Jeff Law
2020-02-13 23:37         ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jjzzqc2.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=idsandoe@googlemail.com \
    --cc=julian@codesourcery.com \
    --cc=macro@orcam.me.uk \
    --cc=mikestump@comcast.net \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).