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

darwin (Big Sur): tbd based stdenv #98541

Merged
merged 18 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7f1a82d
stdenv/darwin: bump bootstrap tools
LnL7 Oct 15, 2020
86ee107
darwin/stdenv: assemble full clang toolchain
thefloweringash Jul 31, 2020
fece3eb
darwin/stdenv: refactoring
thefloweringash Jul 31, 2020
ddd1720
compiler-rt: prevent platform sniffing on Darwin
thefloweringash Jul 29, 2020
8946ff8
darwin/darwin-stubs: init
thefloweringash Sep 10, 2020
fd33052
darwin/print-reexports: nixpkgs-specific utility to inspect .tbd files
thefloweringash Sep 18, 2020
b176ad9
darwin/Libsystem: use darwin-stubs
thefloweringash Sep 18, 2020
03988a5
darwin/Security: use darwin-stubs
thefloweringash Sep 18, 2020
193c912
darwin/IOKit: use darwin-stubs
thefloweringash Sep 18, 2020
8e6d830
darwin/objc4: use darwin-stubs
thefloweringash Sep 18, 2020
3456ef6
darwin/apple-sdk: use darwin stubs
thefloweringash Sep 18, 2020
f6c54e8
qt512.qtbase: patch framework detection to support tbd frameworks
thefloweringash Sep 16, 2020
1f52024
qt514.qtbase: patch framework detection to support tbd frameworks
thefloweringash Nov 12, 2020
16075a7
qt515.qtbase: patch framework detection to support tbd frameworks
thefloweringash Nov 12, 2020
47c770e
darwin/make-bootstrap-tools: remove references to old libSystem
thefloweringash Sep 9, 2020
70f3863
trash-cli: remove reference to libSystem.dylib proxy on darwin
thefloweringash Nov 10, 2020
7e49fb6
darwin/apple-sdk: explain why Kernel.framework has no .tbd file
thefloweringash Nov 12, 2020
f2b81a0
darwin/print-reexports: add an overview comment
thefloweringash Nov 12, 2020
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
5 changes: 5 additions & 0 deletions pkgs/development/compilers/llvm/10/compiler-rt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ stdenv.mkDerivation rec {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.parsed.cpu.name}"
];

outputs = [ "out" "dev" ];
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/compilers/llvm/5/compiler-rt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ stdenv.mkDerivation {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.parsed.cpu.name}"
];

outputs = [ "out" "dev" ];
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/compilers/llvm/6/compiler-rt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ stdenv.mkDerivation {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.parsed.cpu.name}"
];

outputs = [ "out" "dev" ];
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/compilers/llvm/7/compiler-rt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ stdenv.mkDerivation {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.parsed.cpu.name}"
];

outputs = [ "out" "dev" ];
Expand Down
5 changes: 4 additions & 1 deletion pkgs/development/compilers/llvm/7/libc++abi.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ stdenv, cmake, fetch, libcxx, llvm, version
, standalone ? false
# on musl the shared objects don't build
, enableShared ? ! stdenv.hostPlatform.isMusl }:

Expand All @@ -20,7 +21,9 @@ stdenv.mkDerivation {
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
'';

cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";
cmakeFlags =
stdenv.lib.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++
stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF";

installPhase = if stdenv.isDarwin
then ''
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/compilers/llvm/8/compiler-rt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ stdenv.mkDerivation {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.parsed.cpu.name}"
];

outputs = [ "out" "dev" ];
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/compilers/llvm/9/compiler-rt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ stdenv.mkDerivation rec {
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
] ++ stdenv.lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.parsed.cpu.name}"
];

outputs = [ "out" "dev" ];
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/libraries/qt-5/5.12/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ let
./qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
./qtbase.patch.d/0002-qtbase-mac.patch
./qtbase.patch.d/0013-define-kiosurfacesuccess.patch

