Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cctools: 973.0.1 -> 1010.6 #307880

Merged
merged 24 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1cb1853
ld-wrapper: use a temporary file for reponse file
reckenrode Apr 14, 2024
4712e8f
libredirect: use llvmPackages unconditionally
reckenrode Apr 16, 2024
91d8dd9
darwin.apple_sdk_10_12.sdkRoot: specify exact SDK version
reckenrode Jul 3, 2024
3a545f6
darwin.AvailabilityVersions: init at 140.1
reckenrode Apr 19, 2024
7f45223
darwin.binutils: add dwarfdump and fix typo
reckenrode Jul 13, 2024
b7952b4
darwin.Libsystem: get headers from AvailabilityVersions
reckenrode Apr 19, 2024
4ee4fe5
darwin.configd: remove dependency on CF for private headers
reckenrode Apr 14, 2024
baf3568
darwin.libdispatch: 442.1.4 -> 703.50.37
reckenrode Apr 9, 2024
cdf968c
libtapi: 1100.0.11 -> 1500.0.12.3
reckenrode Apr 6, 2024
f02b50b
ld64: init at 951.9
reckenrode Apr 9, 2024
9f68d60
cctools: 973.0.1 -> 1010.6
reckenrode Apr 8, 2024
65a37e7
darwin.stdenv: make sure curl cannot be used
reckenrode Apr 14, 2024
8559d64
darwin.stdenv: always use a response file
reckenrode Jul 1, 2024
78da51c
darwin.stdenv: adjust flags for llvm-strip in bootstrap tools
reckenrode Jul 1, 2024
7f1bc0d
binutils: drop Darwin hack
reckenrode Jul 1, 2024
05e5d7f
darwin.stdenv: clean up GNU binutils ban
reckenrode Jul 1, 2024
9403fdc
darwin.stdenv: consolidate stage 2 into one stage
reckenrode Jul 1, 2024
10c87ee
stdenv: set NIX_DONT_SET_RPATH_FOR_TARGET on Darwin
reckenrode Apr 25, 2024
c922cb2
bintools-wrapper: drop postLinkSignHook
reckenrode Apr 14, 2024
a49dbb2
darwin.stdenv: switch to top-level cctools and ld64
reckenrode Jul 1, 2024
ca92415
dotnet: use dwarfdump from darwin.binutils
reckenrode Jul 13, 2024
79f5f9b
ghc: update Darwin bintools references
reckenrode Jul 4, 2024
76e1209
darwin.{cctools,libtapi}: drop old source
reckenrode Jul 1, 2024
9641ac5
darwin.cctools-{apple,llvm}: add to darwin-aliases.nix
reckenrode Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions pkgs/build-support/bintools-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
(!(targetPlatform.isAarch && targetPlatform.isStatic))
])
]) "pie"

# Darwin code signing support utilities
, postLinkSignHook ? null, signingUtils ? null
}:

assert propagateDoc -> bintools ? man;
Expand Down Expand Up @@ -357,7 +354,7 @@ stdenvNoCC.mkDerivation {
##

# TODO(@sternenseemann): make a generic strip wrapper?
+ optionalString (bintools.isGNU or false) ''
+ optionalString (bintools.isGNU or false || bintools.isCCTools or false) ''
wrap ${targetPrefix}strip ${./gnu-binutils-strip-wrapper.sh} \
"${bintools_bin}/bin/${targetPrefix}strip"
''
Expand Down Expand Up @@ -396,24 +393,6 @@ stdenvNoCC.mkDerivation {
''
)

##
## Code signing on Apple Silicon
##
+ optionalString (targetPlatform.isDarwin && targetPlatform.isAarch64) ''
echo 'source ${postLinkSignHook}' >> $out/nix-support/post-link-hook

export signingUtils=${signingUtils}

wrap \
${targetPrefix}install_name_tool \
${./darwin-install_name_tool-wrapper.sh} \
"${bintools_bin}/bin/${targetPrefix}install_name_tool"

wrap \
${targetPrefix}strip ${./darwin-strip-wrapper.sh} \
"${bintools_bin}/bin/${targetPrefix}strip"
''

##
## Extra custom steps
##
Expand Down
11 changes: 7 additions & 4 deletions pkgs/build-support/bintools-wrapper/ld-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ PATH="$path_backup"
# Old bash workaround, see above.

if (( "${NIX_LD_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
@prog@ @<(printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"})
responseFile=$(mktemp "${TMPDIR:-/tmp}/ld-params.XXXXXX")
trap 'rm -f -- "$responseFile"' EXIT
printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"} > "$responseFile"
@prog@ "@$responseFile"
else
@prog@ \
${extraBefore+"${extraBefore[@]}"} \
Expand Down
19 changes: 6 additions & 13 deletions pkgs/build-support/libredirect/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
{ lib, stdenv, bintools-unwrapped, llvmPackages, llvmPackages_13, coreutils }:

let
# aarch64-darwin needs a clang that can build arm64e binaries, so make sure a version of LLVM
# is used that can do that, but prefer the stdenv one if it is new enough.
llvmPkgs = if (lib.versionAtLeast (lib.getVersion llvmPackages.clang) "13")
then llvmPackages
else llvmPackages_13;
in
{ lib, stdenv, bintools-unwrapped, llvmPackages, coreutils }:

if stdenv.hostPlatform.isStatic
then throw ''
libredirect is not available on static builds.
Expand Down Expand Up @@ -46,11 +39,11 @@ else stdenv.mkDerivation rec {
# and the library search directory for libdl.
# We can't build this on x86_64, because the libSystem we point to doesn't
# like arm64(e).
PATH=${bintools-unwrapped}/bin:${llvmPkgs.clang-unwrapped}/bin:$PATH \
PATH=${bintools-unwrapped}/bin:${llvmPackages.clang-unwrapped}/bin:$PATH \
clang -arch x86_64 -arch arm64 -arch arm64e \
-isystem ${llvmPkgs.clang.libc}/include \
-isystem ${llvmPkgs.libclang.lib}/lib/clang/*/include \
-L${llvmPkgs.clang.libc}/lib \
-isystem ${llvmPackages.clang.libc}/include \
-isystem ${llvmPackages.libclang.lib}/lib/clang/*/include \
-L${llvmPackages.clang.libc}/lib \
-Wl,-install_name,$libName \
-Wall -std=c99 -O3 -fPIC libredirect.c \
-shared -o "$libName"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 55b2a5fcc38eb62f53e155bd8c741481690f1c73 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Wed, 10 Apr 2024 19:08:39 -0400
Subject: [PATCH 1/6] Fix build issues with misc/redo_prebinding.c

- Add missing headers; and
- Add missing arguments to `writeout`.
---
misc/redo_prebinding.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/misc/redo_prebinding.c b/misc/redo_prebinding.c
index a5a3c81..9d0f4c8 100644
--- a/misc/redo_prebinding.c
+++ b/misc/redo_prebinding.c
@@ -83,6 +83,7 @@
#include <mach-o/redo_prebinding.h>
#endif /* defined(LIBRARY_API) */

+#import <stdint.h>
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
@@ -106,7 +107,7 @@
#import <stuff/hppa.h>
#import <stuff/execute.h>
#import <stuff/guess_short_name.h>
-//#import <stuff/seg_addr_table.h>
+#import <stuff/seg_addr_table.h>
#import <stuff/macosx_deployment_target.h>

#include <mach-o/dyld.h>
@@ -918,7 +919,7 @@ char *envp[])
if(write_to_stdout)
output_file = NULL;
writeout(archs, narchs, output_file, mode, TRUE, FALSE, FALSE,
- FALSE, NULL);
+ FALSE, FALSE, NULL);
if(errors){
if(write_to_stdout == FALSE)
unlink(output_file);
@@ -928,7 +929,7 @@ char *envp[])
else{
output_file = makestr(input_file, ".redo_prebinding", NULL);
writeout(archs, narchs, output_file, mode, TRUE, FALSE, FALSE,
- FALSE, NULL);
+ FALSE, FALSE, NULL);
if(errors){
unlink(output_file);
return(2);
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 419c469634891d09f6688d56da9e26431018f342 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Wed, 10 Apr 2024 20:36:53 -0400
Subject: [PATCH 2/6] Rely on libcd_is_blob_a_linker_signature

---
libstuff/code_directory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstuff/code_directory.c b/libstuff/code_directory.c
index 7c158fa..3b8eb77 100644
--- a/libstuff/code_directory.c
+++ b/libstuff/code_directory.c
@@ -146,7 +146,7 @@ static const char* format_version_xyz(uint32_t version)
*/
int codedir_is_linker_signed(const char* data, uint32_t size)
{
-#if 1
reckenrode marked this conversation as resolved.
Show resolved Hide resolved
+#if 0
// HACK: libcodedirectory.h is in both the macOS SDK in /usr/local/include, and in the tool chain at /usr/include.
// but there is no way to control clang's search path to look in the toolchain first.
// So, declare newer API locally. Once this new header is in all SDKs we can remove this.
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 989ba5e30cefa0dd8990da158661713c4a21c0fe Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Thu, 11 Apr 2024 18:05:34 -0400
Subject: [PATCH 3/6] Fix utimensat compatability with the 10.12 SDK

---
include/compat.h | 3 +++
libstuff/writeout.c | 2 +-
misc/lipo.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
create mode 100644 include/compat.h

diff --git a/include/compat.h b/include/compat.h
new file mode 100644
index 0000000..8b1b866
--- /dev/null
+++ b/include/compat.h
@@ -0,0 +1,3 @@
+#pragma once
+#include <time.h>
+extern int utimensat(int dirfd, const char* pathname, const struct timespec times[_Nullable 2], int flags);
diff --git a/libstuff/writeout.c b/libstuff/writeout.c
index f904caa..03fa535 100644
--- a/libstuff/writeout.c
+++ b/libstuff/writeout.c
@@ -297,7 +297,7 @@ no_throttle:
* have been zeroed out when the library was created. writeout
* will not zero out the modification time in the filesystem.
*/
- if (__builtin_available(macOS 10.12, *)) {
+ if (__builtin_available(macOS 10.13, *)) {
struct timespec times[2] = {0};
memcpy(&times[0], &toc_timespec, sizeof(struct timespec));
memcpy(&times[1], &toc_timespec, sizeof(struct timespec));
diff --git a/misc/lipo.c b/misc/lipo.c
index 04a3eca..887c049 100644
--- a/misc/lipo.c
+++ b/misc/lipo.c
@@ -607,7 +607,7 @@ unknown_flag:
if(close(fd) == -1)
system_fatal("can't close output file: %s",output_file);
#ifndef __OPENSTEP__
- if (__builtin_available(macOS 10.12, *)) {
+ if (__builtin_available(macOS 10.13, *)) {
time_result = utimensat(AT_FDCWD, output_file,
output_times, 0);
}
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From 86b5ad551ef0ffc7ca4da24b7619937bec738522 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Mon, 15 Apr 2024 20:47:59 -0400
Subject: [PATCH 4/6] Use nixpkgs clang with the assembler driver

---
as/driver.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/as/driver.c b/as/driver.c
index a0d49ad..c15dcbf 100644
--- a/as/driver.c
+++ b/as/driver.c
@@ -36,7 +36,7 @@ char **envp)
char *p, c, *arch_name, *as, *as_local;
char **new_argv;
const char *CLANG = "clang";
- char *prefix, buf[MAXPATHLEN], resolved_name[PATH_MAX];
+ char *prefix = "@clang-unwrapped@/bin/";
uint32_t bufsize;
struct arch_flag arch_flag;
const struct arch_flag *arch_flags, *family_arch_flag;
@@ -50,22 +50,6 @@ char **envp)
qflag = FALSE;
Qflag = FALSE;
some_input_files = FALSE;
- /*
- * Construct the prefix to the assembler driver.
- */
- bufsize = MAXPATHLEN;
- p = buf;
- i = _NSGetExecutablePath(p, &bufsize);
- if(i == -1){
- p = allocate(bufsize);
- _NSGetExecutablePath(p, &bufsize);
- }
- prefix = realpath(p, resolved_name);
- if(prefix == NULL)
- system_fatal("realpath(3) for %s failed", p);
- p = rindex(prefix, '/');
- if(p != NULL)
- p[1] = '\0';
/*
* Process the assembler flags exactly like the assembler would (except
* let the assembler complain about multiple flags, bad combinations of
@@ -362,6 +346,8 @@ char **envp)
exit(1);
}

+ prefix = "@gas@/bin/"; /* `libexec` is found relative to the assembler driver’s path. */
toonn marked this conversation as resolved.
Show resolved Hide resolved
+
/*
* If this assembler exist try to run it else print an error message.
*/
--
2.45.2

28 changes: 28 additions & 0 deletions pkgs/by-name/cc/cctools/0005-Find-ld64-in-the-store.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From e62f7d75380540937f24f896c82736a1e653cc75 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Mon, 22 Apr 2024 18:15:53 -0400
Subject: [PATCH 5/6] Find ld64 in the store

---
libstuff/execute.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/libstuff/execute.c b/libstuff/execute.c
index 8526ab7..abbbf1b 100644
--- a/libstuff/execute.c
+++ b/libstuff/execute.c
@@ -149,6 +149,11 @@ char *
cmd_with_prefix(
char *str)
{
+ // Return the path to ld64 in the store.
+ if (strcmp(str, "ld") == 0) {
+ return "@ld64_path@";
+ }
+
int i;
char *p;
char *prefix, buf[MAXPATHLEN], resolved_name[PATH_MAX];
--
2.45.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From e25de788260051892b9e34177ea957cbafe6c415 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Thu, 2 May 2024 07:55:05 -0400
Subject: [PATCH 6/6] Support target prefixes in ranlib detection

---
misc/libtool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/misc/libtool.c b/misc/libtool.c
index 289ec4d..8265d53 100644
--- a/misc/libtool.c
+++ b/misc/libtool.c
@@ -426,11 +426,11 @@ char **envp)
p++;
else
p = argv[0];
- if(strncmp(p, "ranlib", sizeof("ranlib") - 1) == 0) {
+ if(strncmp(p, "@targetPrefix@ranlib", sizeof("@targetPrefix@ranlib") - 1) == 0) {
cmd_flags.ranlib = TRUE;
}
else if (getenv("LIBTOOL_FORCE_RANLIB")) {
- progname = "ranlib";
+ progname = "@targetPrefix@ranlib";
cmd_flags.ranlib = TRUE;
}

--
2.45.2

Loading