public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 3/4] libgo/test: Fix compilation for build sysroot
@ 2019-11-11 18:13 Maciej W. Rozycki
  2019-11-11 23:43 ` [golang-dev] " Ian Lance Taylor
  2023-09-12 11:16 ` libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH 3/4] libgo/test: Fix compilation for build sysroot) Thomas Schwinge
  0 siblings, 2 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2019-11-11 18:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: libffi-discuss, golang-dev

Fix a problem with the libgo testsuite using a method to determine the 
compiler to use resulting in the tool being different from one the 
library has been built with, and causing a catastrophic failure from the 
lack of a suitable `--sysroot=' option where the `--with-build-sysroot=' 
configuration option has been used to build the compiler resulting in 
the inability to link executables.

Address this problem by providing a DejaGNU configuration file defining 
the compiler to use, via the GOC_UNDER_TEST TCL variable, set from $GOC 
by autoconf, which will have all the required options set for the target 
compiler to build executables in the environment configured, removing 
failures like:

.../bin/riscv64-linux-gnu-ld: cannot find crt1.o: No such file or directory
.../bin/riscv64-linux-gnu-ld: cannot find -lm
.../bin/riscv64-linux-gnu-ld: cannot find -lc
collect2: error: ld returned 1 exit status
compiler exited with status 1

No summary comparison, because the libgo testsuite does not provide one 
in this configuration for some reason, however this change improves 
overall test results for the `riscv64-linux-gnu' target (here with the 
`x86_64-linux-gnu' host and RISC-V QEMU in the Linux user emulation mode 
as the target board) from 0 PASSes and 159 FAILs to 133 PASSes and 26 
FAILs.

	libgo/
	* configure.ac: Add testsuite/libgo-test-support.exp to output 
	files.
	* configure: Regenerate.
	* testsuite/libgo-test-support.exp.in: New file.
	* testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New 
	variable.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/lib/libgo.exp: Don't override GOC_UNDER_TEST 
	previously set.
---
 libgo/configure                           |    3 ++-
 libgo/configure.ac                        |    2 +-
 libgo/testsuite/Makefile.am               |    2 ++
 libgo/testsuite/Makefile.in               |    5 ++++-
 libgo/testsuite/lib/libgo.exp             |   13 ++++++++-----
 libgo/testsuite/libgo-test-support.exp.in |    1 +
 6 files changed, 18 insertions(+), 8 deletions(-)

gcc-test-libgo-gcc-under-test.diff
Index: gcc/libgo/configure
===================================================================
--- gcc.orig/libgo/configure
+++ gcc/libgo/configure
@@ -15850,7 +15850,7 @@ else
   multilib_arg=
 fi
 
-ac_config_files="$ac_config_files Makefile testsuite/Makefile"
+ac_config_files="$ac_config_files Makefile testsuite/Makefile testsuite/libgo-test-support.exp"
 
 
 ac_config_commands="$ac_config_commands default"
@@ -17031,6 +17031,7 @@ do
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
+    "testsuite/libgo-test-support.exp") CONFIG_FILES="$CONFIG_FILES testsuite/libgo-test-support.exp" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
Index: gcc/libgo/configure.ac
===================================================================
--- gcc.orig/libgo/configure.ac
+++ gcc/libgo/configure.ac
@@ -877,7 +877,7 @@ else
   multilib_arg=
 fi
 
