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

swift: use stdenv libc++ on Darwin #245641

Merged
merged 1 commit into from
Aug 5, 2023
Merged

Conversation

reckenrode
Copy link
Contributor

Description of changes

Swift uses libc++ 15, but it should really be using the same libc++ from the stdenv. While not strictly needed currently, Swift 5.9 will support C++ interop. If Swift is not using the stdenv C++, any C++ library used with interop would need to be rebuilt against the Swift libc++.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@reckenrode
Copy link
Contributor Author

Result of nixpkgs-review pr 245641 run on aarch64-darwin 1

6 packages marked as broken and skipped:
  • jellyfin-mpv-shim
  • jellyfin-mpv-shim.dist
  • mpc-qt
  • sublime-music
  • sublime-music.dist
  • wtwitch
9 packages failed to build:
  • anki
  • anki.dist
  • anki.doc
  • anki.man
  • hydrus
  • hydrus.doc
  • mnemosyne
  • mnemosyne.dist
  • swiftPackages.swift-unwrapped
36 packages built:
  • ani-cli
  • cplay-ng
  • cplay-ng.dist
  • curseradio
  • curseradio.dist
  • darwin.openwith
  • dmlive
  • dra-cla
  • klipperscreen
  • mpv-unwrapped
  • mpv-unwrapped.dev
  • mpv-unwrapped.man
  • python310Packages.mpv
  • python310Packages.mpv.dist
  • python311Packages.mpv
  • python311Packages.mpv.dist
  • somafm-cli
  • sourcekit-lsp (swiftPackages.sourcekit-lsp)
  • subtitleedit
  • swift (swiftPackages.swift)
  • swift-format (swiftPackages.swift-format)
  • swift.man (swiftPackages.swift.man)
  • swiftPackages.XCTest
  • swiftPackages.clang
  • swiftPackages.stdenv
  • swiftPackages.swift-docc
  • swiftPackages.swift-driver
  • swiftPackages.swift-unwrapped.dev
  • swiftPackages.swift-unwrapped.doc
  • swiftPackages.swift-unwrapped.lib
  • swiftPackages.swift-unwrapped.man
  • swiftPackages.swiftNoSwiftDriver
  • swiftPackages.swiftNoSwiftDriver.man
  • swiftpm (swiftPackages.swiftpm)
  • swiftPackages.xcbuild (swiftPackages.xcodebuild)
  • ytfzf

@reckenrode
Copy link
Contributor Author

Result of nixpkgs-review pr 245641 run on x86_64-darwin 1

3 packages marked as broken and skipped:
  • darwin.openwith
  • mnemosyne
  • mnemosyne.dist
4 packages failed to build:
  • anki
  • anki.dist
  • anki.doc
  • anki.man
18 packages built:
  • sourcekit-lsp (swiftPackages.sourcekit-lsp)
  • swift (swiftPackages.swift)
  • swift-format (swiftPackages.swift-format)
  • swift.man (swiftPackages.swift.man)
  • swiftPackages.XCTest
  • swiftPackages.clang
  • swiftPackages.stdenv
  • swiftPackages.swift-docc
  • swiftPackages.swift-driver
  • swiftPackages.swift-unwrapped
  • swiftPackages.swift-unwrapped.dev
  • swiftPackages.swift-unwrapped.doc
  • swiftPackages.swift-unwrapped.lib
  • swiftPackages.swift-unwrapped.man
  • swiftPackages.swiftNoSwiftDriver
  • swiftPackages.swiftNoSwiftDriver.man
  • swiftpm (swiftPackages.swiftpm)
  • swiftPackages.xcbuild (swiftPackages.xcodebuild)

@reckenrode
Copy link
Contributor Author

  • Anki is failing to build because it depends on qtwebengine6, which is broken right now but will be fixed by darwin-stdenv: revert NIX_CC_NO_RESPONSE_FILE logic #245640.
  • Hydrus build seems to be non-deterministic. It sometimes succeeds and sometimes fails for me. 🤷🏻‍♂️
  • Mnemosyne depends on Anki and fails due to the Anki failure.
  • I don’t know why swiftPackages.swift-unwrapped is showing as failed on aarch64-darwin but the individual outputs show as succeeded.

Comment on lines 32 to 46
llvmPackages_15.clang.override rec {
libc = apple_sdk.Libsystem;
bintools = pkgs.bintools.override { inherit libc; };
# Ensure that Swift’s internal clang is using the same libc++ and libc++abi
# used by the default Darwin stdenv.
libcxx = pkgs.llvmPackages.libcxx;
extraPackages = [
pkgs.llvmPackages.libcxxabi
(pkgs.llvmPackages_15.compiler-rt.override {
inherit (pkgs.llvmPackages) libcxxabi;
})
];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that llvmPackages_15 is repeated twice, can we turn this into a function, something like:

if pkgs.stdenv.isDarwin then
  # Comments here
  let makeSwiftClang = stdenvLLVM: targetLLVM:
      ...
  in
  makeSwiftClang pkgs.llvmPackages llvmPackages_15

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How’s the current push look like with the alias (swiftLlvmPackages)? I can still rework it to use a function, but it’s only going to be used right away, so it seems like it would add a limited amount of clarity.

pkgs/development/compilers/swift/default.nix Outdated Show resolved Hide resolved
pkgs/development/compilers/swift/default.nix Outdated Show resolved Hide resolved
@reckenrode reckenrode force-pushed the swift-libc++ branch 2 times, most recently from 3c58bda to 3595e01 Compare August 5, 2023 00:20
Copy link
Contributor

@tjni tjni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

pkgs/development/compilers/swift/default.nix Outdated Show resolved Hide resolved
Swift uses libc++ 15, but it should really be using the same libc++ from
the stdenv. While not strictly needed currently, Swift 5.9 will support
C++ interop. If Swift is not using the stdenv C++, any C++ library used
with interop would need to be rebuilt against the Swift libc++.
@wegank wegank merged commit c839b1f into NixOS:master Aug 5, 2023
8 checks passed
@reckenrode reckenrode mentioned this pull request Aug 15, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants