public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot
@ 2020-04-20 13:18 Maciej W. Rozycki
  2020-04-22 18:04 ` Jeff Law
  2023-09-12 10:58 ` libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot) Thomas Schwinge
  0 siblings, 2 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2020-04-20 13:18 UTC (permalink / raw)
  To: gcc-patches
  Cc: Jeff Law, Mike Stump, Chung-Lin Tang, Ian Lance Taylor, libffi-discuss

Fix a problem with the libffi 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 
inability to actually choose any compiler at all in a cross-compilation 
configuration.

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

FAIL: libffi.call/closure_fn0.c -W -Wall -Wno-psabi -O0 (test for excess errors)
Excess errors:
default_target_compile: No compiler to compile with
UNRESOLVED: libffi.call/closure_fn0.c -W -Wall -Wno-psabi -O0 compilation failed to produce executable

and bringing 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:

		=== libffi Summary ===

# of unexpected failures	708
# of unresolved testcases	708
# of unsupported tests		30

to:

		=== libffi Summary ===

# of expected passes		1934
# of unsupported tests		28

This is a combined backport of the relevant parts of upstream libffi 
changes as follows:

- commit 8308984e479e ("[PATCH] Make sure we're running dejagnu tests 
  with the right compiler."),

- commit 2d9b3939751b ("[PATCH] Fix for closures with sunpro compiler"),

- commit 0c3824702d3d ("[PATCH] Always set CC_FOR_TARGET for dejagnu, to
  make the testsuite respect $CC"),

- commit 7d698125b1f0 ("[PATCH] Use the proper C++ compiler to run C++
  tests"),

- commit 6b6df1a7bb37 ("[PATCH] Adds `local.exp` to CLEANFILES"),

- commit 6cf0dea78a5a ("[PATCH] Change CLEANFILES to DISTCLEANFILES")

	libffi/
	* Makefile.am (DISTCLEANFILES): New variable.
	* configure.ac: Produce `local.exp'.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New 
	variable.
	* testsuite/Makefile.in: Regenerate.
---
Hi,

 As you may recall I have proposed a clean solution for the problem 
discussed here, which I posted for inclusion with upstream libffi, with an 
intent to have it backported to GCC as soon as it has been accepted by the 
maintainer, as a part of patch series that have been archived here: 
<https://sourceware.org/pipermail/libffi-discuss/2020/002502.html>.

 I have pinged the series last week:
<https://sourceware.org/pipermail/libffi-discuss/2020/002517.html>, 
and then again just now: 
<https://sourceware.org/pipermail/libffi-discuss/2020/002518.html>.

 I think with the GCC 10 release about to be rolled out we need a 
contingency plan, so I propose that, unless my proposed libffi changes 
have been accepted upstream real soon now, such as by the end of this 
coming Friday AoE, we include this change instead.

 Therefore, OK to apply once Friday AoE has passed and the upstream libffi 
changes have gone nowhere?

  Maciej

[Change log corrected to include history before v4.]

Changes from v4:

- Replace with a backport of the partially complete solution already 
  present upstream.

Changes from v3:

- Replace with a backport of a change submitted upstream.

Changes from v2:

- Revert to v1.

- Rename testsuite/libffi-test-support.exp.in to
  testsuite/libffi-site-extra.exp.in.

Changes from v1:

- Remove testsuite/libffi-test-support.exp.in and the associated changes.

- Pass $(CC) via `--tool_exec' in $(AM_RUNTESTFLAGS).
---
 libffi/Makefile.am           |    3 +++
 libffi/Makefile.in           |    4 ++++
 libffi/configure             |    5 +++++
 libffi/configure.ac          |    5 +++++
 libffi/testsuite/Makefile.am |    2 ++
 libffi/testsuite/Makefile.in |    1 +
 6 files changed, 20 insertions(+)

gcc-test-libffi-cc-for-target.diff
Index: gcc/libffi/Makefile.am
===================================================================
--- gcc.orig/libffi/Makefile.am
+++ gcc/libffi/Makefile.am
@@ -15,6 +15,9 @@ EXTRA_DIST = LICENSE ChangeLog.v1 Change
 	libffi.xcodeproj/project.pbxproj				\
 	libtool-ldflags
 
+# local.exp is generated by configure
+DISTCLEANFILES = local.exp
+
 # Automake Documentation:
 # If your package has Texinfo files in many directories, you can use the
 # variable TEXINFO_TEX to tell Automake where to find the canonical
Index: gcc/libffi/Makefile.in
===================================================================
--- gcc.orig/libffi/Makefile.in
+++ gcc/libffi/Makefile.in
@@ -454,6 +454,9 @@ EXTRA_DIST = LICENSE ChangeLog.v1 Change
 	libtool-ldflags
 
 
+# local.exp is generated by configure
+DISTCLEANFILES = local.exp
+
 # Automake Documentation:
 # If your package has Texinfo files in many directories, you can use the
 # variable TEXINFO_TEX to tell Automake where to find the canonical
@@ -1674,6 +1677,7 @@ installcheck: installcheck-recursive
 	-rm -f src/x86/$(am__dirstamp)
 	-rm -f src/xtensa/$(DEPDIR)/$(am__dirstamp)
 	-rm -f src/xtensa/$(am__dirstamp)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
Index: gcc/libffi/configure
===================================================================
--- gcc.orig/libffi/configure
+++ gcc/libffi/configure
@@ -14961,6 +14961,11 @@ _ACEOF
 
 
 
+cat > local.exp <<EOF
+set CC_FOR_TARGET "$CC"
+set CXX_FOR_TARGET "$CXX"
+EOF
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
Index: gcc/libffi/configure.ac
===================================================================
--- gcc.orig/libffi/configure.ac
+++ gcc/libffi/configure.ac
@@ -61,6 +61,11 @@ AC_PROG_LIBTOOL
 # Test for 64-bit build.
 AC_CHECK_SIZEOF([size_t])
 
+cat > local.exp <<EOF
+set CC_FOR_TARGET "$CC"
+set CXX_FOR_TARGET "$CXX"
+EOF
+
 AM_MAINTAINER_MODE
 
 AC_CHECK_HEADERS(sys/mman.h)
Index: gcc/libffi/testsuite/Makefile.am
===================================================================
--- gcc.orig/libffi/testsuite/Makefile.am
+++ gcc/libffi/testsuite/Makefile.am
@@ -13,6 +13,8 @@ RUNTEST = `if [ -f $(top_srcdir)/../deja
 
 AM_RUNTESTFLAGS =
 
+EXTRA_DEJAGNU_SITE_CONFIG=../local.exp
+
 CLEANFILES = *.exe core* *.log *.sum
 
 EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c		\
Index: gcc/libffi/testsuite/Makefile.in
===================================================================
--- gcc.orig/libffi/testsuite/Makefile.in
+++ gcc/libffi/testsuite/Makefile.in
@@ -279,6 +279,7 @@ RUNTEST = `if [ -f $(top_srcdir)/../deja
 	       echo $(top_srcdir)/../dejagnu/runtest ; \
 	    else echo runtest; fi`
 
+EXTRA_DEJAGNU_SITE_CONFIG = ../local.exp
 CLEANFILES = *.exe core* *.log *.sum
 EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c		\
 libffi.call/cls_align_longdouble_split.c				\

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

* Re: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot
  2020-04-20 13:18 [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot Maciej W. Rozycki
@ 2020-04-22 18:04 ` Jeff Law
  2020-04-25 20:33   ` Maciej W. Rozycki
  2023-09-12 10:58 ` libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot) Thomas Schwinge
  1 sibling, 1 reply; 8+ messages in thread
From: Jeff Law @ 2020-04-22 18:04 UTC (permalink / raw)
  To: Maciej W. Rozycki, gcc-patches
  Cc: Mike Stump, Chung-Lin Tang, Ian Lance Taylor, libffi-discuss

On Mon, 2020-04-20 at 14:18 +0100, Maciej W. Rozycki wrote:
> Fix a problem with the libffi 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 
> inability to actually choose any compiler at all in a cross-compilation 
> configuration.
> 
> Address this problem by providing a DejaGNU configuration file defining 
> the compiler to use, via the CC_FOR_TARGET TCL variable, set from $CC by 
> autoconf, which will have all the required options set for the target 
> compiler to build executables in the environment configured, removing 
> failures like:
> 
> FAIL: libffi.call/closure_fn0.c -W -Wall -Wno-psabi -O0 (test for excess
> errors)
> Excess errors:
> default_target_compile: No compiler to compile with
> UNRESOLVED: libffi.call/closure_fn0.c -W -Wall -Wno-psabi -O0 compilation
> failed to produce executable
> 
> and bringing 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:
> 
> 		=== libffi Summary ===
> 
> # of unexpected failures	708
> # of unresolved testcases	708
> # of unsupported tests		30
> 
> to:
> 
> 		=== libffi Summary ===
> 
> # of expected passes		1934
> # of unsupported tests		28
> 
> This is a combined backport of the relevant parts of upstream libffi 
> changes as follows:
> 
> - commit 8308984e479e ("[PATCH] Make sure we're running dejagnu tests 
>   with the right compiler."),
> 
> - commit 2d9b3939751b ("[PATCH] Fix for closures with sunpro compiler"),
> 
> - commit 0c3824702d3d ("[PATCH] Always set CC_FOR_TARGET for dejagnu, to
>   make the testsuite respect $CC"),
> 
> - commit 7d698125b1f0 ("[PATCH] Use the proper C++ compiler to run C++
>   tests"),
> 
> - commit 6b6df1a7bb37 ("[PATCH] Adds `local.exp` to CLEANFILES"),
> 
> - commit 6cf0dea78a5a ("[PATCH] Change CLEANFILES to DISTCLEANFILES")
> 
> 	libffi/
> 	* Makefile.am (DISTCLEANFILES): New variable.
> 	* configure.ac: Produce `local.exp'.
> 	* Makefile.in: Regenerate.
> 	* configure: Regenerate.
> 	* testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New 
> 	variable.
> 	* testsuite/Makefile.in: Regenerate.
OK
jeff
> 


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

* Re: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot
  2020-04-22 18:04 ` Jeff Law
@ 2020-04-25 20:33   ` Maciej W. Rozycki
  2020-04-29 17:14     ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: Maciej W. Rozycki @ 2020-04-25 20:33 UTC (permalink / raw)
  To: Jeff Law
  Cc: gcc-patches, Mike Stump, Chung-Lin Tang, Ian Lance Taylor,
	libffi-discuss

On Wed, 22 Apr 2020, Jeff Law wrote:

> > 	libffi/
> > 	* Makefile.am (DISTCLEANFILES): New variable.
> > 	* configure.ac: Produce `local.exp'.
> > 	* Makefile.in: Regenerate.
> > 	* configure: Regenerate.
> > 	* testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New 
> > 	variable.
> > 	* testsuite/Makefile.in: Regenerate.
> OK
> jeff

 Committed now then, according to schedule, thanks for your review.  We 
may revisit the backport of improvements I previously proposed when/if the 
upstream libffi maintainer decides to accept them.

  Maciej

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

* Re: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot
  2020-04-25 20:33   ` Maciej W. Rozycki
@ 2020-04-29 17:14     ` Jeff Law
  2020-04-29 20:48       ` Florian Weimer
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2020-04-29 17:14 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: gcc-patches, Mike Stump, Chung-Lin Tang, Ian Lance Taylor,
	libffi-discuss

On Sat, 2020-04-25 at 21:33 +0100, Maciej W. Rozycki wrote:
> On Wed, 22 Apr 2020, Jeff Law wrote:
> 
> > > 	libffi/
> > > 	* Makefile.am (DISTCLEANFILES): New variable.
> > > 	* configure.ac: Produce `local.exp'.
> > > 	* Makefile.in: Regenerate.
> > > 	* configure: Regenerate.
> > > 	* testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New 
> > > 	variable.
> > > 	* testsuite/Makefile.in: Regenerate.
> > OK
> > jeff
> 
>  Committed now then, according to schedule, thanks for your review.  We 
> may revisit the backport of improvements I previously proposed when/if the 
> upstream libffi maintainer decides to accept them.
ACK.

FWIW, I'm expecting Florian to be digging into some libffi stuff relatively soon
and once those issues are ironed out, there'll be a push for a libffi upstream
release -- which seems like a good place to re-sync GCC to the upstream libffi
master.

jeff


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

* Re: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot
  2020-04-29 17:14     ` Jeff Law
@ 2020-04-29 20:48       ` Florian Weimer
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Weimer @ 2020-04-29 20:48 UTC (permalink / raw)
  To: Jeff Law via Libffi-discuss
  Cc: Maciej W. Rozycki, law, Mike Stump, gcc-patches,
	Ian Lance Taylor, Chung-Lin Tang

* Jeff Law via Libffi-discuss:

> FWIW, I'm expecting Florian to be digging into some libffi stuff
> relatively soon and once those issues are ironed out, there'll be a
> push for a libffi upstream release -- which seems like a good place
> to re-sync GCC to the upstream libffi master.

I'm not going to work on the master branch for now, so this should not
impact the release.  The goal is specifically to support more hardware
for legacy binaries with the old libffi.so.6 soname.

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

* libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot)
  2020-04-20 13:18 [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot Maciej W. Rozycki
  2020-04-22 18:04 ` Jeff Law
@ 2023-09-12 10:58 ` Thomas Schwinge
  2023-10-25  8:30   ` [PING] " Thomas Schwinge
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Schwinge @ 2023-09-12 10:58 UTC (permalink / raw)
  To: gcc-patches
  Cc: Maciej W. Rozycki, libffi-discuss, H.J.Lu, Rainer Orth,
	Mike Stump, Iain Sandoe

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

Hi!

On 2020-04-20T14:18:40+0100, "Maciej W. Rozycki via Gcc-patches" <gcc-patches@gcc.gnu.org> wrote:
> Fix a problem with the libffi 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
> inability to actually choose any compiler at all in a cross-compilation
> configuration.

This has since, as far as I can tell, been resolved properly by H.J. Lu's
GCC commit 5be7b66998127286fada45e4f23bd8a2056d553e,
"libffi: Integrate build with GCC", and
GCC commit 4824ed41ba7cd63e60fd9f8769a58b79935a90d1
"libffi: Integrate testsuite with GCC testsuite".

> Address this problem by providing a DejaGNU configuration file defining
> the compiler to use, via the CC_FOR_TARGET TCL variable, set from $CC 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 GCC libffi 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 the attached
"libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]"?


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

From 8b8654d04dcbb7f0a5947bc21efc5b9c60b3b6c6 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Mon, 11 Sep 2023 10:50:00 +0200
Subject: [PATCH] libffi: 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 a0b48358cb1e70e161a87ec5deb7a4b25defba6b
"libffi/test: Fix compilation for build sysroot" done differently,
avoiding build-tree testing use of any random gunk that may appear in
build-time 'CC', 'CXX'.

	PR testsuite/109951
	libffi/
	* configure.ac: 'AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)'.
	<local.exp>: Don't set 'CC_FOR_TARGET', 'CXX_FOR_TARGET', instead
	set 'SYSROOT_CFLAGS_FOR_TARGET'.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* include/Makefile.in: Likewise.
	* man/Makefile.in: Likewise.
	* testsuite/Makefile.in: Likewise.
	* testsuite/lib/libffi.exp (libffi_target_compile): If
	'--with-build-sysroot=[...]' was specified, use it for build-tree
	testing.
---
 libffi/Makefile.in              |  1 +
 libffi/configure                | 10 ++++++----
 libffi/configure.ac             |  5 +++--
 libffi/include/Makefile.in      |  1 +
 libffi/man/Makefile.in          |  1 +
 libffi/testsuite/Makefile.in    |  1 +
 libffi/testsuite/lib/libffi.exp |  7 +++++++
 7 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/libffi/Makefile.in b/libffi/Makefile.in
index 1d936b5c8a5..3a55212cc00 100644
--- a/libffi/Makefile.in
+++ b/libffi/Makefile.in
@@ -383,6 +383,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/configure b/libffi/configure
index 9eac9c907bf..f1efd6987a3 100755
--- a/libffi/configure
+++ b/libffi/configure
@@ -666,6 +666,7 @@ TESTSUBDIR_TRUE
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
+SYSROOT_CFLAGS_FOR_TARGET
 READELF
 CXXCPP
 CPP
@@ -11634,7 +11635,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11637 "configure"
+#line 11638 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11740,7 +11741,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11743 "configure"
+#line 11744 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15137,9 +15138,10 @@ _ACEOF
 
 
 
+
+
 cat > local.exp <<EOF
-set CC_FOR_TARGET "$CC"
-set CXX_FOR_TARGET "$CXX"
+set SYSROOT_CFLAGS_FOR_TARGET "$SYSROOT_CFLAGS_FOR_TARGET"
 set compiler_vendor "$ax_cv_c_compiler_vendor"
 EOF
 
diff --git a/libffi/configure.ac b/libffi/configure.ac
index 014d89d0423..0381d178f66 100644
--- a/libffi/configure.ac
+++ b/libffi/configure.ac
@@ -61,9 +61,10 @@ AC_CHECK_TOOL(READELF, readelf)
 # Test for 64-bit build.
 AC_CHECK_SIZEOF([size_t])
 
+AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
+
 cat > local.exp <<EOF
-set CC_FOR_TARGET "$CC"
-set CXX_FOR_TARGET "$CXX"
+set SYSROOT_CFLAGS_FOR_TARGET "$SYSROOT_CFLAGS_FOR_TARGET"
 set compiler_vendor "$ax_cv_c_compiler_vendor"
 EOF
 
diff --git a/libffi/include/Makefile.in b/libffi/include/Makefile.in
index 879cb72296d..9759f0d91dc 100644
--- a/libffi/include/Makefile.in
+++ b/libffi/include/Makefile.in
@@ -255,6 +255,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/man/Makefile.in b/libffi/man/Makefile.in
index 9d4f96608c4..18de1e836f5 100644
--- a/libffi/man/Makefile.in
+++ b/libffi/man/Makefile.in
@@ -237,6 +237,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/testsuite/Makefile.in b/libffi/testsuite/Makefile.in
index a19b523e54a..27d48a7ad7a 100644
--- a/libffi/testsuite/Makefile.in
+++ b/libffi/testsuite/Makefile.in
@@ -210,6 +210,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/testsuite/lib/libffi.exp b/libffi/testsuite/lib/libffi.exp
index 15d3d5ebd73..6dc0bc1d77f 100644
--- a/libffi/testsuite/lib/libffi.exp
+++ b/libffi/testsuite/lib/libffi.exp
@@ -369,6 +369,13 @@ proc libffi_target_compile { source dest type options } {
 	lappend options "ldflags=$wrap_flags"
     }
 
+    if { $blddirffi != "" } {
+	# If '--with-build-sysroot=[...]' was specified, use it for build-tree
+	# testing.
+	global SYSROOT_CFLAGS_FOR_TARGET
+	lappend options "additional_flags=${SYSROOT_CFLAGS_FOR_TARGET}"
+    }
+
     # TOOL_OPTIONS must come first, so that it doesn't override testcase
     # specific options.
     if [info exists TOOL_OPTIONS] {
-- 
2.34.1


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

* [PING] libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot)
  2023-09-12 10:58 ` libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot) Thomas Schwinge
@ 2023-10-25  8:30   ` Thomas Schwinge
  2023-10-26 13:32     ` [PING] libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Schwinge @ 2023-10-25  8:30 UTC (permalink / raw)
  To: gcc-patches; +Cc: Iain Sandoe, libffi-discuss, Maciej W. Rozycki

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

Hi!

Ping.


Grüße
 Thomas


On 2023-09-12T12:58:27+0200, I wrote:
> Hi!
>
> On 2020-04-20T14:18:40+0100, "Maciej W. Rozycki via Gcc-patches" <gcc-patches@gcc.gnu.org> wrote:
>> Fix a problem with the libffi 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
>> inability to actually choose any compiler at all in a cross-compilation
>> configuration.
>
> This has since, as far as I can tell, been resolved properly by H.J. Lu's
> GCC commit 5be7b66998127286fada45e4f23bd8a2056d553e,
> "libffi: Integrate build with GCC", and
> GCC commit 4824ed41ba7cd63e60fd9f8769a58b79935a90d1
> "libffi: Integrate testsuite with GCC testsuite".
>
>> Address this problem by providing a DejaGNU configuration file defining
>> the compiler to use, via the CC_FOR_TARGET TCL variable, set from $CC 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 GCC libffi 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 the attached
> "libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]"?
>
>
> 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-libffi-Consider-with-build-sysroot-.-for-target-libr.patch --]
[-- Type: text/x-diff, Size: 5237 bytes --]

From 8b8654d04dcbb7f0a5947bc21efc5b9c60b3b6c6 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Mon, 11 Sep 2023 10:50:00 +0200
Subject: [PATCH] libffi: 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 a0b48358cb1e70e161a87ec5deb7a4b25defba6b
"libffi/test: Fix compilation for build sysroot" done differently,
avoiding build-tree testing use of any random gunk that may appear in
build-time 'CC', 'CXX'.

	PR testsuite/109951
	libffi/
	* configure.ac: 'AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)'.
	<local.exp>: Don't set 'CC_FOR_TARGET', 'CXX_FOR_TARGET', instead
	set 'SYSROOT_CFLAGS_FOR_TARGET'.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* include/Makefile.in: Likewise.
	* man/Makefile.in: Likewise.
	* testsuite/Makefile.in: Likewise.
	* testsuite/lib/libffi.exp (libffi_target_compile): If
	'--with-build-sysroot=[...]' was specified, use it for build-tree
	testing.
---
 libffi/Makefile.in              |  1 +
 libffi/configure                | 10 ++++++----
 libffi/configure.ac             |  5 +++--
 libffi/include/Makefile.in      |  1 +
 libffi/man/Makefile.in          |  1 +
 libffi/testsuite/Makefile.in    |  1 +
 libffi/testsuite/lib/libffi.exp |  7 +++++++
 7 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/libffi/Makefile.in b/libffi/Makefile.in
index 1d936b5c8a5..3a55212cc00 100644
--- a/libffi/Makefile.in
+++ b/libffi/Makefile.in
@@ -383,6 +383,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/configure b/libffi/configure
index 9eac9c907bf..f1efd6987a3 100755
--- a/libffi/configure
+++ b/libffi/configure
@@ -666,6 +666,7 @@ TESTSUBDIR_TRUE
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
+SYSROOT_CFLAGS_FOR_TARGET
 READELF
 CXXCPP
 CPP
@@ -11634,7 +11635,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11637 "configure"
+#line 11638 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11740,7 +11741,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11743 "configure"
+#line 11744 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15137,9 +15138,10 @@ _ACEOF
 
 
 
+
+
 cat > local.exp <<EOF
-set CC_FOR_TARGET "$CC"
-set CXX_FOR_TARGET "$CXX"
+set SYSROOT_CFLAGS_FOR_TARGET "$SYSROOT_CFLAGS_FOR_TARGET"
 set compiler_vendor "$ax_cv_c_compiler_vendor"
 EOF
 
diff --git a/libffi/configure.ac b/libffi/configure.ac
index 014d89d0423..0381d178f66 100644
--- a/libffi/configure.ac
+++ b/libffi/configure.ac
@@ -61,9 +61,10 @@ AC_CHECK_TOOL(READELF, readelf)
 # Test for 64-bit build.
 AC_CHECK_SIZEOF([size_t])
 
+AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
+
 cat > local.exp <<EOF
-set CC_FOR_TARGET "$CC"
-set CXX_FOR_TARGET "$CXX"
+set SYSROOT_CFLAGS_FOR_TARGET "$SYSROOT_CFLAGS_FOR_TARGET"
 set compiler_vendor "$ax_cv_c_compiler_vendor"
 EOF
 
diff --git a/libffi/include/Makefile.in b/libffi/include/Makefile.in
index 879cb72296d..9759f0d91dc 100644
--- a/libffi/include/Makefile.in
+++ b/libffi/include/Makefile.in
@@ -255,6 +255,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/man/Makefile.in b/libffi/man/Makefile.in
index 9d4f96608c4..18de1e836f5 100644
--- a/libffi/man/Makefile.in
+++ b/libffi/man/Makefile.in
@@ -237,6 +237,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/testsuite/Makefile.in b/libffi/testsuite/Makefile.in
index a19b523e54a..27d48a7ad7a 100644
--- a/libffi/testsuite/Makefile.in
+++ b/libffi/testsuite/Makefile.in
@@ -210,6 +210,7 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
 TARGET = @TARGET@
 TARGETDIR = @TARGETDIR@
 TARGET_OBJ = @TARGET_OBJ@
diff --git a/libffi/testsuite/lib/libffi.exp b/libffi/testsuite/lib/libffi.exp
index 15d3d5ebd73..6dc0bc1d77f 100644
--- a/libffi/testsuite/lib/libffi.exp
+++ b/libffi/testsuite/lib/libffi.exp
@@ -369,6 +369,13 @@ proc libffi_target_compile { source dest type options } {
 	lappend options "ldflags=$wrap_flags"
     }
 
+    if { $blddirffi != "" } {
+	# If '--with-build-sysroot=[...]' was specified, use it for build-tree
+	# testing.
+	global SYSROOT_CFLAGS_FOR_TARGET
+	lappend options "additional_flags=${SYSROOT_CFLAGS_FOR_TARGET}"
+    }
+
     # TOOL_OPTIONS must come first, so that it doesn't override testcase
     # specific options.
     if [info exists TOOL_OPTIONS] {
-- 
2.34.1


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

* Re: [PING] libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]
  2023-10-25  8:30   ` [PING] " Thomas Schwinge
@ 2023-10-26 13:32     ` Jeff Law
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Law @ 2023-10-26 13:32 UTC (permalink / raw)
  To: Thomas Schwinge, gcc-patches
  Cc: Iain Sandoe, libffi-discuss, Maciej W. Rozycki



On 10/25/23 02:30, Thomas Schwinge wrote:
> Hi!
> 
> Ping.
> 
> 
> Grüße
>   Thomas
> 
> 
> On 2023-09-12T12:58:27+0200, I wrote:
>> Hi!
>>
>> On 2020-04-20T14:18:40+0100, "Maciej W. Rozycki via Gcc-patches" <gcc-patches@gcc.gnu.org> wrote:
>>> Fix a problem with the libffi 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
>>> inability to actually choose any compiler at all in a cross-compilation
>>> configuration.
>>
>> This has since, as far as I can tell, been resolved properly by H.J. Lu's
>> GCC commit 5be7b66998127286fada45e4f23bd8a2056d553e,
>> "libffi: Integrate build with GCC", and
>> GCC commit 4824ed41ba7cd63e60fd9f8769a58b79935a90d1
>> "libffi: Integrate testsuite with GCC testsuite".
>>
>>> Address this problem by providing a DejaGNU configuration file defining
>>> the compiler to use, via the CC_FOR_TARGET TCL variable, set from $CC 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 GCC libffi 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 the attached
>> "libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]"?
OK (patch didn't appear inline, but hopefully you've got enough context 
to know it's the libffi bits getting ACK'd).

jeff

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

end of thread, other threads:[~2023-10-26 13:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 13:18 [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot Maciej W. Rozycki
2020-04-22 18:04 ` Jeff Law
2020-04-25 20:33   ` Maciej W. Rozycki
2020-04-29 17:14     ` Jeff Law
2020-04-29 20:48       ` Florian Weimer
2023-09-12 10:58 ` libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] (was: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot) Thomas Schwinge
2023-10-25  8:30   ` [PING] " Thomas Schwinge
2023-10-26 13:32     ` [PING] libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951] Jeff Law

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