# Patch framework detection to support X.framework/X.tbd,
# extending the current support for X.framework/X.
./qtbase.patch.d/0015-qtbase-tbd-frameworks.patch
]
++ [
./qtbase.patch.d/0003-qtbase-mkspecs.patch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
index 84dbbfebd4..615bfed124 100644
--- a/src/gui/Qt5GuiConfigExtras.cmake.in
+++ b/src/gui/Qt5GuiConfigExtras.cmake.in
@@ -119,6 +119,10 @@ macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
endif()
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY "${Qt5Gui_${_cmake_lib_name}_LIBRARY}/${_lib}.tbd")
+ if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
+ endif()
!!ENDIF
if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY)
# The above find_library call doesn\'t work for finding
4 changes: 4 additions & 0 deletions pkgs/development/libraries/qt-5/5.14/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ let
optionals stdenv.isDarwin [
./qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
./qtbase.patch.d/0002-qtbase-mac.patch

# Patch framework detection to support X.framework/X.tbd,
# extending the current support for X.framework/X.
./qtbase.patch.d/0012-qtbase-tbd-frameworks.patch
]
++ [
./qtbase.patch.d/0003-qtbase-mkspecs.patch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
index 84dbbfebd4..615bfed124 100644
--- a/src/gui/Qt5GuiConfigExtras.cmake.in
+++ b/src/gui/Qt5GuiConfigExtras.cmake.in
@@ -119,6 +119,10 @@ macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
endif()
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY "${Qt5Gui_${_cmake_lib_name}_LIBRARY}/${_lib}.tbd")
+ if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
+ endif()
!!ENDIF
if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY)
# The above find_library call doesn\'t work for finding
4 changes: 4 additions & 0 deletions pkgs/development/libraries/qt-5/5.15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ let
optionals stdenv.isDarwin [
./qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
./qtbase.patch.d/0002-qtbase-mac.patch

# Patch framework detection to support X.framework/X.tbd,
# extending the current support for X.framework/X.
./qtbase.patch.d/0012-qtbase-tbd-frameworks.patch
]
++ [
./qtbase.patch.d/0003-qtbase-mkspecs.patch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
index 84dbbfebd4..615bfed124 100644
--- a/src/gui/Qt5GuiConfigExtras.cmake.in
+++ b/src/gui/Qt5GuiConfigExtras.cmake.in
@@ -119,6 +119,10 @@ macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
endif()
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY "${Qt5Gui_${_cmake_lib_name}_LIBRARY}/${_lib}.tbd")
+ if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
+ endif()
!!ENDIF
if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY)
# The above find_library call doesn\'t work for finding
2 changes: 1 addition & 1 deletion pkgs/os-specific/darwin/apple-sdk/cf-setup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ linkSystemCoreFoundationFramework() {
# gross! many symbols (such as _OBJC_CLASS_$_NSArray) are defined in system CF, but not
# in the opensource release
# if the package needs private headers, we assume they also want to link with system CF
NIX_LDFLAGS+=" /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation"
NIX_LDFLAGS+=" @out@/Library/Frameworks/CoreFoundation.framework/CoreFoundation"
FRidh marked this conversation as resolved.
Show resolved Hide resolved
}

preConfigureHooks+=(linkSystemCoreFoundationFramework)
109 changes: 93 additions & 16 deletions pkgs/os-specific/darwin/apple-sdk/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib }:
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }:

let version = "10.12"; in

Expand Down Expand Up @@ -42,7 +42,12 @@ let
rmdir System

pushd lib
ln -s -L /usr/lib/libcups*.dylib .
cp ${darwin-stubs}/usr/lib/libcups*.tbd .
ln -s libcups.2.tbd libcups.tbd
ln -s libcupscgi.1.tbd libcupscgi.tbd
ln -s libcupsimage.2.tbd libcupsimage.tbd
ln -s libcupsmime.1.tbd libcupsmime.tbd
ln -s libcupsppdc.1.tbd libcupsppdc.tbd
popd
'';

Expand All @@ -53,6 +58,12 @@ let
};
};

