commit:     14e6d6149b2e104b5446052340d20d6880ca50a5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 13 19:40:56 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 13 19:40:56 2021 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=14e6d614

sys-devel/binutils-config-5.1-r4: revbump for BigSur sdk_version fix

Package-Manager: Portage-3.0.12.0.2-prefix, Repoman-3.0.2
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 ...5.1-r3.ebuild => binutils-config-5.1-r4.ebuild} |  5 ++++-
 sys-devel/binutils-config/files/ldwrapper.c        | 24 ++++++++++++++++++----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/sys-devel/binutils-config/binutils-config-5.1-r3.ebuild 
b/sys-devel/binutils-config/binutils-config-5.1-r4.ebuild
similarity index 95%
rename from sys-devel/binutils-config/binutils-config-5.1-r3.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r4.ebuild
index 02468e2b1a..36bc85a317 100644
--- a/sys-devel/binutils-config/binutils-config-5.1-r3.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5.1-r4.ebuild
@@ -44,7 +44,10 @@ src_compile() {
                # macOS Big Sur has an empty /usr/lib, so the linker really has
                # to look into the SDK, for which it needs to be told where it
                # is (symlinked right into our EPREFIX root as MacOSX.sdk)
-               extraargs+=( -DDARWIN_LD_SYSLIBROOT=1 )
+               extraargs+=(
+                       -DDARWIN_LD_SYSLIBROOT=1
+                       
-DDARWIN_LD_DEFAULT_TARGET='"'${MACOSX_DEPLOYMENT_TARGET}'"'
+               )
        fi
        local args=(
                $(tc-getCC)

diff --git a/sys-devel/binutils-config/files/ldwrapper.c 
b/sys-devel/binutils-config/files/ldwrapper.c
index 7410afd334..6bcb2a5e72 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2019 Gentoo Foundation
+ * Copyright 1999-2021 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  * Authors: Fabian Groffen <grob...@gentoo.org>
  *          Michael Haubenwallner <ha...@gentoo.org>
@@ -218,6 +218,11 @@ main(int argc, char *argv[])
        DIR *dirp;
        struct dirent *dp;
 
+#ifdef DARWIN_LD_DEFAULT_TARGET
+       if (darwin_dt == NULL)
+               darwin_dt = DARWIN_LD_DEFAULT_TARGET;
+#endif
+
        /* two ways to determine CTARGET from argv[0]:
         * 1. called as <CTARGET>-ld (manually)
         * 2. called as EPREFIX/usr/libexec/gcc/<CTARGET>/ld (by gcc's collect2)
@@ -340,8 +345,8 @@ main(int argc, char *argv[])
                        newargc += 2 + 1;
 
 #ifdef DARWIN_LD_SYSLIBROOT
-                       /* add -syslibroot <path> */
-                       newargc += 2;
+                       /* add -syslibroot <path> -sdk_version <ver> */
+                       newargc += 4;
 #endif
                } else {
                        /* add the 4 paths we want (-L + -R) */
@@ -378,11 +383,22 @@ main(int argc, char *argv[])
        newargv[j++] = ld;
 
        if (!is_cross && is_darwin) {
-               /* inject this first to make the intention clear */
+               char target[ESIZ];
+               ssize_t trglen;
+
+               /* ld64 will try to infer sdk version when -syslibroot is used
+                * from the path given, unfortunately this searches for the
+                * first numbers it finds, which means anything random in
+                * EPREFIX, causing errors.  Explicitly set the deployment
+                * version here, for the sdk link can be versionless when set to
+                * CommandLineTools */
 #ifdef DARWIN_LD_SYSLIBROOT
+               newargv[j++] = "-sdk_version";
+               newargv[j++] = darwin_dt;
                newargv[j++] = "-syslibroot";
                newargv[j++] = EPREFIX "/MacOSX.sdk";
 #endif
+               /* inject this first to make the intention clear */
                newargv[j++] = "-search_paths_first";
        }
 

Reply via email to