Browse Source

CMakeParseImplicitLinkInfo: Do not mistake ld.so for a linker

Our pattern meant to match `/usr/bin/ld`, `ld.exe`, etc., unfortunately also
captures `ld.so`, which happens to be the dynamic linker on x86 GNU/Hurd.
Through `linker_tool_regex`, this:

    elseif("${line}" MATCHES "${linker_tool_regex}")
      set(linker_tool "${CMAKE_MATCH_2}")
    endif()

is then assuming that:

    /.../collect2 [...] -dynamic-linker /lib/ld.so [...]

claims the linker to be `/lib/ld.so`, and stops there, without noticing
further down in the log:

    /usr/bin/ld [...] -dynamic-linker /lib/ld.so [...]

which is what should be claiming `/usr/bin/ld` is the linker.
Samuel Thibault 1 year ago
parent
commit
c4f64cee36
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Modules/CMakeParseImplicitLinkInfo.cmake

+ 1 - 1
Modules/CMakeParseImplicitLinkInfo.cmake

@@ -61,7 +61,7 @@ function(cmake_parse_implicit_link_info2 text log_var obj_regex)
     endif()
   endif()
   # Parse implicit linker arguments.
-  set(linker "ld[0-9]*(\\.[a-z]+)?")
+  set(linker "ld[0-9]*(|\\.[a-rt-z][a-z]*|\\.s[a-np-z][a-z]*|\\.so[a-z]+)")
   if(is_lfortran_less_0_40)
     # lfortran < 0.40 has no way to pass -v to clang/gcc driver.
     string(APPEND linker "|clang|gcc")