mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

gcc14-esysroot.patch (2319B)


      1 commit 287f90318af7e4d09f65351355f080d81e4e30d6
      2 Author: James Le Cuirot <chewi@gentoo.org>
      3 Date:   Sun Aug 4 17:02:06 2024 +0100
      4 
      5     gentoo: Allow setting target sysroot with ESYSROOT env var for cross-compilers
      6     
      7     The variable is ignored for native compilers. The --sysroot command line
      8     option takes precedence.
      9     
     10     Signed-off-by: James Le Cuirot <chewi@gentoo.org>
     11 
     12 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
     13 index b14ad30cdf2..fbec579ae32 100644
     14 --- a/gcc/doc/invoke.texi
     15 +++ b/gcc/doc/invoke.texi
     16 @@ -19027,6 +19027,10 @@ for this option.  If your linker does not support this option, the
     17  header file aspect of @option{--sysroot} still works, but the
     18  library aspect does not.
     19  
     20 +On MRRL, this option can also be set for cross-compilers using the
     21 +@env{ESYSROOT} environmnent variable.  The variable is ignored for native
     22 +compilers.  The command line option takes precedence.
     23 +
     24  @opindex no-sysroot-suffix
     25  @item --no-sysroot-suffix
     26  For some targets, a suffix is added to the root directory specified
     27 @@ -37422,6 +37426,12 @@ using GCC also uses these directories when searching for ordinary
     28  libraries for the @option{-l} option (but directories specified with
     29  @option{-L} come first).
     30  
     31 +@vindex ESYSROOT
     32 +@item ESYSROOT
     33 +On MRRL, this variable sets the logical root directory for headers and
     34 +libraries for cross-compilers.  It is ignored for native compilers.  The
     35 +@option{--sysroot} option takes precedence.
     36 +
     37  @vindex LANG
     38  @cindex locale definition
     39  @item LANG
     40 diff --git a/gcc/gcc.cc b/gcc/gcc.cc
     41 index 825ad1cb5e7..cf42ecf5b12 100644
     42 --- a/gcc/gcc.cc
     43 +++ b/gcc/gcc.cc
     44 @@ -5507,6 +5507,16 @@ process_command (unsigned int decoded_options_count,
     45  	      "BINUTILS", PREFIX_PRIORITY_LAST, 0, 1);
     46    free (tooldir_prefix);
     47  
     48 +  if (*cross_compile == '1' && !target_system_root_changed)
     49 +    {
     50 +      const char *esysroot = env.get("ESYSROOT");
     51 +      if (esysroot && esysroot[0] != '\0' && strcmp(esysroot, "/") != 0 && (!target_system_root || strcmp(esysroot, target_system_root) != 0))
     52 +	{
     53 +	  target_system_root = esysroot;
     54 +	  target_system_root_changed = 1;
     55 +	}
     56 +    }
     57 +
     58  #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS)
     59    /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix,
     60       then consider it to relocate with the rest of the GCC installation