public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/
Date: Tue, 26 Sep 2023 19:38:50 +0000 (UTC)	[thread overview]
Message-ID: <1695756952.753907f35f78864cf66a7bc084b32eb56b31684d.grobian@gentoo> (raw)

commit:     753907f35f78864cf66a7bc084b32eb56b31684d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 26 19:30:33 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Sep 26 19:35:52 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=753907f3

sys-apps/binutils-config: fix ldwrapper for CLT 15

Because -platform_version is actually supported since a while, and we
don't really support older versions (except Darwin 17 and 9 which use
way different versions), just switch to using platform_version when the
target is macos 12 or up.

Closes: https://bugs.gentoo.org/910277
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 sys-devel/binutils-config/files/ldwrapper.c | 60 ++++++++++++++++++++++++-----
 1 file changed, 50 insertions(+), 10 deletions(-)

diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 1b5fa19ad3..16932af5d6 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -207,6 +207,7 @@ main(int argc, char *argv[])
 	char *ld = ldbuf;
 	char ctarget[128];
 	char *darwin_dt = getenv("MACOSX_DEPLOYMENT_TARGET");
+	int darwin_dt_ver = 0;
 	char is_cross = 0;
 	char is_darwin = 0;
 	char darwin_use_rpath = 1;
@@ -293,8 +294,12 @@ main(int argc, char *argv[])
 				newargc++;
 			if (argv[i][1] == 'v' || argv[i][1] == 'V')
 				verbose = 1;
-			if (strcmp(argv[i], "-macosx_version_min") == 0 && i < argc - 1)
+			if ((strcmp(argv[i], "-macosx_version_min") == 0 ||
+				 strcmp(argv[i], "-macos_version_min") == 0) && i < argc - 1)
 				darwin_dt = argv[i + 1];
+			if (strcmp(argv[i], "-platform_version") == 0 &&
+				i < argc - 3 && strcmp(argv[i + 1], "macos") == 0)
+				darwin_dt = argv[i + 2];
 			/* ld64 will refuse to accept -rpath if any of the
 			 * following options are given */
 			if (strcmp(argv[i], "-static") == 0 ||
@@ -306,6 +311,12 @@ main(int argc, char *argv[])
 		}
 	}
 
+	if (is_darwin && darwin_dt != NULL) {
+		darwin_dt_ver = (int)strtol(darwin_dt, &p, 10) * 100;
+		if (*p == '.')
+			darwin_dt_ver += (int)strtol(p + 1, &p, 10);
+	}
+
 	/* Note: Code below assumes that newargc is the count of -L arguments. */
 
 	/* If a package being cross-compiled injects standard directories, it's
@@ -325,10 +336,7 @@ main(int argc, char *argv[])
 				 * parsing at dots. darwin_dt != NULL isn't
 				 * just for safety: ld64 also refuses -rpath
 				 * when not given a deployment target at all */
-				darwin_use_rpath = darwin_dt != NULL &&
-					(atoi(darwin_dt) > 10 ||
-					 (strncmp(darwin_dt, "10.", 3) == 0 &&
-					  atoi(darwin_dt + 3) >= 5));
+				darwin_use_rpath = darwin_dt_ver >= 1005;
 			}
 
 			if (darwin_use_rpath) {
@@ -345,8 +353,8 @@ main(int argc, char *argv[])
 			newargc += 2 + 1;
 
 #ifdef DARWIN_LD_SYSLIBROOT
-			/* add -syslibroot <path> -sdk_version <ver> */
-			newargc += 4;
+			/* add -syslibroot <path> -platform_version macos <ver> 0.0 */
+			newargc += 6;
 #endif
 		} else {
 			/* add the 4 paths we want (-L + -R) */
@@ -393,8 +401,17 @@ main(int argc, char *argv[])
 		 * 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;
+		/* bug #910277: transform into platform_version arg for newer
+		 * targets */
+		if (darwin_dt_ver >= 1200) {
+			newargv[j++] = "-platform_version";
+			newargv[j++] = "macos";
+			newargv[j++] = darwin_dt;
+			newargv[j++] = "0.0";
+		} else {
+			newargv[j++] = "-sdk_version";
+			newargv[j++] = darwin_dt;
+		}
 		newargv[j++] = "-syslibroot";
 		newargv[j++] = EPREFIX "/MacOSX.sdk";
 #endif
@@ -405,6 +422,26 @@ main(int argc, char *argv[])
 	/* position k right after the original arguments */
 	k = j - 1 + argc;
 	for (i = 1; i < argc; i++, j++) {
+#ifdef DARWIN_LD_SYSLIBROOT
+		if (is_darwin) {
+			/* skip platform version stuff, we already pushed it out */
+			if ((strcmp(argv[i], "-macosx_version_min") == 0 ||
+				 strcmp(argv[i], "-macos_version_min") == 0) && i < argc - 1)
+			{
+				i++;
+				j--;
+				continue;
+			}
+			if (strcmp(argv[i], "-platform_version") == 0 &&
+				i < argc - 3 && strcmp(argv[i + 1], "macos") == 0)
+			{
+				i += 3;
+				j--;
+				continue;
+			}
+		}
+#endif
+
 		newargv[j] = argv[i];
 
 		if (is_cross || (is_darwin && !darwin_use_rpath))
@@ -487,7 +524,10 @@ main(int argc, char *argv[])
 	if (verbose) {
 		fprintf(stderr, "%s: invoking %s with arguments:\n", wrapper, ld);
 		for (j = 0; newargv[j] != NULL; j++)
-			fprintf(stderr, "  %s\n", newargv[j]);
+			fprintf(stderr, "  %s%s",
+					newargv[j],
+					newargv[j + 1] != NULL && newargv[j + 1][0] != '-'
+					? "" : "\n");
 	}
 
 	/* finally, execute the real ld */


             reply	other threads:[~2023-09-26 19:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 19:38 Fabian Groffen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-01-13 14:29 [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/ Fabian Groffen
2020-11-27 13:57 Fabian Groffen
2020-11-27 13:39 Fabian Groffen
2018-01-31  9:50 Fabian Groffen
2017-12-29 14:56 Fabian Groffen
2017-12-27  9:05 Fabian Groffen
2017-12-25 19:47 Fabian Groffen
2017-11-29 15:21 Fabian Groffen
2017-11-25 18:33 Fabian Groffen
2016-05-15 16:44 Fabian Groffen
2016-05-13 12:14 Fabian Groffen
2016-05-13 12:14 Fabian Groffen
2016-05-13 12:14 Fabian Groffen
2016-04-18  8:07 Michael Haubenwallner
2016-02-15 14:30 Fabian Groffen
2016-02-14 14:56 Fabian Groffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1695756952.753907f35f78864cf66a7bc084b32eb56b31684d.grobian@gentoo \
    --to=grobian@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox