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

Message ID 875y4fzqca.fsf@euler.schwinge.homeip.net
State Accepted
Headers
Series 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]) |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Thomas Schwinge Sept. 12, 2023, 9:35 a.m. UTC
  Hi!

On 2023-06-02T11:52:04+0200, I wrote:
> On 2020-01-14T21:31:13+0800, Chung-Lin Tang <chunglin_tang@mentor.com> wrote:
>> I understand your situation with --with-build-sysroot/--without-sysroot, [...]
>>
>> Can you test if the attached patch works for you? The patch exports the build sysroot
>> setting from the toplevel to target library subdirs, and adds the --sysroot= option
>> when doing build-tree testing [...]
>
> Belatedly: thanks, I like that approach better indeed.
>
> This is, by the way, in line with what GCC compiler testing is doing;
> 'gcc/Makefile.in':
>
>     # Set if the compiler was configured with --with-build-sysroot.
>     SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
>
>     # TEST_ALWAYS_FLAGS are flags that should be passed to every compilation.
>     # They are passed first to allow individual tests to override them.
>             @echo "set TEST_ALWAYS_FLAGS \"$(SYSROOT_CFLAGS_FOR_TARGET)\"" >> ./site.tmp
>
> That is, via 'site.exp', put 'SYSROOT_CFLAGS_FOR_TARGET' into
> 'TEST_ALWAYS_FLAGS', which is "passed to every compilation".
>
>> [...], if this does work, then other library testsuites (e.g. libatomic.exp) might
>> also need considering updating, I think.
>
> Correct.  (I'm offering to take care of that.)

First, regarding the top-level build system part:

>> 2020-01-14  Chung-Lin Tang  <cltang@codesourcery.com>
>>
>>       * Makefile.tpl  (NORMAL_TARGET_EXPORTS): Add export of
>>       SYSROOT_CFLAGS_FOR_TARGET variable.
>>       * Makefile.in:  Regenerate.

>> --- Makefile.tpl      (revision 279954)
>> +++ Makefile.tpl      (working copy)
>> @@ -322,6 +322,7 @@ RAW_CXX_TARGET_EXPORTS = \
>>
>>  NORMAL_TARGET_EXPORTS = \
>>       $(BASE_TARGET_EXPORTS) \
>> +     SYSROOT_CFLAGS_FOR_TARGET="$(SYSROOT_CFLAGS_FOR_TARGET)"; export SYSROOT_CFLAGS_FOR_TARGET; \
>>       CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
>
> With that one moved into the generic 'BASE_TARGET_EXPORTS', [...]

Pushed to master branch commit d1bff1ba4d470f6723be83c0e3c4d5083e51877a
"Pass 'SYSROOT_CFLAGS_FOR_TARGET' down to target libraries [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
  

Patch

From d1bff1ba4d470f6723be83c0e3c4d5083e51877a Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 1 Jun 2023 23:07:37 +0200
Subject: [PATCH] Pass 'SYSROOT_CFLAGS_FOR_TARGET' down to target libraries
 [PR109951]

..., where we need to use it (separate commits) for build-tree testing, similar
to 'gcc/Makefile.in:site.exp':

    # TEST_ALWAYS_FLAGS are flags that should be passed to every compilation.
    # They are passed first to allow individual tests to override them.
    	@echo "set TEST_ALWAYS_FLAGS \"$(SYSROOT_CFLAGS_FOR_TARGET)\"" >> ./site.tmp

	PR testsuite/109951
	* Makefile.tpl (BASE_TARGET_EXPORTS): Add
	'SYSROOT_CFLAGS_FOR_TARGET'.
	* Makefile.in: Regenerate.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
---
 Makefile.in  | 1 +
 Makefile.tpl | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Makefile.in b/Makefile.in
index c97130a2338..2f136839c35 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -321,6 +321,7 @@  BASE_TARGET_EXPORTS = \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	READELF="$(READELF_FOR_TARGET)"; export READELF; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
+	SYSROOT_CFLAGS_FOR_TARGET="$(SYSROOT_CFLAGS_FOR_TARGET)"; export SYSROOT_CFLAGS_FOR_TARGET; \
 	WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
 	WINDMC="$(WINDMC_FOR_TARGET)"; export WINDMC; \
 @if gcc-bootstrap
diff --git a/Makefile.tpl b/Makefile.tpl
index 36fa20950d4..5872dd03f2c 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -324,6 +324,7 @@  BASE_TARGET_EXPORTS = \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	READELF="$(READELF_FOR_TARGET)"; export READELF; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
+	SYSROOT_CFLAGS_FOR_TARGET="$(SYSROOT_CFLAGS_FOR_TARGET)"; export SYSROOT_CFLAGS_FOR_TARGET; \
 	WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
 	WINDMC="$(WINDMC_FOR_TARGET)"; export WINDMC; \
 @if gcc-bootstrap
-- 
2.34.1