From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2C565158089 for ; Tue, 26 Sep 2023 19:38:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4C6352BC01A; Tue, 26 Sep 2023 19:38:53 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 300172BC01A for ; Tue, 26 Sep 2023 19:38:53 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 48D34335C52 for ; Tue, 26 Sep 2023 19:38:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B9E38FAC for ; Tue, 26 Sep 2023 19:38:50 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1695756952.753907f35f78864cf66a7bc084b32eb56b31684d.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/files/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: sys-devel/binutils-config/files/ldwrapper.c X-VCS-Directories: sys-devel/binutils-config/files/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 753907f35f78864cf66a7bc084b32eb56b31684d X-VCS-Branch: master Date: Tue, 26 Sep 2023 19:38:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 03b3b94e-40b5-4a0e-8747-a9ae08a6e177 X-Archives-Hash: adc0ab45d71a9fc1c6f23339e42c3ef1 commit: 753907f35f78864cf66a7bc084b32eb56b31684d Author: Fabian Groffen gentoo org> AuthorDate: Tue Sep 26 19:30:33 2023 +0000 Commit: Fabian Groffen gentoo 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 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 -sdk_version */ - newargc += 4; + /* add -syslibroot -platform_version macos 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 */