mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-26 13:31:27 +01:00 
			
		
		
		
	+ add -XR switch for target root file system with libs (also used for C lib type detection)
git-svn-id: trunk@8695 -
This commit is contained in:
		
							parent
							
								
									7d5d4ba706
								
							
						
					
					
						commit
						0625040eba
					
				| @ -936,8 +936,6 @@ implementation | |||||||
|             while (j>0) and (s[j]<>';') do |             while (j>0) and (s[j]<>';') do | ||||||
|              dec(j); |              dec(j); | ||||||
|             currPath:= TrimSpace(Copy(s,j+1,length(s)-j)); |             currPath:= TrimSpace(Copy(s,j+1,length(s)-j)); | ||||||
|             DePascalQuote(currPath); |  | ||||||
|             currPath:=FixPath(currPath,false); |  | ||||||
|             if j=0 then |             if j=0 then | ||||||
|              s:='' |              s:='' | ||||||
|             else |             else | ||||||
| @ -949,12 +947,12 @@ implementation | |||||||
|             if j=0 then |             if j=0 then | ||||||
|              j:=255; |              j:=255; | ||||||
|             currPath:= TrimSpace(Copy(s,1,j-1)); |             currPath:= TrimSpace(Copy(s,1,j-1)); | ||||||
|             DePascalQuote(currPath); |  | ||||||
|             currPath:=SrcPath+FixPath(currPath,false); |  | ||||||
|             System.Delete(s,1,j); |             System.Delete(s,1,j); | ||||||
|           end; |           end; | ||||||
| 
 | 
 | ||||||
|          { fix pathname } |          { fix pathname } | ||||||
|  |          DePascalQuote(currPath); | ||||||
|  |          currPath:=SrcPath+FixPath(currPath,false); | ||||||
|          if currPath='' then |          if currPath='' then | ||||||
|            currPath:= CurDirRelPath(source_info) |            currPath:= CurDirRelPath(source_info) | ||||||
|          else |          else | ||||||
|  | |||||||
| @ -191,7 +191,8 @@ interface | |||||||
|        utilsprefix    : TCmdStr; |        utilsprefix    : TCmdStr; | ||||||
|        cshared        : boolean;        { pass --shared to ld to link C libs shared} |        cshared        : boolean;        { pass --shared to ld to link C libs shared} | ||||||
|        Dontlinkstdlibpath: Boolean;     { Don't add std paths to linkpath} |        Dontlinkstdlibpath: Boolean;     { Don't add std paths to linkpath} | ||||||
|        rlinkpath      : TCmdStr;         { rpath-link linkdir override} |        rlinkpath      : TCmdStr;        { rpath-link linkdir override} | ||||||
|  |        sysrootpath    : TCmdStr;        { target system root to search dyn linker } | ||||||
| 
 | 
 | ||||||
|        { some flags for global compiler switches } |        { some flags for global compiler switches } | ||||||
|        do_build, |        do_build, | ||||||
| @ -1166,6 +1167,7 @@ implementation | |||||||
|         utilsprefix:=''; |         utilsprefix:=''; | ||||||
|         cshared:=false; |         cshared:=false; | ||||||
|         rlinkpath:=''; |         rlinkpath:=''; | ||||||
|  |         sysrootpath:=''; | ||||||
| 
 | 
 | ||||||
