darwin.Libsystem: get headers from AvailabilityVersions

While these headers correspond to a newer SDK, they’re compatible with the 10.12 SDK and more compatible with GCC.
This commit is contained in:
Randy Eckenrode 2024-04-18 20:13:00 -04:00
parent 7f45223bea
commit b7952b4729
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
3 changed files with 8 additions and 24 deletions

View File

@ -1,5 +1,5 @@
{ lib, stdenv, buildPackages, fetchzip, fetchFromGitHub
, appleDerivation', xnu, Libc, Libm, libdispatch, Libinfo
, appleDerivation', AvailabilityVersions, sdkRoot, xnu, Libc, Libm, libdispatch, Libinfo
, dyld, Csu, architecture, libclosure, CarbonHeaders, ncurses, CommonCrypto
, copyfile, removefile, libresolvHeaders, libresolv, Libnotify, libmalloc, libplatform, libpthread
, mDNSResponder, launchd, libutilHeaders, hfsHeaders, darwin-stubs
@ -48,9 +48,11 @@ appleDerivation' stdenv {
# Set up our include directories
(cd ${xnu}/include && find . -name '*.h' -or -name '*.defs' | copyHierarchy $out/include)
cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/Availability*.h $out/include
cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h $out/include
# These headers are from a newer SDK, but theyre more compatible with GCC (and still work with older SDKs).
${lib.getExe AvailabilityVersions} ${lib.getVersion sdkRoot} "$out"
for dep in ${Libc} ${Libm} ${Libinfo} ${dyld} ${architecture} \
${libclosure} ${CarbonHeaders} ${libdispatch} ${ncurses.dev} \
${CommonCrypto} ${copyfile} ${removefile} ${libresolvHeaders} \
@ -74,27 +76,6 @@ appleDerivation' stdenv {
cp ${darling.src}/src/libc/os/log.h $out/include/os
cp ${darling.src}/src/duct/include/os/trace.h $out/include/os
cat <<EOF > $out/include/os/availability.h
#ifndef __OS_AVAILABILITY__
#define __OS_AVAILABILITY__
#include <AvailabilityInternal.h>
#if defined(__has_feature) && defined(__has_attribute) && __has_attribute(availability)
#define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
#define API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__, __API_DEPRECATED_MSG5, __API_DEPRECATED_MSG4, __API_DEPRECATED_MSG3, __API_DEPRECATED_MSG2, __API_DEPRECATED_MSG1)(__VA_ARGS__)
#define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__, __API_DEPRECATED_REP5, __API_DEPRECATED_REP4, __API_DEPRECATED_REP3, __API_DEPRECATED_REP2, __API_DEPRECATED_REP1)(__VA_ARGS__)
#define API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__, __API_UNAVAILABLE3, __API_UNAVAILABLE2, __API_UNAVAILABLE1)(__VA_ARGS__)
#else
#define API_AVAILABLE(...)
#define API_DEPRECATED(...)
#define API_DEPRECATED_WITH_REPLACEMENT(...)
#define API_UNAVAILABLE(...)
#endif
#endif
EOF
cat <<EOF > $out/include/TargetConditionals.h
#ifndef __TARGETCONDITIONALS__
#define __TARGETCONDITIONALS__

View File

@ -1,7 +1,9 @@
AssertMacros.h
Availability.h
AvailabilityInternal.h
AvailabilityInternalLegacy.h
AvailabilityMacros.h
AvailabilityVersions.h
Block.h
Block_private.h
CommonCrypto/CommonBaseXX.h
@ -1050,6 +1052,7 @@ os/overflow.h
os/semaphore_private.h
os/trace.h
os/tsd.h
os_availability.modulemap
os/voucher_activity_private.h
os/voucher_private.h
osfmk/UserNotification/KUNCUserNotifications.h

View File

@ -287,7 +287,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
else macosPackages_11_0_1.libplatform;
libpthread = applePackage "libpthread" "osx-10.12.6" "sha256-QvJ9PERmrCWBiDmOWrLvQUKZ4JxHuh8gS5nlZKDLqE8=" {};
libresolv = applePackage "libresolv" "osx-10.12.6" "sha256-FtvwjJKSFX6j9APYPC8WLXVOjbHLZa1Gcoc8yxLy8qE=" {};
Libsystem = applePackage "Libsystem" "osx-10.12.6" "sha256-zvRdCP//TjKCGAqm/5nJXPppshU1cv2fg/L/yK/olGQ=" {};
Libsystem = applePackage "Libsystem" "osx-10.12.6" "sha256-zvRdCP//TjKCGAqm/5nJXPppshU1cv2fg/L/yK/olGQ=" { inherit (pkgs.darwin.apple_sdk) sdkRoot; };
libutil = applePackage "libutil" "osx-10.12.6" "sha256-4PFuk+CTLwvd/Ll9GLBkiIM0Sh/CVaiKwh5m1noheRs=" {};
libunwind = applePackage "libunwind" "osx-10.12.6" "sha256-CC0sndP/mKYe3dZu3v7fjuDASV4V4w7dAcnWMvpoquE=" {};
mDNSResponder = applePackage "mDNSResponder" "osx-10.12.6" "sha256-ddZr6tropkpdMJhq/kUlm3OwO8b0yxtkrMpwec8R4FY=" {};