diff -ru fpcbuild-2.6.0-1/fpcsrc/compiler/systems/t_linux.pas fpcbuild-2.6.0-2/fpcsrc/compiler/systems/t_linux.pas --- fpcbuild-2.6.0-1/fpcsrc/compiler/systems/t_linux.pas 2011-07-01 09:37:05.000000000 +0200 +++ fpcbuild-2.6.0-2/fpcsrc/compiler/systems/t_linux.pas 2012-06-24 12:25:52.354081128 +0200 @@ -388,21 +388,25 @@ { try to add crti and crtbegin if linking to C } if linklibc and (libctype<>uclibc) then begin + { crtbegin[S|T].o and crti.o should not be used with absolute paths + as FindFile is not locating appropriate library for x86 when + compiling on x86_64 machine (should use /usr/lib32/...). Let + ld find the right one to link with if found in system. } { crti.o must come first } if librarysearchpath.FindFile('crti.o',false,s) then - AddFileName(s); + AddFileName('crti.o'); { then the crtbegin* } if cs_create_pic in current_settings.moduleswitches then begin if librarysearchpath.FindFile('crtbeginS.o',false,s) then - AddFileName(s); + AddFileName('crtbeginS.o'); end else if (cs_link_staticflag in current_settings.globalswitches) and librarysearchpath.FindFile('crtbeginT.o',false,s) then - AddFileName(s) + AddFileName('crtbeginT.o') else if librarysearchpath.FindFile('crtbegin.o',false,s) then - AddFileName(s); + AddFileName('crtbegin.o'); end; { main objectfiles } while not ObjectFiles.Empty do @@ -481,11 +485,22 @@ { objects which must be at the end } if linklibc and (libctype<>uclibc) then begin + { crtend[S].o and crtn.o should not be used with absolute paths + as FindFile is not locating appropriate library for x86 when + compiling on x86_64 machine (should use /usr/lib32/...). Let + ld find the right one to link with if found in system. } if cs_create_pic in current_settings.moduleswitches then - found1:=librarysearchpath.FindFile('crtendS.o',false,s1) + begin + found1:=librarysearchpath.FindFile('crtendS.o',false,s1); + if found1 then s1:='crtendS.o'; + end else - found1:=librarysearchpath.FindFile('crtend.o',false,s1); + begin + found1:=librarysearchpath.FindFile('crtend.o',false,s1); + if found1 then s1:='crtend.o'; + end; found2:=librarysearchpath.FindFile('crtn.o',false,s2); + if found2 then s2:='crtn.o'; if found1 or found2 then begin Add('INPUT(');