|         { Search Paths } |         { Search Paths } | ||||||
|         librarysearchpath:=TSearchPathList.Create; |         librarysearchpath:=TSearchPathList.Create; | ||||||
|  | |||||||
| @ -750,9 +750,9 @@ begin | |||||||
|                  'l' : |                  'l' : | ||||||
|                    begin |                    begin | ||||||
|                      if ispara then |                      if ispara then | ||||||
|                        ParaLibraryPath.AddPath(More,false) |                        ParaLibraryPath.AddPath(sysrootpath,More,false) | ||||||
|                      else |                      else | ||||||
|                        LibrarySearchPath.AddPath(More,true); |                        LibrarySearchPath.AddPath(sysrootpath,More,true); | ||||||
|                    end; |                    end; | ||||||
|                  'L' : |                  'L' : | ||||||
|                    begin |                    begin | ||||||
| @ -1394,6 +1394,12 @@ begin | |||||||
|                         DefaultReplacements(rlinkpath); |                         DefaultReplacements(rlinkpath); | ||||||
|                         More:=''; |                         More:=''; | ||||||
|                       end; |                       end; | ||||||
|  |                     'R' : | ||||||
|  |                       begin | ||||||
|  |                         sysrootpath:=copy(more,2,length(more)-1); | ||||||
|  |                         defaultreplacements(sysrootpath); | ||||||
|  |                         more:=''; | ||||||
|  |                       end; | ||||||
|                     's' : |                     's' : | ||||||
|                       begin |                       begin | ||||||
|                         If UnsetBool(More, j) then |                         If UnsetBool(More, j) then | ||||||
|  | |||||||
| @ -183,7 +183,7 @@ begin | |||||||
|   { since that is what the compiler expects.              } |   { since that is what the compiler expects.              } | ||||||
|   if pos(';',s) = 0 then |   if pos(';',s) = 0 then | ||||||
|     s:=s+';'; |     s:=s+';'; | ||||||
|   LibrarySearchPath.AddPath(s,true); {format:'path1;path2;...'} |   LibrarySearchPath.AddPath(sysrootpath,s,true); {format:'path1;path2;...'} | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -208,10 +208,10 @@ begin | |||||||
|   Inherited Create; |   Inherited Create; | ||||||
|   if not Dontlinkstdlibpath Then |   if not Dontlinkstdlibpath Then | ||||||
|    if not(target_info.system in systems_darwin) then |    if not(target_info.system in systems_darwin) then | ||||||
|      LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib',true) |      LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true) | ||||||
|    else |    else | ||||||
|      { Mac OS X doesn't have a /lib } |      { Mac OS X doesn't have a /lib } | ||||||
|      LibrarySearchPath.AddPath('/usr/lib',true) |      LibrarySearchPath.AddPath(sysrootpath,'/usr/lib',true) | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -205,12 +205,12 @@ begin | |||||||
|   Inherited Create; |   Inherited Create; | ||||||
|   if not Dontlinkstdlibpath Then |   if not Dontlinkstdlibpath Then | ||||||
| {$ifdef x86_64} | {$ifdef x86_64} | ||||||
|    LibrarySearchPath.AddPath('/lib64;/usr/lib64;/usr/X11R6/lib64',true); |    LibrarySearchPath.AddPath(sysrootpath,'/lib64;/usr/lib64;/usr/X11R6/lib64',true); | ||||||
| {$else} | {$else} | ||||||
| {$ifdef powerpc64} | {$ifdef powerpc64} | ||||||
|    LibrarySearchPath.AddPath('/lib64;/usr/lib64;/usr/X11R6/lib64',true); |    LibrarySearchPath.AddPath(sysrootpath,'/lib64;/usr/lib64;/usr/X11R6/lib64',true); | ||||||
| {$else powerpc64} | {$else powerpc64} | ||||||
|    LibrarySearchPath.AddPath('/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} | ||||||
| end; | end; | ||||||
| @ -230,19 +230,21 @@ const | |||||||
| {$ifdef arm}    platform_select='';{$endif} {unknown :( } | {$ifdef arm}    platform_select='';{$endif} {unknown :( } | ||||||
| {$ifdef m68k}    platform_select='';{$endif} {unknown :( } | {$ifdef m68k}    platform_select='';{$endif} {unknown :( } | ||||||
| 
 | 
 | ||||||
| {$ifdef m68k} |  | ||||||
| var | var | ||||||
|  | {$ifdef m68k} | ||||||
|   St : TSearchRec; |   St : TSearchRec; | ||||||
|  | {$else} | ||||||
|  |   defdynlinker: string; | ||||||
| {$endif m68k} | {$endif m68k} | ||||||
| begin | begin | ||||||
|   with Info do |   with Info do | ||||||
|    begin |    begin | ||||||
|      ExeCmd[1]:='ld '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES'; |      ExeCmd[1]:='ld '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE -T $RES'; | ||||||
|      DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES -E'; |      DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES -E'; | ||||||
|      DllCmd[2]:='strip --strip-unneeded $EXE'; |      DllCmd[2]:='strip --strip-unneeded $EXE'; | ||||||
| {$ifdef m68k} | {$ifdef m68k} | ||||||
|      libctype:=glibc2; |      libctype:=glibc2; | ||||||
|      if FindFirst('/lib/ld*',faAnyFile+faSymLink,st)<>0 then |      if FindFirst(sysrootpath+'/lib/ld*',faAnyFile+faSymLink,st)<>0 then | ||||||
|        begin |        begin | ||||||
|          repeat |          repeat | ||||||
|             if copy(st.name,1,5)='ld-2.' then |             if copy(st.name,1,5)='ld-2.' then | ||||||
| @ -258,6 +260,29 @@ begin | |||||||
| {$endif m68k} | {$endif m68k} | ||||||
| 
 | 
 | ||||||
| {$ifdef i386} | {$ifdef i386} | ||||||
|  |      defdynlinker:='/lib/ld-linux.so.1'; | ||||||
|  | {$endif} | ||||||
|  | 
 | ||||||
|  | {$ifdef x86_64} | ||||||
|  |      defdynlinker:='/lib/ld-linux-x86-64.so.2' | ||||||
|  | {$endif x86_64} | ||||||
|  | 
 | ||||||
|  | {$ifdef sparc} | ||||||
|  |      defdynlinker:='/lib/ld-linux.so.2'; | ||||||
|  | {$endif sparc} | ||||||
|  | 
 | ||||||
|  | {$ifdef powerpc} | ||||||
|  |      defdynlinker:='/lib/ld.so.1'; | ||||||
|  | {$endif powerpc} | ||||||
|  | 
 | ||||||
|  | {$ifdef powerpc64} | ||||||
|  |      defdynlinker:='/lib/ld64.so.1'; | ||||||
|  | {$endif powerpc64} | ||||||
|  | 
 | ||||||
|  | {$ifdef arm} | ||||||
|  |      defdynlinker:='/lib/ld-linux.so.2'; | ||||||
|  | {$endif arm} | ||||||
|  | 
 | ||||||
|      { |      { | ||||||
|        Search order: |        Search order: | ||||||
|          glibc 2.1+ |          glibc 2.1+ | ||||||
| @ -265,19 +290,22 @@ begin | |||||||
|          glibc 2.0 |          glibc 2.0 | ||||||
|        If none is found (e.g. when cross compiling) glibc21 is assumed |        If none is found (e.g. when cross compiling) glibc21 is assumed | ||||||
|      } |      } | ||||||
|      if FileExists('/lib/ld-linux.so.2',false) then | {$ifdef i386} | ||||||
|  |      if FileExists(sysrootpath+'/lib/ld-linux.so.2',false) then | ||||||
|        begin |        begin | ||||||
|          DynamicLinker:='/lib/ld-linux.so.2'; |          DynamicLinker:='/lib/ld-linux.so.2'; | ||||||
|          libctype:=glibc21; |          libctype:=glibc21; | ||||||
|        end |        end | ||||||
|      else if fileexists('/lib/ld-uClibc.so.0',false) then |      else  | ||||||
|  | {$endif i386} | ||||||
|  |      if fileexists(sysrootpath+'/lib/ld-uClibc.so.0',false) then | ||||||
|        begin |        begin | ||||||
|          dynamiclinker:='/lib/ld-uClibc.so.0'; |          dynamiclinker:='/lib/ld-uClibc.so.0'; | ||||||
|          libctype:=uclibc; |          libctype:=uclibc; | ||||||
|        end |        end | ||||||
|      else if fileexists('/lib/ld-linux.so.1',false) then |      else if fileexists(sysrootpath+defdynlinker,false) then | ||||||
|        begin |        begin | ||||||
|          DynamicLinker:='/lib/ld-linux.so.1'; |          DynamicLinker:=defdynlinker; | ||||||
|          libctype:=glibc2; |          libctype:=glibc2; | ||||||
|        end |        end | ||||||
|      else |      else | ||||||
| @ -286,32 +314,6 @@ begin | |||||||
|          DynamicLinker:='/lib/ld-linux.so.2'; |          DynamicLinker:='/lib/ld-linux.so.2'; | ||||||
|          libctype:=glibc21; |          libctype:=glibc21; | ||||||
|        end; |        end; | ||||||
| {$endif i386} |  | ||||||
| 
 |  | ||||||
| {$ifdef x86_64} |  | ||||||
|      DynamicLinker:='/lib64/ld-linux-x86-64.so.2'; |  | ||||||
|      libctype:=glibc2; |  | ||||||
| {$endif x86_64} |  | ||||||
| 
 |  | ||||||
| {$ifdef sparc} |  | ||||||
|      DynamicLinker:='/lib/ld-linux.so.2'; |  | ||||||
|      libctype:=glibc2; |  | ||||||
| {$endif sparc} |  | ||||||
| 
 |  | ||||||
| {$ifdef powerpc} |  | ||||||
|      DynamicLinker:='/lib/ld.so.1'; |  | ||||||
|      libctype:=glibc2; |  | ||||||
| {$endif powerpc} |  | ||||||
| 
 |  | ||||||
| {$ifdef powerpc64} |  | ||||||
|      DynamicLinker:='/lib64/ld64.so.1'; |  | ||||||
|      libctype:=glibc2; |  | ||||||
| {$endif powerpc64} |  | ||||||
| 
 |  | ||||||
| {$ifdef arm} |  | ||||||
|      DynamicLinker:='/lib/ld-linux.so.2'; |  | ||||||
|      libctype:=glibc2; |  | ||||||
| {$endif arm} |  | ||||||
|    end; |    end; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| @ -437,7 +439,7 @@ begin | |||||||
|       if not (target_info.system in system_internal_sysinit) and (prtobj<>'') then |       if not (target_info.system in system_internal_sysinit) and (prtobj<>'') then | ||||||
|        AddFileName(maybequoted(FindObjectFile(prtobj,'',false))); |        AddFileName(maybequoted(FindObjectFile(prtobj,'',false))); | ||||||
|       { try to add crti and crtbegin if linking to C } |       { try to add crti and crtbegin if linking to C } | ||||||
|       if linklibc then |       if linklibc and (libctype<>uclibc) then | ||||||
|        begin |        begin | ||||||
|          { x86_64 requires this to use entry/exit code with pic, |          { x86_64 requires this to use entry/exit code with pic, | ||||||
|            see also issue #8210 regarding a discussion |            see also issue #8210 regarding a discussion | ||||||
| @ -791,7 +793,7 @@ var | |||||||
|   binstr, |   binstr, | ||||||
|   cmdstr  : TCmdStr; |   cmdstr  : TCmdStr; | ||||||
|   success : boolean; |   success : boolean; | ||||||
|   DynLinkStr : string[60]; |   DynLinkStr : string; | ||||||
|   GCSectionsStr, |   GCSectionsStr, | ||||||
|   StaticStr, |   StaticStr, | ||||||
|   StripStr   : string[40]; |   StripStr   : string[40]; | ||||||
| @ -815,11 +817,11 @@ begin | |||||||
|   If (cs_profile in current_settings.moduleswitches) or |   If (cs_profile in current_settings.moduleswitches) or | ||||||
|      ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then |      ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then | ||||||
|    begin |    begin | ||||||
|      DynLinkStr:='-dynamic-linker='+Info.DynamicLinker; |      DynLinkStr:='--dynamic-linker='+Info.DynamicLinker; | ||||||
|      if cshared Then |      if cshared then | ||||||
|        DynLinkStr:='--shared ' + DynLinkStr; |        DynLinkStr:=DynLinkStr+' --shared '; | ||||||
|      if rlinkpath<>'' Then |      if rlinkpath<>'' then | ||||||
|        DynLinkStr:='--rpath-link '+rlinkpath + ' '+ DynLinkStr; |        DynLinkStr:=DynLinkStr+' --rpath-link '+rlinkpath; | ||||||
|    End; |    End; | ||||||
| 
 | 
 | ||||||
| { Write used files and libraries } | { Write used files and libraries } | ||||||
|  | |||||||
| @ -74,7 +74,7 @@ implementation | |||||||
| Constructor TLinkerMPW.Create; | Constructor TLinkerMPW.Create; | ||||||
| begin | begin | ||||||
|   Inherited Create; |   Inherited Create; | ||||||
|   //LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib',true); |   //LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true); | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -182,7 +182,7 @@ Constructor TLinkersolaris.Create; | |||||||
| begin | begin | ||||||
|   Inherited Create; |   Inherited Create; | ||||||
|   if NOT Dontlinkstdlibpath Then |   if NOT Dontlinkstdlibpath Then | ||||||
|    LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib;/opt/sfw/lib',true); |    LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib;/opt/sfw/lib',true); | ||||||
| {$ifdef  LinkTest} | {$ifdef  LinkTest} | ||||||
|      if (cs_link_staticflag in current_settings.globalswitches) then  WriteLN('ForceLinkStaticFlag'); |      if (cs_link_staticflag in current_settings.globalswitches) then  WriteLN('ForceLinkStaticFlag'); | ||||||
|      if (cs_link_static in current_settings.globalswitches) then  WriteLN('LinkStatic-Flag'); |      if (cs_link_static in current_settings.globalswitches) then  WriteLN('LinkStatic-Flag'); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 micha
						micha