https://gcc.gnu.org/g:7cd316dfa1e1b716c2a9288284c1b18736019d45

commit r17-6361-g7cd316dfa1e1b716c2a9288284c1b18736019d45
Author: Zhongteng Gui <[email protected]>
Date:   Tue Nov 17 21:39:00 2026 +0800

    Pass target sysroot flags to bootstrap compiler
    
    When --with-build-sysroot is used, most target compiler invocations
    receive SYSROOT_CFLAGS_FOR_TARGET through XGCC_FLAGS_FOR_TARGET.
    However, GCC_FOR_TARGET and the post-stage1 C++ compiler are assembled
    separately, and therefore miss the configured sysroot.  Similarly,
    gnattools constructs its native and rebuild CC and CXX commands directly.
    
    Without these flags, configure tests performed in later bootstrap
    stages can fail to find the target headers or startup files, reporting
    that the C++ compiler cannot create executables.  Native gnattools can
    also invoke xg++ without the build sysroot when linking its programs,
    causing the target linker to fail to find crt2.o and default-manifest.o.
    
    Add SYSROOT_CFLAGS_FOR_TARGET to GCC_FOR_TARGET and the post-stage1 C++
    compiler.  Pass XGCC_FLAGS_FOR_TARGET to the compiler commands used by
    native and rebuilt gnattools.
    
            PR bootstrap/126722
    /
            * Makefile.in: Regenerate.
            * Makefile.tpl (POSTSTAGE1_CXX_EXPORT): Add
            SYSROOT_CFLAGS_FOR_TARGET.
            (GCC_FOR_TARGET): Likewise.
    
    gnattools/
            * Makefile.in (CXX_LFLAGS): Add XGCC_FLAGS_FOR_TARGET.

Diff:
---
 Makefile.in           | 3 ++-
 Makefile.tpl          | 3 ++-
 gnattools/Makefile.in | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index dabe88d42c76..662cd1b1d694 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,6 +266,7 @@ POSTSTAGE1_CXX_EXPORT = \
          `if $(LEAN); then echo ' -isystem '; else echo ' -I'; 
fi`$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/include/$(TARGET_SUBDIR) \
          `if $(LEAN); then echo ' -isystem '; else echo ' -I'; 
fi`$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/include \
          `if $(LEAN); then echo ' -isystem '; else echo ' -I'; 
fi`$$s/libstdc++-v3/libsupc++ \
+         $(SYSROOT_CFLAGS_FOR_TARGET) \
          -L$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/src/.libs \
          -L$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs"; \
          export CXX; \
@@ -720,7 +721,7 @@ CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@
 # variable is passed down to the gcc Makefile, where it is used to
 # build libgcc2.a.  We define it here so that it can itself be
 # overridden on the command line.
-GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@
+GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@ 
$(SYSROOT_CFLAGS_FOR_TARGET)
 CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@
 RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@
 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
diff --git a/Makefile.tpl b/Makefile.tpl
index 83870fccccfe..e89588b66d34 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -269,6 +269,7 @@ POSTSTAGE1_CXX_EXPORT = \
          `if $(LEAN); then echo ' -isystem '; else echo ' -I'; 
fi`$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/include/$(TARGET_SUBDIR) \
          `if $(LEAN); then echo ' -isystem '; else echo ' -I'; 
fi`$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/include \
          `if $(LEAN); then echo ' -isystem '; else echo ' -I'; 
fi`$$s/libstdc++-v3/libsupc++ \
+         $(SYSROOT_CFLAGS_FOR_TARGET) \
          -L$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/src/.libs \
          -L$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs"; \
          export CXX; \
@@ -627,7 +628,7 @@ CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@
 # variable is passed down to the gcc Makefile, where it is used to
 # build libgcc2.a.  We define it here so that it can itself be
 # overridden on the command line.
-GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@
+GCC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCC_FOR_TARGET@ 
$(SYSROOT_CFLAGS_FOR_TARGET)
 CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@
 RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@
 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@
diff --git a/gnattools/Makefile.in b/gnattools/Makefile.in
index aec880c4fd16..03746dea272d 100644
--- a/gnattools/Makefile.in
+++ b/gnattools/Makefile.in
@@ -76,7 +76,8 @@ CXX_LFLAGS = \
  -B../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
  -B../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \
  -L../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
- -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs
+ -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \
+ $(XGCC_FLAGS_FOR_TARGET)
 
 # Variables for gnattools, native
 TOOLS_FLAGS_TO_PASS_NATIVE= \

Reply via email to