[Git][ghc/ghc][wip/romes/24792] configure: Prefer tool name over tool path

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Tue May 28 16:41:58 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/24792 at Glasgow Haskell Compiler / GHC


Commits:
d0ac40dd by Rodrigo Mesquita at 2024-05-28T17:34:11+01:00
configure: Prefer tool name over tool path

It is non-obvious whether the toolchain configuration should use
full-paths to tools or simply their names. In addressing #24574, we've
decided to prefer executable names over paths, ultimately, because the
bindist configure script already does this, thus is the default in ghcs
out there.

Updates the in-tree configure script to prefer tool names
(`AC_CHECK_TOOL` rather than `AC_PATH_TOOL`) and `ghc-toolchain` to
ignore the full-path-result of `findExecutable`, which it previously
used over the program name.

This change doesn't undo the fix in bd92182cd56140ffb2f68ec01492e5aa6333a8fc
because `AC_CHECK_TOOL` still takes into account the target triples,
unlike `AC_CHECK_PROG/AC_PATH_PROG`.

- - - - -


3 changed files:

- configure.ac
- m4/find_merge_objects.m4
- utils/ghc-toolchain/src/GHC/Toolchain/Program.hs


Changes:

=====================================
configure.ac
=====================================
@@ -299,16 +299,16 @@ if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then
     FP_INSTALL_WINDOWS_TOOLCHAIN
     FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/inplace/mingw], [$hardtop/inplace/mingw])
 else
-    AC_PATH_TOOL([CC],[gcc], [clang])
-    AC_PATH_TOOL([CXX],[g++], [clang++])
-    AC_PATH_TOOL([NM],[nm])
+    AC_CHECK_TOOL([CC],[gcc], [clang])
+    AC_CHECK_TOOL([CXX],[g++], [clang++])
+    AC_CHECK_TOOL([NM],[nm])
     # N.B. we don't probe for LD here but instead
     # do so in FIND_LD to avoid #21778.
-    AC_PATH_TOOL([AR],[ar])
-    AC_PATH_TOOL([RANLIB],[ranlib])
-    AC_PATH_TOOL([OBJDUMP],[objdump])
-    AC_PATH_TOOL([WindresCmd],[windres])
-    AC_PATH_TOOL([Genlib],[genlib])
+    AC_CHECK_TOOL([AR],[ar])
+    AC_CHECK_TOOL([RANLIB],[ranlib])
+    AC_CHECK_TOOL([OBJDUMP],[objdump])
+    ([WindresCmd],[windres])
+    ([Genlib],[genlib])
 
     if test "$HostOS" = "mingw32"; then
         AC_CHECK_TARGET_TOOL([WindresCmd],[windres])


=====================================
m4/find_merge_objects.m4
=====================================
@@ -26,7 +26,7 @@ AC_DEFUN([FIND_MERGE_OBJECTS],[
 
     if test -z ${MergeObjsCmd+x}; then
         AC_MSG_NOTICE([Setting cmd])
-        MergeObjsCmd="$(command -v $LD)"
+        MergeObjsCmd="$LD"
     fi
     if test -z ${MergeObjsArgs+x}; then
         MergeObjsArgs="-r"
@@ -45,7 +45,7 @@ AC_DEFUN([FIND_MERGE_OBJECTS],[
       if test "$result" = "1"; then
           AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...])
           MergeObjsCmd=""
-          AC_PATH_TARGET_TOOL([MergeObjsCmd], [ld])
+          AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld])
           CHECK_FOR_GOLD_T22266($MergeObjsCmd)
           if test "$result" = "1"; then
               AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.])


=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Program.hs
=====================================
@@ -104,7 +104,9 @@ logExecute prog args =
     logDebug $ "Execute: " ++ intercalate " " ([prgPath prog] ++ prgFlags prog ++ args)
 
 -- | Program specifier from the command-line.
-data ProgOpt = ProgOpt { poPath :: Maybe FilePath
+data ProgOpt = ProgOpt { poPath :: Maybe String
+                       -- ^ Refers to the path to an executable, or simply the
+                       -- executable name.
                        , poFlags :: Maybe [String]
                        }
 
@@ -160,7 +162,9 @@ findProgram description userSpec candidates
           r <- liftIO $ findExecutable name
           case r of
             Nothing -> throwE $ name ++ " not found in search path"
-            Just x -> return x
+            -- Use the given `prgPath` or candidate name rather than the
+            -- absolute path returned by `findExecutable`.
+            Just _x -> return name
 
 -------------------- Compiling utilities --------------------
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0ac40dd004dce1ea413bcddfbfc2de82eecdd64

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0ac40dd004dce1ea413bcddfbfc2de82eecdd64
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240528/86994969/attachment-0001.html>


More information about the ghc-commits mailing list