-AC_CONFIG_FILES(Makefile testsuite/Makefile)
+AC_CONFIG_FILES(Makefile testsuite/Makefile testsuite/libgo-test-support.exp)
 
 AC_CONFIG_COMMANDS([default],
 [if test -n "$CONFIG_FILES"; then
Index: gcc/libgo/testsuite/Makefile.am
===================================================================
--- gcc.orig/libgo/testsuite/Makefile.am
+++ gcc/libgo/testsuite/Makefile.am
@@ -11,6 +11,8 @@ RUNTEST = `if [ -f $(top_srcdir)/../deja
 	       echo $(top_srcdir)/../dejagnu/runtest ; \
 	    else echo runtest; fi`
 
+EXTRA_DEJAGNU_SITE_CONFIG = libgo-test-support.exp
+
 # When running the tests we set GCC_EXEC_PREFIX to the install tree so that
 # files that have already been installed there will be found.  The -B option
 # overrides it, so use of GCC_EXEC_PREFIX will not result in using GCC files
Index: gcc/libgo/testsuite/Makefile.in
===================================================================
--- gcc.orig/libgo/testsuite/Makefile.in
+++ gcc/libgo/testsuite/Makefile.in
@@ -106,7 +106,7 @@ am__configure_deps = $(am__aclocal_m4_de
 DIST_COMMON = $(srcdir)/Makefile.am
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = libgo-test-support.exp
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -299,6 +299,7 @@ RUNTEST = `if [ -f $(top_srcdir)/../deja
 	       echo $(top_srcdir)/../dejagnu/runtest ; \
 	    else echo runtest; fi`
 
+EXTRA_DEJAGNU_SITE_CONFIG = libgo-test-support.exp
 
 # When running the tests we set GCC_EXEC_PREFIX to the install tree so that
 # files that have already been installed there will be found.  The -B option
@@ -338,6 +339,8 @@ $(top_srcdir)/configure: @MAINTAINER_MOD
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+libgo-test-support.exp: $(top_builddir)/config.status $(srcdir)/libgo-test-support.exp.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 
 mostlyclean-libtool:
 	-rm -f *.lo
Index: gcc/libgo/testsuite/lib/libgo.exp
===================================================================
--- gcc.orig/libgo/testsuite/lib/libgo.exp
+++ gcc/libgo/testsuite/lib/libgo.exp
@@ -14,13 +14,16 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
-if {$gccdir != ""} {
-    set gccdir [file dirname $gccdir]
-}
-set GOC_UNDER_TEST "$gccdir/gccgo -B$gccdir/"
 set TESTING_IN_BUILD_TREE 1
 
+if ![info exists GOC_UNDER_TEST] then {
+    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+    if {$gccdir != ""} {
+	set gccdir [file dirname $gccdir]
+    }
+    set GOC_UNDER_TEST "$gccdir/gccgo -B$gccdir/"
+}
+
 if [info exists GOTEST_TMPDIR] {
     set tmpdir $GOTEST_TMPDIR
 }
Index: gcc/libgo/testsuite/libgo-test-support.exp.in
===================================================================
--- /dev/null
+++ gcc/libgo/testsuite/libgo-test-support.exp.in
@@ -0,0 +1 @@
+set GOC_UNDER_TEST {@GOC@}

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

* Re: [golang-dev] [PATCH 3/4] libgo/test: Fix compilation for build sysroot
  2019-11-11 18:13 [PATCH 3/4] libgo/test: Fix compilation for build sysroot Maciej W. Rozycki
@ 2019-11-11 23:43 ` Ian Lance Taylor
  2023-09-12 11:16 ` libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH 3/4] libgo/test: Fix compilation for build sysroot) Thomas Schwinge
  1 sibling, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2019-11-11 23:43 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gcc-patches, libffi-discuss, golang-dev

On Mon, Nov 11, 2019 at 10:12 AM Maciej W. Rozycki <macro@wdc.com> wrote:
>
> Fix a problem with the libgo testsuite using a method to determine the
> compiler to use resulting in the tool being different from one the
> library has been built with, and causing a catastrophic failure from the
> lack of a suitable `--sysroot=' option where the `--with-build-sysroot='
> configuration option has been used to build the compiler resulting in
> the inability to link executables.
>
> Address this problem by providing a DejaGNU configuration file defining
> the compiler to use, via the GOC_UNDER_TEST TCL variable, set from $GOC
> by autoconf, which will have all the required options set for the target
> compiler to build executables in the environment configured, removing
> failures like:
>
> .../bin/riscv64-linux-gnu-ld: cannot find crt1.o: No such file or directory
> .../bin/riscv64-linux-gnu-ld: cannot find -lm
> .../bin/riscv64-linux-gnu-ld: cannot find -lc
> collect2: error: ld returned 1 exit status
> compiler exited with status 1
>
> No summary comparison, because the libgo testsuite does not provide one
> in this configuration for some reason, however this change improves
> overall test results for the `riscv64-linux-gnu' target (here with the
> `x86_64-linux-gnu' host and RISC-V QEMU in the Linux user emulation mode
> as the target board) from 0 PASSes and 159 FAILs to 133 PASSes and 26
> FAILs.
>
>         libgo/
>         * configure.ac: Add testsuite/libgo-test-support.exp to output
>         files.
>         * configure: Regenerate.
>         * testsuite/libgo-test-support.exp.in: New file.
>         * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New
>         variable.
>         * testsuite/Makefile.in: Regenerate.
>         * testsuite/lib/libgo.exp: Don't override GOC_UNDER_TEST
>         previously set.

Thanks.

Committed to mainline.

Ian

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

* libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH 3/4] libgo/test: Fix compilation for build sysroot)
  2019-11-11 18:13 [PATCH 3/4] libgo/test: Fix compilation for build sysroot Maciej W. Rozycki
  2019-11-11 23:43 ` [golang-dev] " Ian Lance Taylor
@ 2023-09-12 11:16 ` Thomas Schwinge
  2023-09-12 20:20   ` Ian Lance Taylor
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Schwinge @ 2023-09-12 11:16 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev, Ian Lance Taylor
  Cc: Maciej W. Rozycki, Rainer Orth, Mike Stump, Iain Sandoe

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

Hi!

On 2019-11-11T18:12:44+0000, "Maciej W. Rozycki" <macro@wdc.com> wrote:
> Fix a problem with the libgo testsuite using a method to determine the
> compiler to use resulting in the tool being different from one the
> library has been built with, and causing a catastrophic failure from the
> lack of a suitable `--sysroot=' option where the `--with-build-sysroot='
> configuration option has been used to build the compiler resulting in
> the inability to link executables.
>
> Address this problem by providing a DejaGNU configuration file defining
> the compiler to use, via the GOC_UNDER_TEST TCL variable, set from $GOC
> by autoconf, which will have all the required options set for the target
> compiler to build executables in the environment configured

As we've found, this is conceptually problematic, as discussed in
<https://inbox.sourceware.org/875y868a4b.fsf@euler.schwinge.homeip.net>
"Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.)
[PR109951]".
I therefore suggest to apply to libgo the conceptually same changes
as I've just pushed for libgomp:
<https://inbox.sourceware.org/874jjzzqc2.fsf@euler.schwinge.homeip.net>
"libgomp: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC'
etc.) [PR91884, PR109951]".
OK to push (via Ian/Go upstream) the attached
"libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]"?

By the way, I've tested this one via hard-coding
'libgo/configure.ac:USE_DEJAGNU' to 'yes', and observing that my
"quick hack to replicate the original requirement"
('internal_error ("MISSING SYSROOT");') no longer triggers.


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-libgo-Consider-with-build-sysroot-.-for-target-libra.patch --]
[-- Type: text/x-diff, Size: 4822 bytes --]

From 81a73112e3d0b43c240c7c9040c24d68c2739bf3 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Mon, 11 Sep 2023 16:55:24 +0200
Subject: [PATCH] libgo: Consider '--with-build-sysroot=[...]' for target
 libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]

Similar to commit fb5d27be272b71fb9026224535fc73f125ce3be7
"libgomp: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR91884, PR109951]",
this is commit b72813a68c943643a6241418f27aa8b9d4614647
"libgo: fix DejaGNU testsuite compiler when using build sysroot" done
differently, avoiding build-tree testing use of any random gunk that may
appear in build-time 'GOC'.

	PR testsuite/109951
	libgo/
	* configure.ac: 'AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)'.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* testsuite/Makefile.in: Likewise.
	* testsuite/lib/libgo.exp (libgo_init): If
	'--with-build-sysroot=[...]' was specified, use it for build-tree
	testing.
	* testsuite/libgo-test-support.exp.in (GOC_UNDER_TEST): Don't set.
	(SYSROOT_CFLAGS_FOR_TARGET): Set.
---
 libgo/Makefile.in                         | 1 +
 libgo/configure                           | 7 +++++--
 libgo/configure.ac                        | 2 ++
 libgo/testsuite/Makefile.in               | 1 +
 libgo/testsuite/lib/libgo.exp             | 8 ++++++++
 libgo/testsuite/libgo-test-support.exp.in | 2 +-
 6 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 40340bfb7a5..8dcb6d6a354 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -474,6 +474,7 @@ SPLIT_STACK = @SPLIT_STACK@
 STRINGOPS_FLAG = @STRINGOPS_FLAG@
 STRIP = @STRIP@
 STRUCT_EPOLL_EVENT_FD_OFFSET = @STRUCT_EPOLL_EVENT_FD_OFFSET@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 USE_DEJAGNU = @USE_DEJAGNU@
 VERSION = @VERSION@
 WARN_FLAGS = @WARN_FLAGS@
diff --git a/libgo/configure b/libgo/configure
index a607dbff68e..2f1609b42b5 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -633,6 +633,7 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+SYSROOT_CFLAGS_FOR_TARGET
 HAVE_STATIC_LINK_FALSE
 HAVE_STATIC_LINK_TRUE
 HAVE_STAT_TIMESPEC_FALSE
@@ -11544,7 +11545,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11547 "configure"
+#line 11548 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11650,7 +11651,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11653 "configure"
+#line 11654 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16147,6 +16148,8 @@ else
 fi
 
 
