Browse Source

* fixes to the compiler util exe search routines, which caused the compiler to
erroneusly find '/usr/bin/ld' instead of '/usr/bin/ld.bfd' on OpenBSD, which
silently produced broken executables, which made this bug even more "fun" to
find. :)

git-svn-id: trunk@42128 -

nickysn 6 years ago
parent
commit
40e6c06f67
2 changed files with 21 additions and 3 deletions
  1. 9 1
      compiler/cfileutl.pas
  2. 12 2
      compiler/link.pas

+ 9 - 1
compiler/cfileutl.pas

@@ -1284,8 +1284,16 @@ end;
 
 
 
 
    function  FindExe(const bin:TCmdStr;allowcache:boolean;var foundfile:TCmdStr):boolean;
    function  FindExe(const bin:TCmdStr;allowcache:boolean;var foundfile:TCmdStr):boolean;
+     var
+       b : TCmdStr;
      begin
      begin
-       FindExe:=FindFileInExeLocations(ChangeFileExt(bin,source_info.exeext),allowcache,foundfile);
+       { change extension only on platforms that use an exe extension, otherwise on OpenBSD
+         'ld.bfd' gets converted to 'ld' }
+       if source_info.exeext<>'' then
+         b:=ChangeFileExt(bin,source_info.exeext)
+       else
+         b:=bin;
+       FindExe:=FindFileInExeLocations(b,allowcache,foundfile);
      end;
      end;
 
 
 
 

+ 12 - 2
compiler/link.pas

@@ -681,10 +681,20 @@ Implementation
         if cs_link_on_target in current_settings.globalswitches then
         if cs_link_on_target in current_settings.globalswitches then
           begin
           begin
             { If linking on target, don't add any path PM }
             { If linking on target, don't add any path PM }
-            FindUtil:=ChangeFileExt(s,target_info.exeext);
+            { change extension only on platforms that use an exe extension, otherwise on OpenBSD 'ld.bfd' gets
+              converted to 'ld' }
+            if target_info.exeext<>'' then
+              FindUtil:=ChangeFileExt(s,target_info.exeext)
+            else
+              FindUtil:=s;
             exit;
             exit;
           end;
           end;
-        UtilExe:=ChangeFileExt(s,source_info.exeext);
+        { change extension only on platforms that use an exe extension, otherwise on OpenBSD 'ld.bfd' gets converted
+          to 'ld' }
+        if source_info.exeext<>'' then
+          UtilExe:=ChangeFileExt(s,source_info.exeext)
+        else
+          UtilExe:=s;
         FoundBin:='';
         FoundBin:='';
         Found:=false;
         Found:=false;
         if utilsdirectory<>'' then
         if utilsdirectory<>'' then