Jelajahi Sumber

* change convention for searching sysroot library paths to be the same as the
one used by GNU ld: only search for library paths in the sysroot if they
are built into the compiler or start with "=". Previously, all
user-provided library paths were also searched in the sysroot
(mantis #36198)

git-svn-id: trunk@43279 -

Jonas Maebe 5 tahun lalu
induk
melakukan
78fb35525f
4 mengubah file dengan 33 tambahan dan 36 penghapusan
  1. 6 3
      compiler/cfileutl.pas
  2. 3 9
      compiler/options.pas
  3. 3 3
      compiler/systems/t_bsd.pas
  4. 21 21
      compiler/systems/t_linux.pas

+ 6 - 3
compiler/cfileutl.pas

@@ -99,7 +99,7 @@ interface
 
 
       TSearchPathList = class(TCmdStrList)
       TSearchPathList = class(TCmdStrList)
         procedure AddPath(s:TCmdStr;addfirst:boolean);overload;
         procedure AddPath(s:TCmdStr;addfirst:boolean);overload;
-        procedure AddPath(SrcPath,s:TCmdStr;addfirst:boolean);overload;
+        procedure AddPath(const sysroot: TCmdStr; s:TCmdStr;addfirst:boolean);overload;
         procedure AddList(list:TSearchPathList;addfirst:boolean);
         procedure AddList(list:TSearchPathList;addfirst:boolean);
         function  FindFile(const f : TCmdStr;allowcache:boolean;var foundfile:TCmdStr):boolean;
         function  FindFile(const f : TCmdStr;allowcache:boolean;var foundfile:TCmdStr):boolean;
       end;
       end;
@@ -999,7 +999,7 @@ end;
       end;
       end;
 
 
 
 
-   procedure TSearchPathList.AddPath(SrcPath,s:TCmdStr;addfirst:boolean);
+   procedure TSearchPathList.AddPath(const sysroot: TCmdStr; s:TCmdStr;addfirst:boolean);
      var
      var
        staridx,
        staridx,
        i,j      : longint;
        i,j      : longint;
@@ -1074,7 +1074,10 @@ end;
 
 
          { fix pathname }
          { fix pathname }
          DePascalQuote(currPath);
          DePascalQuote(currPath);
-         currPath:=SrcPath+FixPath(currPath,false);
+         { GNU LD convention: if library search path starts with '=', it's relative to the
+           sysroot; otherwise, interpret it as a regular path }
+         if currPath[1]='=' then
+           currPath:=sysroot+FixPath(copy(currPath,2,length(currPath)-1),false);
          if currPath='' then
          if currPath='' then
            currPath:= CurDirRelPath(source_info)
            currPath:= CurDirRelPath(source_info)
          else
          else

+ 3 - 9
compiler/options.pas

@@ -1678,16 +1678,10 @@ begin
                    Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
                    Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
                  'l' :
                  'l' :
                    begin
                    begin
-                     if path_absolute(More) then
-                       if ispara then
-                         ParaLibraryPath.AddPath(sysrootpath,More,false)
-                       else
-                         LibrarySearchPath.AddPath(sysrootpath,More,true)
+                     if ispara then
+                       ParaLibraryPath.AddPath(sysrootpath,More,false)
                      else
                      else
-                       if ispara then
-                         ParaLibraryPath.AddPath('',More,false)
-                       else
-                         LibrarySearchPath.AddPath('',More,true);
+                       LibrarySearchPath.AddPath(sysrootpath,More,true)
                    end;
                    end;
                  'L' :
                  'L' :
                    begin
                    begin

+ 3 - 3
compiler/systems/t_bsd.pas

@@ -153,11 +153,11 @@ begin
   if not Dontlinkstdlibpath Then
   if not Dontlinkstdlibpath Then
    if target_info.system in systems_darwin then
    if target_info.system in systems_darwin then
      { Mac OS X doesn't have a /lib }
      { Mac OS X doesn't have a /lib }
-     LibrarySearchPath.AddPath(sysrootpath,'/usr/lib',true)
+     LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib',true)
    else if target_info.system in systems_openbsd then
    else if target_info.system in systems_openbsd then
-     LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;$OPENBSD_X11BASE/lib;$OPENBSD_LOCALBASE/lib',true)
+     LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib;=$OPENBSD_X11BASE/lib;=$OPENBSD_LOCALBASE/lib',true)
    else
    else
-     LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true);
+     LibrarySearchPath.AddPath(sysrootpath,'=/lib;=/usr/lib;=/usr/X11R6/lib',true);
 end;
 end;
 
 
 
 

+ 21 - 21
compiler/systems/t_linux.pas

@@ -128,28 +128,28 @@ begin
 {$ifdef x86_64}
 {$ifdef x86_64}
       { some linuxes might not have the lib64 variants (Arch, LFS }
       { some linuxes might not have the lib64 variants (Arch, LFS }
       if PathExists('/usr/X11R6/lib64',true) then
       if PathExists('/usr/X11R6/lib64',true) then
-        LibrarySearchPath.AddPath(sysrootpath,'/usr/X11R6/lib64',true)
+        LibrarySearchPath.AddPath(sysrootpath,'=/usr/X11R6/lib64',true)
       else if PathExists('/usr/X11R6/lib',true) then
       else if PathExists('/usr/X11R6/lib',true) then
-        LibrarySearchPath.AddPath(sysrootpath,'/usr/X11R6/lib',true);
+        LibrarySearchPath.AddPath(sysrootpath,'=/usr/X11R6/lib',true);
 
 
       if PathExists('/usr/lib64',true) then
       if PathExists('/usr/lib64',true) then
-        LibrarySearchPath.AddPath(sysrootpath,'/usr/lib64',true)
+        LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib64',true)
       else if PathExists('/usr/lib',true) then
       else if PathExists('/usr/lib',true) then
-        LibrarySearchPath.AddPath(sysrootpath,'/usr/lib',true);
+        LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib',true);
 
 
       { /lib64 should be the really first, so add it before everything else }
       { /lib64 should be the really first, so add it before everything else }
       if PathExists('/lib64',true) then
       if PathExists('/lib64',true) then
-        LibrarySearchPath.AddPath(sysrootpath,'/lib64',true)
+        LibrarySearchPath.AddPath(sysrootpath,'=/lib64',true)
       else if PathExists('/lib',true) then
       else if PathExists('/lib',true) then
-        LibrarySearchPath.AddPath(sysrootpath,'/lib',true);
+        LibrarySearchPath.AddPath(sysrootpath,'=/lib',true);
 {$else}
 {$else}
 {$ifdef powerpc64}
 {$ifdef powerpc64}
       if target_info.abi<>abi_powerpc_elfv2 then
       if target_info.abi<>abi_powerpc_elfv2 then
-        LibrarySearchPath.AddPath(sysrootpath,'/lib64;/usr/lib64;/usr/X11R6/lib64',true)
+        LibrarySearchPath.AddPath(sysrootpath,'=/lib64;=/usr/lib64;=/usr/X11R6/lib64',true)
       else
       else
-        LibrarySearchPath.AddPath(sysrootpath,'/lib64;/usr/lib/powerpc64le-linux-gnu;/usr/X11R6/powerpc64le-linux-gnu',true);
+        LibrarySearchPath.AddPath(sysrootpath,'=/lib64;=/usr/lib/powerpc64le-linux-gnu;=/usr/X11R6/powerpc64le-linux-gnu',true);
 {$else powerpc64}
 {$else powerpc64}
-      LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/lib;=/usr/lib;=/usr/X11R6/lib',true);
 {$endif powerpc64}
 {$endif powerpc64}
 {$endif x86_64}
 {$endif x86_64}
 
 
@@ -157,41 +157,41 @@ begin
   { some newer Debian have the crt*.o files at uncommon locations,
   { some newer Debian have the crt*.o files at uncommon locations,
     for other arm flavours, this cannot hurt }
     for other arm flavours, this cannot hurt }
 {$ifdef FPC_ARMHF}
 {$ifdef FPC_ARMHF}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/arm-linux-gnueabihf',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/arm-linux-gnueabihf',true);
 {$endif FPC_ARMHF}
 {$endif FPC_ARMHF}
 {$ifdef FPC_ARMEL}
 {$ifdef FPC_ARMEL}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/arm-linux-gnueabi',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/arm-linux-gnueabi',true);
 {$endif}
 {$endif}
 {$endif arm}
 {$endif arm}
 {$ifdef x86_64}
 {$ifdef x86_64}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/x86_64-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/x86_64-linux-gnu',true);
 {$endif x86_64}
 {$endif x86_64}
 {$ifdef i386}
 {$ifdef i386}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/i386-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/i386-linux-gnu',true);
 {$endif i386}
 {$endif i386}
 {$ifdef aarch64}
 {$ifdef aarch64}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/aarch64-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/aarch64-linux-gnu',true);
 {$endif aarch64}
 {$endif aarch64}
 {$ifdef powerpc}
 {$ifdef powerpc}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/powerpc-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/powerpc-linux-gnu',true);
 {$endif powerpc}
 {$endif powerpc}
 {$ifdef m68k}
 {$ifdef m68k}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/m68k-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/m68k-linux-gnu',true);
 {$endif m68k}
 {$endif m68k}
 {$ifdef mipsel}
 {$ifdef mipsel}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/mipsel-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/mipsel-linux-gnu',true);
 {$endif mipsel}
 {$endif mipsel}
 {$ifdef mips}
 {$ifdef mips}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/mips-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/mips-linux-gnu',true);
 {$endif mips}
 {$endif mips}
 {$ifdef sparc64}
 {$ifdef sparc64}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/sparc64-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/sparc64-linux-gnu',true);
 {$endif sparc64}
 {$endif sparc64}
 {$ifdef riscv32}
 {$ifdef riscv32}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/riscv32-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/riscv32-linux-gnu',true);
 {$endif riscv32}
 {$endif riscv32}
 {$ifdef riscv64}
 {$ifdef riscv64}
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/riscv64-linux-gnu',true);
+      LibrarySearchPath.AddPath(sysrootpath,'=/usr/lib/riscv64-linux-gnu',true);
 {$endif riscv64}
 {$endif riscv64}
     end;
     end;
 end;
 end;