mkFrameworkSubs = name: deps:
let
deps' = deps // { "${name}" = placeholder "out"; };
substArgs = lib.concatMap (x: [ "--subst-var-by" x deps'."${x}" ]) (lib.attrNames deps');
in lib.escapeShellArgs substArgs;

framework = name: deps: stdenv.mkDerivation {
name = "apple-framework-${name}";

Expand All @@ -63,11 +74,14 @@ let

disallowedRequisites = [ sdk ];

nativeBuildInputs = [ print-reexports ];

extraTBDFiles = [];

installPhase = ''
linkFramework() {
local path="$1"
local nested_path="$1"
local dest="$out/Library/Frameworks/$path"
if [ "$path" == "JavaNativeFoundation.framework" ]; then
local nested_path="JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework"
fi
Expand All @@ -80,21 +94,29 @@ let
current=A
fi

mkdir -p "$dest"
pushd "$dest" >/dev/null
local dest="$out/Library/Frameworks/$path"

# Keep track of if this is a child or a child rescue as with
# ApplicationServices in the 10.9 SDK
local isChild=0
mkdir -p "$dest/Versions/$current"
pushd "$dest/Versions/$current" >/dev/null

if [ -d "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current/Headers" ]; then
isChild=1
cp -R "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current/Headers" .
elif [ -d "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" ]; then
current="$(readlink "/System/Library/Frameworks/$name.framework/Versions/Current")"
cp -R "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" .
fi
ln -s -L "/System/Library/Frameworks/$nested_path/Versions/$current/$name"

local tbd_source=${darwin-stubs}/System/Library/Frameworks/$nested_path/Versions/$current
if [ "${name}" != "Kernel" ]; then
FRidh marked this conversation as resolved.
Show resolved Hide resolved
# The Kernel.framework has headers but no actual library component.
cp -v $tbd_source/*.tbd .
fi

if [ -d "$tbd_source/Libraries" ]; then
mkdir Libraries
cp -v $tbd_source/Libraries/*.tbd Libraries/
fi

ln -s -L "/System/Library/Frameworks/$nested_path/Versions/$current/Resources"

if [ -f "/System/Library/Frameworks/$nested_path/module.map" ]; then
Expand All @@ -110,17 +132,45 @@ let
linkFramework "$childpath"
done

if [ -d "$dest/Versions/$current" ]; then
mv $dest/Versions/$current/* .
fi
pushd ../.. >/dev/null
ln -s "$current" Versions/Current
ln -s Versions/Current/* .
popd >/dev/null

popd >/dev/null
}

linkFramework "${name}.framework"

# linkFramework is recursive, the rest of the processing is not.

local tbd_source=${darwin-stubs}/System/Library/Frameworks/${name}.framework
for tbd in $extraTBDFiles; do
local tbd_dest_dir=$out/Library/Frameworks/${name}.framework/$(dirname "$tbd")
mkdir -p "$tbd_dest_dir"
cp -v "$tbd_source/$tbd" "$tbd_dest_dir"
done

# Fix and check tbd re-export references
find $out -name '*.tbd' | while read tbd; do
echo "Fixing re-exports in $tbd"
substituteInPlace "$tbd" ${mkFrameworkSubs name deps}

echo "Checking re-exports in $tbd"
print-reexports "$tbd" | while read 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
done
'';

propagatedBuildInputs = deps;
propagatedBuildInputs = builtins.attrValues deps;

# don't use pure CF for dylibs that depend on frameworks
setupHook = ./framework-setup-hook.sh;
Expand All @@ -139,6 +189,17 @@ let
platforms = platforms.darwin;
};
};

tbdOnlyFramework = name: { private ? true }: stdenv.mkDerivation {
name = "apple-framework-${name}";
dontUnpack = true;
installPhase = ''
mkdir -p $out/Library/Frameworks/
cp -r ${darwin-stubs}/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework \
$out/Library/Frameworks
# NOTE there's no re-export checking here, this is probably wrong
'';
};
in rec {
libs = {
xpc = stdenv.mkDerivation {
Expand Down Expand Up @@ -168,7 +229,8 @@ in rec {
installPhase = ''
mkdir -p $out/include $out/lib
ln -s "${lib.getDev sdk}/include/Xplugin.h" $out/include/Xplugin.h
ln -s "/usr/lib/libXplugin.1.dylib" $out/lib/libXplugin.dylib
cp ${darwin-stubs}/usr/lib/libXplugin.1.tbd $out/lib
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
'';
};

Expand All @@ -193,6 +255,10 @@ in rec {
];
});

Carbon = stdenv.lib.overrideDerivation super.Carbon (drv: {
extraTBDFiles = [ "Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering.tbd" ];
});

CoreFoundation = stdenv.lib.overrideDerivation super.CoreFoundation (drv: {
setupHook = ./cf-setup-hook.sh;
});
Expand All @@ -210,6 +276,10 @@ in rec {
setupHook = ./private-frameworks-setup-hook.sh;
});

IMServicePlugIn = stdenv.lib.overrideDerivation super.IMServicePlugIn (drv: {
extraTBDFiles = [ "Versions/A/Frameworks/IMServicePlugInSupport.framework/Versions/A/IMServicePlugInSupport.tbd" ];
});

Security = stdenv.lib.overrideDerivation super.Security (drv: {
setupHook = ./security-setup-hook.sh;
});
Expand All @@ -228,7 +298,14 @@ in rec {
cp ${lib.getDev sdk}/include/simd/*.h $out/include/simd/
'';
});
};

WebKit = stdenv.lib.overrideDerivation super.WebKit (drv: {
extraTBDFiles = [
"Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore.tbd"
"Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy.tbd"
];
});
} // lib.genAttrs [ "ContactsPersistence" "UIFoundation" "GameCenter" ] (x: tbdOnlyFramework x {});

bareFrameworks = stdenv.lib.mapAttrs framework (import ./frameworks.nix {
inherit frameworks libs;
Expand Down
Loading