Merge pull request #105026 from thefloweringash/apple-silicon
Native support for Apple Silicon
This commit is contained in:
@@ -8,7 +8,11 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "0hh4jl590jv3v830p77r3jcrnpndy7p2b8ajai3ldpnx2913jfhp";
|
||||
};
|
||||
|
||||
patchPhase = ''
|
||||
patches = [
|
||||
./sw_vers-CFPriv.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace Makefile \
|
||||
--replace gcc cc
|
||||
'';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/sw_vers.c 2021-04-19 13:06:50.131346864 +0900
|
||||
+++ b/sw_vers.c 2021-04-19 13:07:32.481967474 +0900
|
||||
@@ -28,7 +28,15 @@
|
||||
*/
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
-#include <CoreFoundation/CFPriv.h>
|
||||
+
|
||||
+// Avoid dependency on CoreFoundation/CFPriv, which no longer appears to be
|
||||
+// part of the upstream sdk.
|
||||
+
|
||||
+CFDictionaryRef _CFCopyServerVersionDictionary(void);
|
||||
+CFDictionaryRef _CFCopySystemVersionDictionary(void);
|
||||
+extern CFStringRef _kCFSystemVersionProductNameKey;
|
||||
+extern CFStringRef _kCFSystemVersionProductVersionKey;
|
||||
+extern CFStringRef _kCFSystemVersionBuildVersionKey;
|
||||
|
||||
void usage(char *progname) {
|
||||
fprintf(stderr, "Usage: %s [-productName|-productVersion|-buildVersion]\n", progname);
|
||||
@@ -0,0 +1,151 @@
|
||||
{ lib, stdenvNoCC, buildPackages, fetchurl, xar, cpio, pkgs, python3, pbzx, MacOSX-SDK }:
|
||||
|
||||
# TODO: reorganize to make this just frameworks, and move libs to default.nix
|
||||
|
||||
let
|
||||
stdenv = stdenvNoCC;
|
||||
|
||||
standardFrameworkPath = name: private:
|
||||
"/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework";
|
||||
|
||||
mkDepsRewrites = deps:
|
||||
let
|
||||
mergeRewrites = x: y: {
|
||||
prefix = lib.mergeAttrs (x.prefix or {}) (y.prefix or {});
|
||||
const = lib.mergeAttrs (x.const or {}) (y.const or {});
|
||||
};
|
||||
|
||||
rewriteArgs = { prefix ? {}, const ? {} }: lib.concatLists (
|
||||
(lib.mapAttrsToList (from: to: [ "-p" "${from}:${to}" ]) prefix) ++
|
||||
(lib.mapAttrsToList (from: to: [ "-c" "${from}:${to}" ]) const)
|
||||
);
|
||||
|
||||
rewrites = depList: lib.fold mergeRewrites {}
|
||||
(map (dep: dep.tbdRewrites)
|
||||
(lib.filter (dep: dep ? tbdRewrites) depList));
|
||||
in
|
||||
lib.escapeShellArgs (rewriteArgs (rewrites (builtins.attrValues deps)));
|
||||
|
||||
mkFramework = { name, deps, private ? false }:
|
||||
let self = stdenv.mkDerivation {
|
||||
pname = "apple-${lib.optionalString private "private-"}framework-${name}";
|
||||
version = MacOSX-SDK.version;
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
# because we copy files from the system
|
||||
preferLocalBuild = true;
|
||||
|
||||
disallowedRequisites = [ MacOSX-SDK ];
|
||||
|
||||
nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/Library/Frameworks
|
||||
|
||||
cp -r ${MacOSX-SDK}${standardFrameworkPath name private} $out/Library/Frameworks
|
||||
|
||||
# Fix and check tbd re-export references
|
||||
chmod u+w -R $out
|
||||
find $out -name '*.tbd' -type f | while read tbd; do
|
||||
echo "Fixing re-exports in $tbd"
|
||||
rewrite-tbd \
|
||||
-p ${standardFrameworkPath name private}/:$out/Library/Frameworks/${name}.framework/ \
|
||||
${mkDepsRewrites deps} \
|
||||
-r ${builtins.storeDir} \
|
||||
"$tbd"
|
||||
done
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = builtins.attrValues deps;
|
||||
|
||||
passthru = {
|
||||
tbdRewrites = {
|
||||
prefix."${standardFrameworkPath name private}/" = "${self}/Library/Frameworks/${name}.framework/";
|
||||
};
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Apple SDK framework ${name}";
|
||||
maintainers = with maintainers; [ copumpkin ];
|
||||
platforms = platforms.darwin;
|
||||
};
|
||||
};
|
||||
in self;
|
||||
|
||||
framework = name: deps: mkFramework { inherit name deps; private = false; };
|
||||
privateFramework = name: deps: mkFramework { inherit name deps; private = true; };
|
||||
in rec {
|
||||
libs = {
|
||||
xpc = stdenv.mkDerivation {
|
||||
name = "apple-lib-xpc";
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/include
|
||||
pushd $out/include >/dev/null
|
||||
cp -r "${MacOSX-SDK}/usr/include/xpc" $out/include/xpc
|
||||
cp "${MacOSX-SDK}/usr/include/launch.h" $out/include/launch.h
|
||||
popd >/dev/null
|
||||
'';
|
||||
};
|
||||
|
||||
Xplugin = stdenv.mkDerivation {
|
||||
name = "apple-lib-Xplugin";
|
||||
dontUnpack = true;
|
||||
|
||||
propagatedBuildInputs = with frameworks; [
|
||||
OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/include $out/lib
|
||||
ln -s "${MacOSX-SDK}/include/Xplugin.h" $out/include/Xplugin.h
|
||||
cp ${MacOSX-SDK}/usr/lib/libXplugin.1.tbd $out/lib
|
||||
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
|
||||
'';
|
||||
};
|
||||
|
||||
utmp = stdenv.mkDerivation {
|
||||
name = "apple-lib-utmp";
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/include
|
||||
pushd $out/include >/dev/null
|
||||
ln -s "${MacOSX-SDK}/include/utmp.h"
|
||||
ln -s "${MacOSX-SDK}/include/utmpx.h"
|
||||
popd >/dev/null
|
||||
'';
|
||||
};
|
||||
|
||||
libDER = stdenv.mkDerivation {
|
||||
name = "apple-lib-libDER";
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/include
|
||||
cp -r ${MacOSX-SDK}/usr/include/libDER $out/include
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
overrides = super: {
|
||||
CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: {
|
||||
setupHook = ./cf-setup-hook.sh;
|
||||
});
|
||||
};
|
||||
|
||||
bareFrameworks = (
|
||||
lib.mapAttrs framework (import ./frameworks.nix {
|
||||
inherit frameworks libs;
|
||||
inherit (pkgs.darwin) libobjc Libsystem;
|
||||
inherit (pkgs.darwin.apple_sdk) libnetwork;
|
||||
})
|
||||
) // (
|
||||
lib.mapAttrs privateFramework (import ./private-frameworks.nix {
|
||||
inherit frameworks;
|
||||
})
|
||||
);
|
||||
|
||||
frameworks = bareFrameworks // overrides bareFrameworks;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
forceLinkCoreFoundationFramework() {
|
||||
NIX_CFLAGS_COMPILE="-F@out@/Library/Frameworks${NIX_CFLAGS_COMPILE:+ }${NIX_CFLAGS_COMPILE-}"
|
||||
NIX_LDFLAGS+=" @out@/Library/Frameworks/CoreFoundation.framework/CoreFoundation"
|
||||
}
|
||||
|
||||
preConfigureHooks+=(forceLinkCoreFoundationFramework)
|
||||
@@ -0,0 +1,58 @@
|
||||
{ stdenvNoCC, fetchurl, newScope, pkgs
|
||||
, xar, cpio, python3, pbzx }:
|
||||
|
||||
let
|
||||
MacOSX-SDK = stdenvNoCC.mkDerivation rec {
|
||||
pname = "MacOSX-SDK";
|
||||
version = "11.0.0";
|
||||
|
||||
# https://swscan.apple.com/content/catalogs/others/index-10.16.merged-1.sucatalog
|
||||
src = fetchurl {
|
||||
url = "http://swcdn.apple.com/content/downloads/58/37/001-75138-A_59RXKDS8YM/12ksm19hgzscfc7cau3yhecz4vpkps7wbq/CLTools_macOSNMOS_SDK.pkg";
|
||||
sha256 = "0n51ba926ckwm62w5c8lk3w5hj4ihk0p5j02321qi75wh824hl8m";
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
darwinDontCodeSign = true;
|
||||
|
||||
nativeBuildInputs = [ cpio pbzx ];
|
||||
|
||||
outputs = [ "out" ];
|
||||
|
||||
unpackPhase = ''
|
||||
pbzx $src | cpio -idm
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
cd Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk
|
||||
|
||||
mkdir $out
|
||||
cp -r System usr $out/
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit version;
|
||||
};
|
||||
};
|
||||
|
||||
callPackage = newScope (packages // pkgs.darwin // { inherit MacOSX-SDK; });
|
||||
|
||||
packages = {
|
||||
inherit (callPackage ./apple_sdk.nix {}) frameworks libs;
|
||||
|
||||
# TODO: this is nice to be private. is it worth the callPackage above?
|
||||
# Probably, I don't think that callPackage costs much at all.
|
||||
inherit MacOSX-SDK;
|
||||
|
||||
Libsystem = callPackage ./libSystem.nix {};
|
||||
LibsystemCross = pkgs.darwin.Libsystem;
|
||||
libcharset = callPackage ./libcharset.nix {};
|
||||
libunwind = callPackage ./libunwind.nix {};
|
||||
libnetwork = callPackage ./libnetwork.nix {};
|
||||
objc4 = callPackage ./libobjc.nix {};
|
||||
|
||||
# questionable aliases
|
||||
configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;
|
||||
IOKit = pkgs.darwin.apple_sdk.frameworks.IOKit;
|
||||
};
|
||||
in packages
|
||||
@@ -0,0 +1,193 @@
|
||||
{ frameworks, libs, libobjc, Libsystem, libnetwork }: with frameworks; with libs;
|
||||
{
|
||||
AGL = { inherit Carbon OpenGL; };
|
||||
AVFoundation = { inherit ApplicationServices AVFCapture AVFCore CoreGraphics; };
|
||||
AVKit = {};
|
||||
Accelerate = { inherit CoreWLAN IOBluetooth; };
|
||||
Accessibility = {};
|
||||
Accounts = {};
|
||||
AdSupport = {};
|
||||
AddressBook = { inherit AddressBookCore Carbon ContactsPersistence libobjc; };
|
||||
AppKit = { inherit ApplicationServices AudioToolbox AudioUnit Foundation QuartzCore UIFoundation; };
|
||||
AppTrackingTransparency = {};
|
||||
AppleScriptKit = {};
|
||||
AppleScriptObjC = {};
|
||||
ApplicationServices = { inherit ColorSync CoreGraphics CoreServices CoreText ImageIO; };
|
||||
AudioToolbox = { inherit AudioToolboxCore CoreAudio CoreMIDI; };
|
||||
AudioUnit = { inherit AudioToolbox Carbon CoreAudio; };
|
||||
AudioVideoBridging = { inherit Foundation; };
|
||||
AuthenticationServices = {};
|
||||
AutomaticAssessmentConfiguration = {};
|
||||
Automator = {};
|
||||
BackgroundTasks = {};
|
||||
BusinessChat = {};
|
||||
CFNetwork = {};
|
||||
CalendarStore = {};
|
||||
CallKit = {};
|
||||
Carbon = { inherit ApplicationServices CoreServices Foundation IOKit QuartzCore Security libobjc; };
|
||||
ClassKit = {};
|
||||
CloudKit = { inherit CoreLocation; };
|
||||
Cocoa = { inherit AppKit CoreData; };
|
||||
Collaboration = {};
|
||||
ColorSync = {};
|
||||
Combine = {};
|
||||
Contacts = {};
|
||||
ContactsUI = {};
|
||||
CoreAudio = { inherit IOKit CoreAudioTypes; };
|
||||
CoreAudioKit = { inherit AudioUnit; };
|
||||
CoreAudioTypes = {};
|
||||
CoreBluetooth = {};
|
||||
CoreData = { inherit CloudKit; };
|
||||
CoreDisplay = {};
|
||||
CoreFoundation = { inherit libobjc; };
|
||||
CoreGraphics = { inherit Accelerate IOKit IOSurface SystemConfiguration; };
|
||||
CoreHaptics = {};
|
||||
CoreImage = {};
|
||||
CoreLocation = {};
|
||||
CoreMIDI = {};
|
||||
CoreMIDIServer = { inherit CoreMIDI; };
|
||||
CoreML = {};
|
||||
CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit CoreAudio CoreGraphics CoreVideo; };
|
||||
CoreMediaIO = { inherit CoreMedia; };
|
||||
CoreMotion = {};
|
||||
CoreServices = { inherit CFNetwork CoreAudio CoreData CoreFoundation DiskArbitration NetFS OpenDirectory Security ServiceManagement; };
|
||||
CoreSpotlight = {};
|
||||
CoreTelephony = {};
|
||||
CoreText = { inherit CoreGraphics; };
|
||||
CoreVideo = { inherit ApplicationServices CoreGraphics IOSurface OpenGL; };
|
||||
CoreWLAN = { inherit SecurityFoundation; };
|
||||
CryptoKit = {};
|
||||
CryptoTokenKit = {};
|
||||
DVDPlayback = {};
|
||||
DeveloperToolsSupport = {};
|
||||
DeviceCheck = {};
|
||||
DirectoryService = {};
|
||||
DiscRecording = { inherit CoreServices IOKit libobjc; };
|
||||
DiscRecordingUI = {};
|
||||
DiskArbitration = { inherit IOKit; };
|
||||
DriverKit = {};
|
||||
EventKit = {};
|
||||
ExceptionHandling = {};
|
||||
ExecutionPolicy = {};
|
||||
ExternalAccessory = {};
|
||||
FWAUserLib = {};
|
||||
FileProvider = {};
|
||||
FileProviderUI = {};
|
||||
FinderSync = {};
|
||||
ForceFeedback = { inherit IOKit; };
|
||||
Foundation = { inherit ApplicationServices CoreFoundation Security SystemConfiguration libobjc; };
|
||||
GLKit = {};
|
||||
GLUT = { inherit OpenGL; };
|
||||
GSS = {};
|
||||
GameController = {};
|
||||
GameKit = { inherit Cocoa Foundation GameCenterFoundation GameCenterUI GameCenterUICore GameController GameplayKit Metal MetalKit ModelIO ReplayKit SceneKit SpriteKit; };
|
||||
GameplayKit = {};
|
||||
HIDDriverKit = {};
|
||||
Hypervisor = {};
|
||||
ICADevices = { inherit Carbon IOBluetooth libobjc; };
|
||||
IMServicePlugIn = {};
|
||||
IOBluetooth = { inherit CoreBluetooth IOKit; };
|
||||
IOBluetoothUI = { inherit IOBluetooth; };
|
||||
IOKit = {};
|
||||
IOSurface = { inherit IOKit xpc; };
|
||||
IOUSBHost = {};
|
||||
IdentityLookup = {};
|
||||
ImageCaptureCore = {};
|
||||
ImageIO = { inherit CoreGraphics; };
|
||||
InputMethodKit = { inherit Carbon; };
|
||||
InstallerPlugins = {};
|
||||
InstantMessage = {};
|
||||
Intents = {};
|
||||
JavaNativeFoundation = {};
|
||||
JavaRuntimeSupport = {};
|
||||
JavaScriptCore = { inherit libobjc; };
|
||||
Kerberos = {};
|
||||
Kernel = { inherit IOKit; };
|
||||
KernelManagement = {};
|
||||
LDAP = {};
|
||||
LatentSemanticMapping = { inherit Carbon; };
|
||||
LinkPresentation = { inherit URLFormatting; };
|
||||
LocalAuthentication = {};
|
||||
MLCompute = {};
|
||||
MapKit = {};
|
||||
MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; };
|
||||
MediaLibrary = {};
|
||||
MediaPlayer = {};
|
||||
MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; };
|
||||
Message = {};
|
||||
Metal = {};
|
||||
MetalKit = { inherit Metal ModelIO; };
|
||||
MetalPerformanceShaders = {};
|
||||
MetalPerformanceShadersGraph = {};
|
||||
MetricKit = { inherit SignpostMetrics; };
|
||||
ModelIO = {};
|
||||
MultipeerConnectivity = {};
|
||||
NaturalLanguage = {};
|
||||
NearbyInteraction = {};
|
||||
NetFS = {};
|
||||
Network = { inherit libnetwork; };
|
||||
NetworkExtension = { inherit Network; };
|
||||
NetworkingDriverKit = {};
|
||||
NotificationCenter = {};
|
||||
OSAKit = { inherit Carbon; };
|
||||
OSLog = {};
|
||||
OpenAL = {};
|
||||
OpenCL = { inherit IOSurface OpenGL; };
|
||||
OpenDirectory = {};
|
||||
OpenGL = {};
|
||||
PCIDriverKit = {};
|
||||
PCSC = { inherit CoreData; };
|
||||
PDFKit = {};
|
||||
ParavirtualizedGraphics = {};
|
||||
PassKit = { inherit PassKitCore; };
|
||||
PencilKit = {};
|
||||
Photos = {};
|
||||
PhotosUI = {};
|
||||
PreferencePanes = {};
|
||||
PushKit = {};
|
||||
Python = {};
|
||||
QTKit = { inherit CoreMedia CoreMediaIO MediaToolbox VideoToolbox; };
|
||||
Quartz = { inherit QTKit QuartzCore QuickLook PDFKit; };
|
||||
QuartzCore = { inherit ApplicationServices CoreImage CoreVideo Metal OpenCL libobjc; };
|
||||
QuickLook = { inherit ApplicationServices; };
|
||||
QuickLookThumbnailing = {};
|
||||
RealityKit = {};
|
||||
ReplayKit = {};
|
||||
Ruby = {};
|
||||
SafariServices = {};
|
||||
SceneKit = {};
|
||||
ScreenSaver = {};
|
||||
ScreenTime = {};
|
||||
ScriptingBridge = {};
|
||||
Security = { inherit IOKit libDER; };
|
||||
SecurityFoundation = { inherit Security; };
|
||||
SecurityInterface = { inherit Security SecurityFoundation; };
|
||||
SensorKit = {};
|
||||
ServiceManagement = { inherit Security; };
|
||||
Social = {};
|
||||
SoundAnalysis = {};
|
||||
Speech = {};
|
||||
SpriteKit = {};
|
||||
StoreKit = {};
|
||||
SwiftUI = {};
|
||||
SyncServices = {};
|
||||
System = {};
|
||||
SystemConfiguration = { inherit Security; };
|
||||
SystemExtensions = {};
|
||||
TWAIN = { inherit Carbon; };
|
||||
Tcl = {};
|
||||
Tk = {};
|
||||
USBDriverKit = {};
|
||||
UniformTypeIdentifiers = {};
|
||||
UserNotifications = {};
|
||||
UserNotificationsUI = {};
|
||||
VideoDecodeAcceleration = { inherit CoreVideo; };
|
||||
VideoSubscriberAccount = {};
|
||||
VideoToolbox = { inherit CoreMedia CoreVideo; };
|
||||
Virtualization = {};
|
||||
Vision = {};
|
||||
WebKit = { inherit ApplicationServices Carbon JavaScriptCore OpenGL libobjc; };
|
||||
WidgetKit = {};
|
||||
iTunesLibrary = {};
|
||||
vmnet = {};
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "libSystem";
|
||||
version = MacOSX-SDK.version;
|
||||
|
||||
dontBuild = true;
|
||||
dontUnpack = true;
|
||||
|
||||
nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ];
|
||||
|
||||
includeDirs = [
|
||||
"CommonCrypto" "_types" "architecture" "arpa" "atm" "bank" "bsd" "bsm"
|
||||
"corecrypto" "corpses" "default_pager" "device" "dispatch" "hfs" "i386"
|
||||
"iokit" "kern" "libkern" "mach" "mach-o" "mach_debug" "machine" "malloc"
|
||||
"miscfs" "net" "netinet" "netinet6" "netkey" "nfs" "os" "osfmk" "pexpert"
|
||||
"platform" "protocols" "pthread" "rpc" "rpcsvc" "secure" "security"
|
||||
"servers" "sys" "uuid" "vfs" "voucher" "xlocale"
|
||||
] ++ [
|
||||
"arm" "xpc" "arm64"
|
||||
];
|
||||
|
||||
csu = [
|
||||
"bundle1.o" "crt0.o" "crt1.10.5.o" "crt1.10.6.o" "crt1.o" "dylib1.10.5.o"
|
||||
"dylib1.o" "gcrt1.o" "lazydylib1.o"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{include,lib}
|
||||
|
||||
for dir in $includeDirs; do
|
||||
from=${MacOSX-SDK}/usr/include/$dir
|
||||
if [ -e "$from" ]; then
|
||||
cp -dr $from $out/include
|
||||
else
|
||||
echo "Header directory '$from' doesn't exist: skipping"
|
||||
fi
|
||||
done
|
||||
|
||||
cp -d \
|
||||
${MacOSX-SDK}/usr/include/*.h \
|
||||
$out/include
|
||||
|
||||
rm $out/include/tk*.h $out/include/tcl*.h
|
||||
|
||||
cp -dr \
|
||||
${MacOSX-SDK}/usr/lib/libSystem.* \
|
||||
${MacOSX-SDK}/usr/lib/system \
|
||||
$out/lib
|
||||
|
||||
# Extra libraries
|
||||
for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.1 resolv; do
|
||||
cp -d \
|
||||
${MacOSX-SDK}/usr/lib/lib$name.tbd \
|
||||
${MacOSX-SDK}/usr/lib/lib$name.*.tbd \
|
||||
$out/lib
|
||||
done
|
||||
|
||||
for f in $csu; do
|
||||
from=${MacOSX-SDK}/usr/lib/$f
|
||||
if [ -e "$from" ]; then
|
||||
cp -d $from $out/lib
|
||||
else
|
||||
echo "Csu file '$from' doesn't exist: skipping"
|
||||
fi
|
||||
done
|
||||
|
||||
chmod u+w -R $out/lib
|
||||
find $out -name '*.tbd' -type f | while read tbd; do
|
||||
rewrite-tbd \
|
||||
-c /usr/lib/libsystem.dylib:$out/lib/libsystem.dylib \
|
||||
-p /usr/lib/system/:$out/lib/system/ \
|
||||
-r ${builtins.storeDir} \
|
||||
"$tbd"
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "libcharset";
|
||||
version = MacOSX-SDK.version;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{include,lib}
|
||||
cp ${MacOSX-SDK}/usr/lib/libcharset* $out/lib
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
|
||||
|
||||
let self = stdenvNoCC.mkDerivation {
|
||||
pname = "libnetwork";
|
||||
version = MacOSX-SDK.version;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib
|
||||
cp ${MacOSX-SDK}/usr/lib/libnetwork* $out/lib
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tbdRewrites = {
|
||||
const."/usr/lib/libnetwork.dylib" = "${self}/lib/libnetwork.dylib";
|
||||
};
|
||||
};
|
||||
}; in self
|
||||
@@ -0,0 +1,21 @@
|
||||
{ stdenvNoCC, MacOSX-SDK, libcharset }:
|
||||
|
||||
let self = stdenvNoCC.mkDerivation {
|
||||
pname = "libobjc";
|
||||
version = MacOSX-SDK.version;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{include,lib}
|
||||
cp -r ${MacOSX-SDK}/usr/include/objc $out/include
|
||||
cp ${MacOSX-SDK}/usr/lib/libobjc* $out/lib
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tbdRewrites = {
|
||||
const."/usr/lib/libobjc.A.dylib" = "${self}/lib/libobjc.A.dylib";
|
||||
};
|
||||
};
|
||||
}; in self
|
||||
@@ -0,0 +1,24 @@
|
||||
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "libunwind";
|
||||
version = MacOSX-SDK.version;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/include/mach-o
|
||||
|
||||
cp \
|
||||
${MacOSX-SDK}/usr/include/libunwind.h \
|
||||
${MacOSX-SDK}/usr/include/unwind.h \
|
||||
$out/include
|
||||
|
||||
cp \
|
||||
${MacOSX-SDK}/usr/include/mach-o/compact_unwind_encoding.h \
|
||||
$out/include/mach-o
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{ frameworks }: with frameworks;
|
||||
# generated by hand to avoid exposing all private frameworks
|
||||
# frameworks here are only the necessary ones used by public frameworks.
|
||||
{
|
||||
AVFCapture = {};
|
||||
AVFCore = {};
|
||||
AddressBookCore = { inherit ContactsPersistence; };
|
||||
AudioToolboxCore = {};
|
||||
ContactsPersistence = {};
|
||||
UIFoundation = {};
|
||||
GameCenterFoundation = {};
|
||||
GameCenterUI = {};
|
||||
GameCenterUICore = {};
|
||||
URLFormatting = {};
|
||||
SignpostMetrics = {};
|
||||
PassKitCore = {};
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
{ appleDerivation, python3 }:
|
||||
{ appleDerivation, lib, stdenv, buildPackages, python3 }:
|
||||
|
||||
let
|
||||
formatVersionNumeric = version:
|
||||
let
|
||||
versionParts = lib.versions.splitVersion version;
|
||||
major = lib.toInt (lib.elemAt versionParts 0);
|
||||
minor = lib.toInt (lib.elemAt versionParts 1);
|
||||
patch = if lib.length versionParts > 2 then lib.toInt (lib.elemAt versionParts 2) else 0;
|
||||
in toString (major * 10000 + minor * 100 + patch);
|
||||
in
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ python3 ];
|
||||
|
||||
depsBuildBuild = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace makefile \
|
||||
--replace "/usr/bin/" "" \
|
||||
@@ -26,6 +38,13 @@ appleDerivation {
|
||||
--replace "&TestMailFilterCSS" "NULL"
|
||||
|
||||
patchShebangs icuSources
|
||||
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
||||
|
||||
# This looks like a bug in the makefile. It defines ENV_BUILDHOST to
|
||||
# propagate the correct value of CC, CXX, etc, but has the following double
|
||||
# expansion that results in the empty string.
|
||||
substituteInPlace makefile \
|
||||
--replace '$($(ENV_BUILDHOST))' '$(ENV_BUILDHOST)'
|
||||
'';
|
||||
|
||||
# APPLE is using makefile to save its default configuration and call ./configure, so we hack makeFlags
|
||||
@@ -40,10 +59,21 @@ appleDerivation {
|
||||
|
||||
"DATA_INSTALL_DIR=/share/icu/"
|
||||
"DATA_LOOKUP_DIR=$(DSTROOT)$(DATA_INSTALL_DIR)"
|
||||
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # darwin* platform properties are only defined on darwin
|
||||
# hack to use our lower macos version
|
||||
"MAC_OS_X_VERSION_MIN_REQUIRED=__MAC_OS_X_VERSION_MIN_REQUIRED"
|
||||
"OSX_HOST_VERSION_MIN_STRING=$(MACOSX_DEPLOYMENT_TARGET)"
|
||||
"MAC_OS_X_VERSION_MIN_REQUIRED=${formatVersionNumeric stdenv.hostPlatform.darwinMinVersion}"
|
||||
"ICU_TARGET_VERSION=-m${stdenv.hostPlatform.darwinPlatform}-version-min=${stdenv.hostPlatform.darwinMinVersion}"
|
||||
]
|
||||
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
||||
"CROSS_BUILD=YES"
|
||||
"BUILD_TYPE="
|
||||
"RC_ARCHS=${stdenv.hostPlatform.darwinArch}"
|
||||
"HOSTCC=cc"
|
||||
"HOSTCXX=c++"
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"CXX=${stdenv.cc.targetPrefix}c++"
|
||||
"HOSTISYSROOT="
|
||||
"OSX_HOST_VERSION_MIN_STRING=${stdenv.buildPlatform.darwinMinVersion}"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ lib, appleDerivation, fetchzip, bsdmake, perl, flex, bison
|
||||
{ lib, stdenv, buildPackages, appleDerivation, fetchzip, bsdmake, perl, flex, bison
|
||||
}:
|
||||
|
||||
# this derivation sucks
|
||||
@@ -16,6 +16,7 @@ let recentAdvCmds = fetchzip {
|
||||
};
|
||||
|
||||
in appleDerivation {
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
nativeBuildInputs = [ bsdmake perl bison flex ];
|
||||
buildInputs = [ flex ];
|
||||
|
||||
@@ -61,7 +62,7 @@ in appleDerivation {
|
||||
|
||||
bsdmake -C usr-share-locale.tproj
|
||||
|
||||
clang ${recentAdvCmds}/ps/*.c -o ps
|
||||
${stdenv.cc.targetPrefix}clang ${recentAdvCmds}/ps/*.c -o ps
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{ lib, appleDerivation, xcbuildHook, llvmPackages }:
|
||||
{ lib, appleDerivation, xcbuildHook, llvmPackages, makeWrapper }:
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ xcbuildHook ];
|
||||
nativeBuildInputs = [ xcbuildHook makeWrapper ];
|
||||
|
||||
patches = [
|
||||
# The following copied from
|
||||
@@ -11,8 +11,9 @@ appleDerivation {
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
makeWrapper ${llvmPackages.clang}/bin/clang $out/bin/clang-cpp --add-flags "--driver-mode=cpp"
|
||||
substituteInPlace rpcgen/rpc_main.c \
|
||||
--replace "/usr/bin/cpp" "${llvmPackages.clang-unwrapped}/bin/clang-cpp"
|
||||
--replace "/usr/bin/cpp" "$out/bin/clang-cpp"
|
||||
'';
|
||||
|
||||
# temporary install phase until xcodebuild has "install" support
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{ lib, appleDerivation, xcbuildHook, zlib, bzip2, xz, ncurses, libutil }:
|
||||
{ lib, appleDerivation, xcbuildHook, zlib, bzip2, xz, ncurses, libutil, Libinfo }:
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ xcbuildHook ];
|
||||
buildInputs = [ zlib bzip2 xz ncurses libutil ];
|
||||
buildInputs = [ zlib bzip2 xz ncurses libutil Libinfo ];
|
||||
|
||||
# some commands not working:
|
||||
# mtree: _simple.h not found
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{ lib, appleDerivation, xcbuildHook }:
|
||||
{ lib, appleDerivation, xcbuildHook, launchd }:
|
||||
|
||||
appleDerivation {
|
||||
nativeBuildInputs = [ xcbuildHook ];
|
||||
nativeBuildInputs = [ xcbuildHook launchd ];
|
||||
|
||||
patchPhase = ''
|
||||
# NOTE: these hashes must be recalculated for each version change
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{ stdenv, appleDerivation, lib
|
||||
, Librpcsvc, apple_sdk, pam, CF, openbsm }:
|
||||
, libutil, Librpcsvc, apple_sdk, pam, CF, openbsm }:
|
||||
|
||||
appleDerivation {
|
||||
# xcbuild fails with:
|
||||
@@ -7,7 +7,7 @@ appleDerivation {
|
||||
# see issue facebook/xcbuild#188
|
||||
# buildInputs = [ xcbuild ];
|
||||
|
||||
buildInputs = [ Librpcsvc apple_sdk.frameworks.OpenDirectory pam CF
|
||||
buildInputs = [ libutil Librpcsvc apple_sdk.frameworks.OpenDirectory pam CF
|
||||
apple_sdk.frameworks.IOKit openbsm ];
|
||||
# NIX_CFLAGS_COMPILE = lib.optionalString hostPlatform.isi686 "-D__i386__"
|
||||
# + lib.optionalString hostPlatform.isx86_64 "-D__x86_64__"
|
||||
@@ -35,6 +35,11 @@ appleDerivation {
|
||||
--replace bsm/audit_session.h bsm/audit.h
|
||||
substituteInPlace login.tproj/login_audit.c \
|
||||
--replace bsm/audit_session.h bsm/audit.h
|
||||
'' + lib.optionalString stdenv.isAarch64 ''
|
||||
substituteInPlace sysctl.tproj/sysctl.c \
|
||||
--replace "GPROF_STATE" "0"
|
||||
substituteInPlace login.tproj/login.c \
|
||||
--replace "defined(__arm__)" "defined(__arm__) || defined(__arm64__)"
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
|
||||
@@ -9,6 +9,7 @@ let
|
||||
cmds = [
|
||||
"ar" "ranlib" "as" "install_name_tool"
|
||||
"ld" "strip" "otool" "lipo" "nm" "strings" "size"
|
||||
"codesign_allocate"
|
||||
];
|
||||
in
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, autoreconfHook
|
||||
, installShellFiles
|
||||
, libcxxabi, libuuid
|
||||
, libuuid
|
||||
, libobjc ? null, maloader ? null
|
||||
, enableTapiSupport ? true, libtapi
|
||||
}:
|
||||
@@ -32,7 +32,7 @@ stdenv.mkDerivation {
|
||||
|
||||
nativeBuildInputs = [ autoconf automake libtool autoreconfHook installShellFiles ];
|
||||
buildInputs = [ libuuid ]
|
||||
++ lib.optionals stdenv.isDarwin [ libcxxabi libobjc ]
|
||||
++ lib.optionals stdenv.isDarwin [ libobjc ]
|
||||
++ lib.optional enableTapiSupport libtapi;
|
||||
|
||||
patches = [ ./ld-ignore-rpath-link.patch ./ld-rpath-nonfinal.patch ];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{ lib, stdenv, fetchFromGitHub, cmake, python3, ncurses }:
|
||||
{ lib, stdenv, fetchFromGitHub, pkgsBuildBuild, cmake, python3, ncurses }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation {
|
||||
pname = "libtapi";
|
||||
version = "1100.0.11"; # determined by looking at VERSION.txt
|
||||
|
||||
@@ -13,13 +13,43 @@ stdenv.mkDerivation rec {
|
||||
|
||||
sourceRoot = "source/src/llvm";
|
||||
|
||||
# Backported from newer llvm, fixes configure error when cross compiling.
|
||||
# Also means we don't have to manually fix the result with install_name_tool.
|
||||
patches = [
|
||||
./disable-rpath.patch
|
||||
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
# TODO: make unconditional and rebuild the world
|
||||
# TODO: send upstream
|
||||
./native-clang-tblgen.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake python3 ];
|
||||
|
||||
# ncurses is required here to avoid a reference to bootstrap-tools, which is
|
||||
# not allowed for the stdenv.
|
||||
buildInputs = [ ncurses ];
|
||||
|
||||
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ];
|
||||
cmakeFlags = [ "-DLLVM_INCLUDE_TESTS=OFF" ]
|
||||
++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) [
|
||||
"-DCMAKE_CROSSCOMPILING=True"
|
||||
# This package could probably have a llvm_6 llvm-tblgen and clang-tblgen
|
||||
# provided to reduce some building. This package seems intended to
|
||||
# include all of its dependencies, including enough of LLVM to build the
|
||||
# required tablegens.
|
||||
(
|
||||
let
|
||||
nativeCC = pkgsBuildBuild.stdenv.cc;
|
||||
nativeBintools = nativeCC.bintools.bintools;
|
||||
nativeToolchainFlags = [
|
||||
"-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
|
||||
"-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
|
||||
"-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
|
||||
"-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
|
||||
"-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
|
||||
];
|
||||
in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}"
|
||||
)
|
||||
];
|
||||
|
||||
# fixes: fatal error: 'clang/Basic/Diagnostic.h' file not found
|
||||
# adapted from upstream
|
||||
@@ -35,10 +65,6 @@ stdenv.mkDerivation rec {
|
||||
|
||||
installTargets = [ "install-libtapi" "install-tapi-headers" "install-tapi" ];
|
||||
|
||||
postInstall = lib.optionalString stdenv.isDarwin ''
|
||||
install_name_tool -id $out/lib/libtapi.dylib $out/lib/libtapi.dylib
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size";
|
||||
homepage = "https://github.com/tpoechtrager/apple-libtapi";
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/src/llvm/cmake/modules/AddLLVM.cmake b/src/llvm/cmake/modules/AddLLVM.cmake
|
||||
index a53016eb0..b65e608a4 100644
|
||||
--- a/cmake/modules/AddLLVM.cmake
|
||||
+++ b/cmake/modules/AddLLVM.cmake
|
||||
@@ -1683,8 +1683,7 @@ function(llvm_setup_rpath name)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
- set(_install_name_dir INSTALL_NAME_DIR "@rpath")
|
||||
- set(_install_rpath "@loader_path/../lib" ${extra_libdir})
|
||||
+ set(_install_name_dir)
|
||||
elseif(UNIX)
|
||||
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
|
||||
@@ -0,0 +1,21 @@
|
||||
diffprojects/libtapi/CMakeLists.txt b/src/llvm/projects/libtapi/CMakeLists.txt
|
||||
index 8ee6d8138..8277be147 100644
|
||||
--- a/projects/libtapi/CMakeLists.txt
|
||||
+++ b/projects/libtapi/CMakeLists.txt
|
||||
@@ -193,7 +193,15 @@ if (NOT DEFINED CLANG_VERSION)
|
||||
set(CLANG_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
|
||||
endif ()
|
||||
if (NOT DEFINED CLANG_TABLEGEN_EXE)
|
||||
- set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen")
|
||||
+ if(LLVM_USE_HOST_TOOLS)
|
||||
+ if (NOT CMAKE_CONFIGURATION_TYPES)
|
||||
+ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/bin/clang-tblgen")
|
||||
+ else()
|
||||
+ set(CLANG_TABLEGEN_EXE "${LLVM_NATIVE_BUILD}/Release/bin/clang-tblgen")
|
||||
+ endif()
|
||||
+ else()
|
||||
+ set(CLANG_TABLEGEN_EXE "${LLVM_TOOLS_BINARY_DIR}/clang-tblgen")
|
||||
+ endif ()
|
||||
endif ()
|
||||
|
||||
# Include must go first.
|
||||
+2
-2
@@ -7,11 +7,11 @@ stdenv.mkDerivation {
|
||||
buildInputs = [ libyaml ];
|
||||
|
||||
buildPhase = ''
|
||||
$CC -lyaml -o $name main.c
|
||||
$CC -lyaml -o print-reexports main.c
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mv $name $out/bin
|
||||
mv print-reexports $out/bin
|
||||
'';
|
||||
}
|
||||
+73
-8
@@ -21,6 +21,10 @@
|
||||
#include <sys/errno.h>
|
||||
#include <yaml.h>
|
||||
|
||||
#define LOG(str, ...) fprintf(stderr, "%s", str)
|
||||
|
||||
#define LOGF(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
static yaml_node_t *get_mapping_entry(yaml_document_t *document, yaml_node_t *mapping, const char *name) {
|
||||
if (!mapping) {
|
||||
fprintf(stderr, "get_mapping_entry: mapping is null\n");
|
||||
@@ -35,12 +39,12 @@ static yaml_node_t *get_mapping_entry(yaml_document_t *document, yaml_node_t *ma
|
||||
yaml_node_t *key = yaml_document_get_node(document, pair->key);
|
||||
|
||||
if (!key) {
|
||||
fprintf(stderr, "get_mapping_entry: key (%i) is null\n", pair->key);
|
||||
LOGF("key (%d) is null\n", pair->key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (key->type != YAML_SCALAR_NODE) {
|
||||
fprintf(stderr, "get_mapping_entry: key is not a scalar\n");
|
||||
LOG("get_mapping_entry: key is not a scalar\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -54,18 +58,17 @@ static yaml_node_t *get_mapping_entry(yaml_document_t *document, yaml_node_t *ma
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int emit_reexports(yaml_document_t *document) {
|
||||
static int emit_reexports_v2(yaml_document_t *document) {
|
||||
yaml_node_t *root = yaml_document_get_root_node(document);
|
||||
|
||||
yaml_node_t *exports = get_mapping_entry(document, root, "exports");
|
||||
|
||||
if (!exports) {
|
||||
fprintf(stderr, "emit_reexports: no exports found\n");
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (exports->type != YAML_SEQUENCE_NODE) {
|
||||
fprintf(stderr, "emit_reexports, value is not a sequence\n");
|
||||
LOG("value is not a sequence\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -82,6 +85,11 @@ static int emit_reexports(yaml_document_t *document) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (reexports->type != YAML_SEQUENCE_NODE) {
|
||||
LOG("re-exports is not a sequence\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (
|
||||
yaml_node_item_t *reexport = reexports->data.sequence.items.start;
|
||||
reexport < reexports->data.sequence.items.top;
|
||||
@@ -90,7 +98,58 @@ static int emit_reexports(yaml_document_t *document) {
|
||||
yaml_node_t *val = yaml_document_get_node(document, *reexport);
|
||||
|
||||
if (val->type != YAML_SCALAR_NODE) {
|
||||
fprintf(stderr, "item is not a scalar\n");
|
||||
LOG("item is not a scalar\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fwrite(val->data.scalar.value, val->data.scalar.length, 1, stdout);
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int emit_reexports_v4(yaml_document_t *document) {
|
||||
yaml_node_t *root = yaml_document_get_root_node(document);
|
||||
yaml_node_t *reexports = get_mapping_entry(document, root, "reexported-libraries");
|
||||
|
||||
if (!reexports) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (reexports->type != YAML_SEQUENCE_NODE) {
|
||||
LOG("value is not a sequence\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (
|
||||
yaml_node_item_t *entry = reexports->data.sequence.items.start;
|
||||
entry < reexports->data.sequence.items.top;
|
||||
++entry
|
||||
) {
|
||||
yaml_node_t *entry_node = yaml_document_get_node(document, *entry);
|
||||
|
||||
yaml_node_t *libs = get_mapping_entry(document, entry_node, "libraries");
|
||||
|
||||
if (!libs) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (libs->type != YAML_SEQUENCE_NODE) {
|
||||
LOG("libraries is not a sequence\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (
|
||||
yaml_node_item_t *lib = libs->data.sequence.items.start;
|
||||
lib < libs->data.sequence.items.top;
|
||||
++lib
|
||||
) {
|
||||
yaml_node_t *val = yaml_document_get_node(document, *lib);
|
||||
|
||||
if (val->type != YAML_SCALAR_NODE) {
|
||||
LOG("item is not a scalar\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -135,7 +194,13 @@ int main(int argc, char **argv) {
|
||||
goto err_yaml;
|
||||
}
|
||||
|
||||
emit_reexports(&yaml_document);
|
||||
// Try both, only fail if one reports an error. A lack of re-exports is not
|
||||
// considered an error.
|
||||
int ok = 1;
|
||||
ok = ok && emit_reexports_v2(&yaml_document);
|
||||
ok = ok && emit_reexports_v4(&yaml_document);
|
||||
|
||||
result = !ok;
|
||||
|
||||
err_yaml:
|
||||
yaml_parser_delete(&yaml_parser);
|
||||
@@ -0,0 +1,19 @@
|
||||
fixupOutputHooks+=('checkTbdReexports')
|
||||
|
||||
checkTbdReexports() {
|
||||
local dir="$1"
|
||||
|
||||
while IFS= read -r -d $'\0' tbd; do
|
||||
echo "checkTbdRexports: checking re-exports in $tbd"
|
||||
while read -r target; do
|
||||
local expected="${target%.dylib}.tbd"
|
||||
if ! [ -e "$expected" ]; then
|
||||
echo -e "Re-export missing:\n\t'$target'\n\t(expected '$expected')"
|
||||
echo -e "While processing\n\t'$tbd'"
|
||||
exit 1
|
||||
else
|
||||
echo "Re-exported target '$target' ok"
|
||||
fi
|
||||
done < <(print-reexports "$tbd")
|
||||
done < <(find $prefix -type f -name '*.tbd' -print0)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{ stdenv, fetchFromGitHub, cmake, pkg-config, libyaml }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "rewrite-tbd";
|
||||
version = "20201114";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "thefloweringash";
|
||||
repo = "rewrite-tbd";
|
||||
rev = "988f29c6ccbca9b883966225263d8d78676da6a3";
|
||||
sha256 = "08sk91zwj6n9x2ymwid2k7y0rwv5b7p6h1b25ipx1dv0i43p6v1a";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake pkg-config ];
|
||||
buildInputs = [ libyaml ];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fixupOutputHooks+=('signDarwinBinariesIn $prefix')
|
||||
|
||||
# Uses signingUtils, see definition of autoSignDarwinBinariesHook in
|
||||
# darwin-packages.nix
|
||||
|
||||
signDarwinBinariesIn() {
|
||||
local dir="$1"
|
||||
|
||||
if [ ! -d "$dir" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${darwinDontCodeSign:-}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
while IFS= read -r -d $'\0' f; do
|
||||
signIfRequired "$f"
|
||||
done < <(find "$dir" -type f -print0)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{ stdenvNoCC
|
||||
, sigtool
|
||||
, cctools
|
||||
}:
|
||||
|
||||
let
|
||||
stdenv = stdenvNoCC;
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "signing-utils";
|
||||
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
substituteAll ${./utils.sh} $out
|
||||
'';
|
||||
|
||||
# Substituted variables
|
||||
inherit sigtool;
|
||||
codesignAllocate = "${cctools}/bin/${cctools.targetPrefix}codesign_allocate";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
# Work around for some odd behaviour where we can't codesign a file
|
||||
# in-place if it has been called before. This happens for example if
|
||||
# you try to fix-up a binary using strip/install_name_tool, after it
|
||||
# had been used previous. The solution is to copy the binary (with
|
||||
# the corrupted signature from strip/install_name_tool) to some
|
||||
# location, sign it there and move it back into place.
|
||||
#
|
||||
# This does not appear to happen with the codesign tool that ships
|
||||
# with recent macOS BigSur installs on M1 arm64 machines. However it
|
||||
# had also been happening with the tools that shipped with the DTKs.
|
||||
sign() {
|
||||
local tmpdir
|
||||
tmpdir=$(mktemp -d)
|
||||
|
||||
# $1 is the file
|
||||
|
||||
cp "$1" "$tmpdir"
|
||||
CODESIGN_ALLOCATE=@codesignAllocate@ \
|
||||
@sigtool@/bin/codesign -f -s - "$tmpdir/$(basename "$1")"
|
||||
mv "$tmpdir/$(basename "$1")" "$1"
|
||||
rmdir "$tmpdir"
|
||||
}
|
||||
|
||||
checkRequiresSignature() {
|
||||
local file=$1
|
||||
local rc=0
|
||||
|
||||
@sigtool@/bin/sigtool --file "$file" check-requires-signature || rc=$?
|
||||
|
||||
if [ "$rc" -eq 0 ] || [ "$rc" -eq 1 ]; then
|
||||
return "$rc"
|
||||
fi
|
||||
|
||||
echo "Unexpected exit status from sigtool: $rc"
|
||||
exit 1
|
||||
}
|
||||
|
||||
signIfRequired() {
|
||||
local file=$1
|
||||
if checkRequiresSignature "$file"; then
|
||||
sign "$file"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{ lib, stdenv, fetchFromGitHub, pkg-config, cmake, makeWrapper, openssl }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "sigtool";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "thefloweringash";
|
||||
repo = "sigtool";
|
||||
rev = "4a3719b42dc91c3f513df94048851cc98e7c7fcf";
|
||||
sha256 = "04ra1cx7k1sdbkj5yrvl0s3l333vpir8rnm8k1dh2zy1w0a6hpqa";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkg-config makeWrapper ];
|
||||
buildInputs = [ openssl ];
|
||||
|
||||
installFlags = [ "PREFIX=$(out)" ];
|
||||
|
||||
# Upstream (me) asserts the driver script is optional.
|
||||
postInstall = ''
|
||||
substitute $NIX_BUILD_TOP/$sourceRoot/codesign.sh $out/bin/codesign \
|
||||
--replace sigtool "$out/bin/sigtool"
|
||||
chmod a+x $out/bin/codesign
|
||||
'';
|
||||
}
|
||||
@@ -41,6 +41,7 @@ rec {
|
||||
mv cc-cflags.tmp $out/nix-support/cc-cflags
|
||||
echo "-target ${targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-isystem ${sdk}/usr/include${lib.optionalString (lib.versionAtLeast "10" sdk.version) " -isystem ${sdk}/usr/include/c++/4.2.1/ -stdlib=libstdc++"}" >> $out/nix-support/cc-cflags
|
||||
${lib.optionalString (lib.versionAtLeast sdk.version "14") "echo -isystem ${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 >> $out/nix-support/cc-cflags"}
|
||||
'';
|
||||
}) // {
|
||||
inherit sdk;
|
||||
|
||||
Reference in New Issue
Block a user