瀏覽代碼

* fixed opt-in sysroot substitution again, renamed the three-argument version
TSearchPathList.AddPath() to AddLibraryPath() to make it clear it's only
to be used for adding library search paths (and replaced one case where
it was used for a source file search path with a call to the
two-argument version)
* also added some missing '=' prefixes to built-in library search paths,
and fixed wrong DirectoryExists checks in t_linux in case of using
a sysroot, cross-compiling or linking on target

git-svn-id: trunk@43312 -

Jonas Maebe 5 年之前
父節點
當前提交
6483b3f5e3

+ 4 - 6
compiler/cfileutl.pas

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

+ 2 - 2
compiler/options.pas

@@ -1679,9 +1679,9 @@ begin
                  'l' :
                    begin
                      if ispara then
-                       ParaLibraryPath.AddPath(sysrootpath,More,false)
+                       ParaLibraryPath.AddLibraryPath(sysrootpath,More,false)
                      else
-                       LibrarySearchPath.AddPath(sysrootpath,More,true)
+                       LibrarySearchPath.AddLibraryPath(sysrootpath,More,true)
                    end;
                  'L' :
                    begin

+ 1 - 1
compiler/scandir.pas

@@ -1510,7 +1510,7 @@ unit scandir;
           with current_scanner,current_module,localunitsearchpath do
             begin
               skipspace;
-              AddPath(path,readcomment,false);
+              AddPath(path+source_info.DirSep+readcomment,false);
             end;
       end;
 

+ 2 - 2
compiler/systems/t_aix.pas

@@ -101,9 +101,9 @@ begin
   Inherited Create;
   if not Dontlinkstdlibpath then
     if not(cs_profile in current_settings.moduleswitches) then
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;/usr/X11R6/lib;/opt/freeware/lib',true)
+      LibrarySearchPath.AddLibraryPath(sysrootpath,'=/usr/lib;=/usr/X11R6/lib;=/opt/freeware/lib',true)
     else
-      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib/profiled;/usr/X11R6/lib;/opt/freeware/lib',true)
+      LibrarySearchPath.AddLibraryPath(sysrootpath,'=/usr/lib/profiled;=/usr/X11R6/lib;=/opt/freeware/lib',true)
 end;
 
 

+ 5 - 4
compiler/systems/t_beos.pas

@@ -176,14 +176,15 @@ begin
   Inherited Create;
   s:=GetEnvironmentVariable('BELIBRARIES');
   { convert to correct format in case under unix system }
-  for i:=1 to length(s) do
-    if s[i] = ':' then
-      s[i] := ';';
+  Replace(s,':',';=');
+  Insert('=',s,1);
+  if s[length(s)]='=' then
+    setlength(s,length(s)-1);
   { just in case we have a single path : add the ending ; }
   { since that is what the compiler expects.              }
   if pos(';',s) = 0 then
     s:=s+';';
-  LibrarySearchPath.AddPath(sysrootpath,s,true); {format:'path1;path2;...'}
+  LibrarySearchPath.AddLibraryPath(sysrootpath,s,true); {format:'path1;path2;...'}
 end;
 
 

+ 3 - 3
compiler/systems/t_bsd.pas

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

+ 11 - 11
compiler/systems/t_haiku.pas

@@ -172,11 +172,11 @@ end;
 
 Constructor TLinkerHaiku.Create;
 const
-  HomeNonPackagedDevLib = '/boot/home/config/non-packaged/develop/lib';
-  HomeDevLib = '/boot/home/config/develop/lib';
-  CommonNonPackagedDevLib = '/boot/common/non-packaged/develop/lib';
-  CommonDevLib = '/boot/common/develop/lib';
-  SystemDevLib = '/boot/system/develop/lib';
+  HomeNonPackagedDevLib = '=/boot/home/config/non-packaged/develop/lib';
+  HomeDevLib = '=/boot/home/config/develop/lib';
+  CommonNonPackagedDevLib = '=/boot/common/non-packaged/develop/lib';
+  CommonDevLib = '=/boot/common/develop/lib';
+  SystemDevLib = '=/boot/system/develop/lib';
 var
   s : string;
   i : integer;
@@ -195,13 +195,13 @@ begin
   // Under Haiku with package management, BELIBRARIES is empty by default
   // We have to look at those system paths, in this order.
   // User can still customize BELIBRARIES. That is why it is looked at first.
-  LibrarySearchPath.AddPath(sysrootpath,s,true); {format:'path1;path2;...'}
+  LibrarySearchPath.AddLibraryPath(sysrootpath,s,true); {format:'path1;path2;...'}
 
-  LibrarySearchPath.AddPath(sysrootpath, HomeNonPackagedDevLib, false);
-  LibrarySearchPath.AddPath(sysrootpath, HomeDevLib, false);
-  LibrarySearchPath.AddPath(sysrootpath, CommonNonPackagedDevLib, false);
-  LibrarySearchPath.AddPath(sysrootpath, CommonDevLib, false);
-  LibrarySearchPath.AddPath(sysrootpath, SystemDevLib, false);
+  LibrarySearchPath.AddLibraryPath(sysrootpath, HomeNonPackagedDevLib, false);
+  LibrarySearchPath.AddLibraryPath(sysrootpath, HomeDevLib, false);
+  LibrarySearchPath.AddLibraryPath(sysrootpath, CommonNonPackagedDevLib, false);
+  LibrarySearchPath.AddLibraryPath(sysrootpath, CommonDevLib, false);
+  LibrarySearchPath.AddLibraryPath(sysrootpath, SystemDevLib, false);
 end;
 
 

+ 23 - 29
compiler/systems/t_linux.pas

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

+ 1 - 1
compiler/systems/t_macos.pas

@@ -88,7 +88,7 @@ implementation
 Constructor TLinkerMPW.Create;
 begin
   Inherited Create;
-  //LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true);
+  //LibrarySearchPath.AddLibraryPath(sysrootpath,'=/lib;=/usr/lib;=/usr/X11R6/lib',true);
 end;
 
 

+ 2 - 2
compiler/systems/t_sunos.pas

@@ -108,9 +108,9 @@ begin
     use_gnu_ld:=true;
   if NOT Dontlinkstdlibpath Then
 {$ifdef x86_64}
-   LibrarySearchPath.AddPath(sysrootpath,'/lib/64;/usr/lib/64;/usr/X11R6/lib/64;/opt/sfw/lib/64',true);
+   LibrarySearchPath.AddLibraryPath(sysrootpath,'=/lib/64;=/usr/lib/64;=/usr/X11R6/lib/64;=/opt/sfw/lib/64',true);
 {$else not x86_64}
-   LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib;/opt/sfw/lib',true);
+   LibrarySearchPath.AddLibraryPath(sysrootpath,'=/lib;=/usr/lib;=/usr/X11R6/lib;=/opt/sfw/lib',true);
 {$endif not x86_64}
 {$ifdef  LinkTest}
      if (cs_link_staticflag in current_settings.globalswitches) then  WriteLN('ForceLinkStaticFlag');