git: c4177f5b41d4 - main - bsd.linker.mk: Handle Xcode 15 linker identification

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Mon, 24 Jul 2023 00:40:53 UTC
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=c4177f5b41d45f3c83a0ef329a50e4ae05da3878

commit c4177f5b41d45f3c83a0ef329a50e4ae05da3878
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-07-24 00:34:17 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-07-24 00:34:17 +0000

    bsd.linker.mk: Handle Xcode 15 linker identification
    
    The upcoming Xcode 15 introduces a new linker (called ld-prime or ld-new
    in some documentation) to replace the classic ld64, which we need to
    handle.
    
    Previously, the linker would identify itself as:
    
      @(#)PROGRAM:ld  PROJECT:ld64-<version>
    
    Now, there are two cases. When the classic ld64 is in use, it identifies
    itself as:
    
      @(#)PROGRAM:ld-classic  PROJECT:ld64-<version>
    
    When the new linker is in use, it identifies itself as:
    
      @(#)PROGRAM:ld  PROJECT:dyld-<version>
    
    Thus, tweak the detection to allow a -classic suffix in the PROGRAM
    string and to allow a dyld- prefix instead of an ld64- prefix on the
    version number in the PROJECT string.
    
    MFC after:      1 week
---
 share/mk/bsd.linker.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/share/mk/bsd.linker.mk b/share/mk/bsd.linker.mk
index 81275281be34..2a572fa01bcd 100644
--- a/share/mk/bsd.linker.mk
+++ b/share/mk/bsd.linker.mk
@@ -79,10 +79,10 @@ ${X_}LINKER_FREEBSD_VERSION:=	${_ld_version:[4]:C/.*-([^-]*)\)/\1/}
 .else
 ${X_}LINKER_FREEBSD_VERSION=	0
 .endif
-.elif ${_ld_version:[1]} == "@(\#)PROGRAM:ld"
+.elif ${_ld_version:[1]:S/-classic$//} == "@(\#)PROGRAM:ld"
 # bootstrap linker on MacOS
 ${X_}LINKER_TYPE=        mac
-_v=        ${_ld_version:[2]:S/PROJECT:ld64-//}
+_v=        ${_ld_version:[2]:S/PROJECT:(ld64|dyld)-//}
 # Convert version 409.12 to 409.12.0 so that the echo + awk below works
 .if empty(_v:M[1-9]*.[0-9]*.[0-9]*) && !empty(_v:M[1-9]*.[0-9]*)
 _v:=${_v}.0