darwin.adv_cmds: remove code for macOS < 11

This commit is contained in:
Emily 2024-10-05 19:09:03 +01:00
parent b937adc202
commit 7b3dd230da
5 changed files with 5 additions and 69 deletions

View File

@ -4,8 +4,6 @@
# Project settings
project('adv_cmds', 'c', 'cpp', version : '@version@')
sdk_version = get_option('sdk_version')
# Dependencies
cc = meson.get_compiler('c')
@ -190,8 +188,7 @@ install_man('ps/ps.1')
executable(
'stty',
build_by_default : sdk_version.version_compare('>=11.3'),
install : sdk_version.version_compare('>=11.3'),
install : true,
sources : [
'stty/cchar.c',
'stty/gfmt.c',
@ -202,9 +199,7 @@ executable(
'stty/util.c',
],
)
if sdk_version.version_compare('>=11.3')
install_man('stty/stty.1')
endif
install_man('stty/stty.1')
executable(
'tabs',

View File

@ -1 +0,0 @@
option('sdk_version', type : 'string')

View File

@ -1,7 +1,6 @@
{
lib,
apple-sdk,
apple-sdk_11,
bison,
flex,
libxo,
@ -12,9 +11,9 @@
}:
let
Libc = apple-sdk_11.sourceRelease "Libc";
libplatform = apple-sdk_11.sourceRelease "libplatform";
xnu = apple-sdk_11.sourceRelease "xnu";
Libc = apple-sdk.sourceRelease "Libc";
libplatform = apple-sdk.sourceRelease "libplatform";
xnu = apple-sdk.sourceRelease "xnu";
privateHeaders = stdenvNoCC.mkDerivation {
name = "adv_cmds-deps-private-headers";
@ -41,11 +40,6 @@ mkAppleDerivation {
xcodeHash = "sha256-2p/JyMPw6acHphvzkaJXPXGwxCUEoxryCejww5kPHvQ=";
patches = [
# Use older API when running on systems prior to 11.3.
./patches/0001-Fall-back-to-task_read_pid-on-older-systems.patch
];
postPatch = ''
# Meson generators require using @BASENAME@ in the output.
substituteInPlace mklocale/lex.l \
@ -67,8 +61,6 @@ mkAppleDerivation {
env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include";
buildInputs = [
# Use the 11.3 SDK because CMake depends on adv_cmds.ps, so it cant simply be omitted when using an older SDK.
apple-sdk_11
libxo
ncurses
];
@ -79,12 +71,6 @@ mkAppleDerivation {
pkg-config
];
mesonFlags = [
# Even though adv_cmds is built with a newer SDK, the default SDK is still the deployment target.
# Dont build packages that use newer APIs unnecessarily.
(lib.mesonOption "sdk_version" (lib.getVersion apple-sdk))
];
postInstall = ''
moveToOutput bin/ps "$ps"
ln -s "$ps/bin/ps" "$out/bin/ps"

View File

@ -1,38 +0,0 @@
From c05a83d29349c6ae2fd8084a48ea51c8e8bf23f2 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Sun, 18 Aug 2024 10:29:16 -0400
Subject: [PATCH] Fall back to `task_read_pid` on older systems
---
ps/tasks.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ps/tasks.c b/ps/tasks.c
index d2fcb07..068c985 100644
--- a/ps/tasks.c
+++ b/ps/tasks.c
@@ -25,8 +25,6 @@
#include <mach/shared_memory_server.h>
#include <mach/mach_vm.h>
-extern kern_return_t task_read_for_pid(task_port_t task, pid_t pid, task_port_t *target);
-
#define STATE_MAX 7
int
@@ -98,7 +96,11 @@ int get_task_info (KINFO *ki)
ki->state = STATE_MAX;
pid = KI_PROC(ki)->p_pid;
- error = task_read_for_pid(mach_task_self(), pid, &ki->task);
+ if (__builtin_available(macos 11.3, *)) {
+ error = task_read_for_pid(mach_task_self(), pid, &ki->task);
+ } else {
+ error = task_for_pid(mach_task_self(), pid, &ki->task);
+ }
if (error != KERN_SUCCESS) {
#ifdef DEBUG
mach_error("Error calling task_read_for_pid()", error);
--
2.44.1

View File

@ -681,12 +681,6 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
postLinkSignHook = prevStage.darwin.postLinkSignHook.override { inherit (selfDarwin) sigtool; };
adv_cmds = superDarwin.adv_cmds.override {
# Break an infinite recursion between CMake and libtapi. CMake requires adv_cmds.ps, and adv_cmds
# requires a newer SDK that requires libtapi to build, which requires CMake.
inherit (prevStage) apple-sdk_11;
};
# Rewrap binutils with the real libSystem
binutils = superDarwin.binutils.override {
inherit (self) coreutils;