+
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
diff --git a/libgo/configure.ac b/libgo/configure.ac
index a59aa091d1d..54c35c0903c 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -913,6 +913,8 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
 LDFLAGS=$LDFLAGS_hold])
 AM_CONDITIONAL(HAVE_STATIC_LINK, test "$libgo_cv_ld_static" = yes)
 
+AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
+
 AC_CACHE_SAVE
 
 if test ${multilib} = yes; then
diff --git a/libgo/testsuite/Makefile.in b/libgo/testsuite/Makefile.in
index 7869265851c..7c2e2e62fcf 100644
--- a/libgo/testsuite/Makefile.in
+++ b/libgo/testsuite/Makefile.in
@@ -223,6 +223,7 @@ SPLIT_STACK = @SPLIT_STACK@
 STRINGOPS_FLAG = @STRINGOPS_FLAG@
 STRIP = @STRIP@
 STRUCT_EPOLL_EVENT_FD_OFFSET = @STRUCT_EPOLL_EVENT_FD_OFFSET@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 USE_DEJAGNU = @USE_DEJAGNU@
 VERSION = @VERSION@
 WARN_FLAGS = @WARN_FLAGS@
diff --git a/libgo/testsuite/lib/libgo.exp b/libgo/testsuite/lib/libgo.exp
index b5833bbafe2..638bf869602 100644
--- a/libgo/testsuite/lib/libgo.exp
+++ b/libgo/testsuite/lib/libgo.exp
@@ -53,5 +53,13 @@ load_gcc_lib timeout.exp
 load_gcc_lib go.exp
 
 proc libgo_init { args } {
+    global TESTING_IN_BUILD_TREE
+    if { [info exists TESTING_IN_BUILD_TREE] } {
+	# If '--with-build-sysroot=[...]' was specified, use it for build-tree
+	# testing.
+	global TEST_ALWAYS_FLAGS SYSROOT_CFLAGS_FOR_TARGET
+	set TEST_ALWAYS_FLAGS $SYSROOT_CFLAGS_FOR_TARGET
+    }
+
     go_init $args
 }
diff --git a/libgo/testsuite/libgo-test-support.exp.in b/libgo/testsuite/libgo-test-support.exp.in
index aaa6c5ef91d..effd6f1caca 100644
--- a/libgo/testsuite/libgo-test-support.exp.in
+++ b/libgo/testsuite/libgo-test-support.exp.in
@@ -14,4 +14,4 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-set GOC_UNDER_TEST {@GOC@}
+set SYSROOT_CFLAGS_FOR_TARGET {@SYSROOT_CFLAGS_FOR_TARGET@}
-- 
2.34.1


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

* Re: libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH 3/4] libgo/test: Fix compilation for build sysroot)
  2023-09-12 11:16 ` libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH 3/4] libgo/test: Fix compilation for build sysroot) Thomas Schwinge
@ 2023-09-12 20:20   ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2023-09-12 20:20 UTC (permalink / raw)
  To: Thomas Schwinge
  Cc: gcc-patches, gofrontend-dev, Iain Sandoe, Maciej W. Rozycki

On Tue, Sep 12, 2023 at 4:16 AM Thomas Schwinge <thomas@codesourcery.com> wrote:
>
> As we've found, this is conceptually problematic, as discussed in
> <https://inbox.sourceware.org/875y868a4b.fsf@euler.schwinge.homeip.net>
> "Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.)
> [PR109951]".
> I therefore suggest to apply to libgo the conceptually same changes
> as I've just pushed for libgomp:
> <https://inbox.sourceware.org/874jjzzqc2.fsf@euler.schwinge.homeip.net>
> "libgomp: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC'
> etc.) [PR91884, PR109951]".
> OK to push (via Ian/Go upstream) the attached
> "libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]"?
>
> By the way, I've tested this one via hard-coding
> 'libgo/configure.ac:USE_DEJAGNU' to 'yes', and observing that my
> "quick hack to replicate the original requirement"
> ('internal_error ("MISSING SYSROOT");') no longer triggers.

Thanks.  Committed.

Ian

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

end of thread, other threads:[~2023-09-12 20:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 18:13 [PATCH 3/4] libgo/test: Fix compilation for build sysroot Maciej W. Rozycki
2019-11-11 23:43 ` [golang-dev] " Ian Lance Taylor
2023-09-12 11:16 ` libgo: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH 3/4] libgo/test: Fix compilation for build sysroot) Thomas Schwinge
2023-09-12 20:20   ` Ian Lance Taylor

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).