Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions pkgs/build-support/cc-wrapper/cc-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ fi

if [[ "$isCxx" = 1 ]]; then
if [[ "$cxxInclude" = 1 ]]; then
#
# The motivation for this comment is to explain the reason for appending
# the C++ stdlib to NIX_CFLAGS_COMPILE, which I initially thought should
# change and later realized it shouldn't in:
#
# https://github.com/NixOS/nixpkgs/pull/185569#issuecomment-1234959249
#
# NIX_CFLAGS_COMPILE contains dependencies added using "-isystem", and
# NIX_CXXSTDLIB_COMPILE adds the C++ stdlib using "-isystem". Appending
# NIX_CXXSTDLIB_COMPILE to NIX_CLAGS_COMPILE emulates this part of the
# include lookup order from GCC/Clang:
#
# > 4. Directories specified with -isystem options are scanned in
# > left-to-right order.
# > 5. Standard system directories are scanned.
# > 6. Directories specified with -idirafter options are scanned
# > in left-to-right order.
#
# NIX_CXX_STDLIB_COMPILE acts as the "standard system directories" that
# are otherwise missing from CC in nixpkgs, so should be added last.
#
# This means that the C standard library should never be present inside
# NIX_CFLAGS_COMPILE, because it MUST come after the C++ stdlib. It is
# added automatically by cc-wrapper later using "-idirafter".
#
NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@"
fi
if [[ "$cxxLibrary" = 1 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ in rec {
bareFrameworks = (
lib.mapAttrs framework (import ./frameworks.nix {
inherit frameworks libs;
inherit (pkgs.darwin.apple_sdk_11_0) libnetwork Libsystem;
inherit (pkgs.darwin.apple_sdk_11_0) libnetwork;
libobjc = pkgs.darwin.apple_sdk_11_0.objc4;
})
) // (
Expand Down
4 changes: 3 additions & 1 deletion pkgs/os-specific/darwin/apple-sdk-11.0/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ let
libcharset = callPackage ./libcharset.nix {};
libunwind = callPackage ./libunwind.nix {};
libnetwork = callPackage ./libnetwork.nix {};
objc4 = callPackage ./libobjc.nix {};
# Avoid introducing a new objc4 if stdenv already has one, to prevent
# conflicting LLVM modules.
objc4 = if stdenv ? objc4 then stdenv.objc4 else callPackage ./libobjc.nix {};

# questionable aliases
configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;
Expand Down
6 changes: 2 additions & 4 deletions pkgs/os-specific/darwin/apple-sdk-11.0/frameworks.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ frameworks, libs, libobjc, Libsystem, libnetwork }: with frameworks; with libs;
{ frameworks, libs, libobjc, libnetwork }: with frameworks; with libs;
{
AGL = { inherit Carbon OpenGL; };
AVFoundation = { inherit ApplicationServices AVFCapture AVFCore CoreGraphics simd UniformTypeIdentifiers; };
Expand Down Expand Up @@ -89,9 +89,7 @@
IOBluetooth = { inherit CoreBluetooth IOKit; };
IOBluetoothUI = { inherit IOBluetooth; };
IOKit = {};
# `IOSurface` should depend on `Libsystem` (in place of `xpc`) but this currently causes build
# issues due to incompatibility issues between `Libsystem` and `libcxx`.
IOSurface = { inherit IOKit xpc; };
IOSurface = { inherit IOKit; };
IOUSBHost = {};
IdentityLookup = {};
ImageCaptureCore = {};
Expand Down
5 changes: 5 additions & 0 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ rec {
libc = pkgs.darwin.Libsystem;
shellPackage = pkgs.bash;
inherit bootstrapTools;
} // lib.optionalAttrs useAppleSDKLibs {
# This objc4 will be propagated to all builds using the final stdenv,
# and we shouldn't mix different builds, because they would be
# conflicting LLVM modules. Export it here so we can grab it later.
inherit (pkgs.darwin) objc4;
};

allowedRequisites = (with pkgs; [
Expand Down