Commit Graph

69 Commits

Author SHA1 Message Date
Ihar Hrachyshka
58a38b9adb swift: strip -mtls-dialect=gnu2 from clang wrapper (#542332) 2026-08-14 03:56:48 +00:00
JD Flamm
0c841ee8da swift: strip -mtls-dialect=gnu2 from clang wrapper
Guard the substituteInPlace that strips -mtls-dialect=gnu2 with
lib.optionalString so it only runs when the flag could actually
be present:

  targetPlatform.isLinux && targetPlatform.isx86
  && lib.versionAtLeast (lib.getVersion clang) "19.1"

This matches the condition the cc-wrapper uses when adding the
flag, preventing breakage on Darwin and aarch64-linux where the
option does not exist in the wrapper scripts.

Assisted-by: OpenClaw (friendli/zai-org/GLM-5.2)
2026-08-13 09:08:56 -06:00
liberodark
7a39ad3c85 swift: fix eval on unsupported systems 2026-08-10 16:50:57 +02:00
Emily
002e6194af Revert "swiftPackages.swift-unwrapped: fix darwin build"
The ld64 issue has been fixed.

This reverts commit 401b87c97d.
2026-07-15 03:26:25 +01:00
sempiternal-aurora
401b87c97d swiftPackages.swift-unwrapped: fix darwin build 2026-07-02 17:43:33 +10:00
David McFarland
0650c7b316 swift.swift: fix linux build 2026-02-10 23:26:07 -04:00
David McFarland
845d7f8f0f swift: fix darwin build
Fixes: #483584
2026-01-30 09:48:40 -04:00
Sam
89f7581b9e swiftPackages.swift: ignore unguarded-availability error
I couldn't figure out how to get CMake to set the correct target, as it
insisted on using OS X 10.9 no matter what I set.
2025-11-08 23:38:55 -07:00
Sam
e3f5990dd5 swiftPackages.swift: fix patchPhase indentation 2025-10-11 14:47:33 -07:00
Sam
f3ea847829 swiftPackages.swift{,-corelibs-libdispatch}: fix build with modern clang
We apply this patch to the copy of libdispatch that's copied into Swift
and to the standalone build.
2025-10-11 14:44:17 -07:00
Sam
60a9738efa swiftPackages.swift: drop SysRoot replacements that fail to apply
These replacements didn't apply cleanly to Swift 5.8 anyway, we just
didn't notice. They don't appear to cause any problems and regardless,
the goal is "no more broken than before"
2025-10-11 14:44:17 -07:00
Sam
8e4a990997 swiftPackages.*: swap from replace to replace-fail 2025-10-11 14:44:17 -07:00
Sam
470ee5bfaf swiftPackages.swift: enable remaining compiler features
There are remaining features that are not enabled, but they depend on a
host Swift with which to compile.
2025-10-11 14:44:17 -07:00
Sam
12231abbaf swiftPackages.swift: fix patches that no longer apply cleanly 2025-10-11 14:44:11 -07:00
Sam
a156f5fda3 swiftPackages.swift: patch CMake to import missing module 2025-10-10 20:10:52 -07:00
Sam
374682d81a swiftPackages.swift: drop upstreamed patches 2025-10-10 20:10:30 -07:00
Sam
8aff8a38bc swiftPackages.swift: clang 15 -> 16 2025-10-10 19:57:21 -07:00
Sam
11a5bac33b swiftPackages.*: bump SDK to 14 2025-10-10 19:51:06 -07:00
Emily
c9f171a0bb cmake: drop fixCmakeFiles hook
This regularly broke things – as can be seen from the number
of packages that were opting out of it – while providing only a
dubious and partial benefit to purity that other build systems did
not “enjoy”.

It has become associated with Darwin, but was actually introduced
in 2007 as part of 67d41efde1,
a work‐in‐progress commit for KDE 4 that introduced the CMake
setup hook. It has haunted us ever since, and will presumably become
even better at doing so now that it is a dead ghost.

Of course, it is possible and even likely that more impure paths will
leak into Darwin builds from third‐party CMake modules included
in packages. However, considering it already disregarded many of the
most common macOS system paths, it will be better overall to address
these in a targeted manner than dealing with the effects of this
brute‐force hook. In the long run, a good sandbox is going to be
the solution for reliable build reproducibility on the platform.
2025-09-19 18:34:06 +01:00
Emily
f7a0510047 swift: don’t build LLVM tools
These aren’t required by the build, and fail to compile with the
LLVM 21 / Darwin system libc++ changes.
2025-09-15 22:46:21 +01:00
Emily
2153141b51 swiftPackages.*: build with the default LLVM version 2025-09-02 04:14:28 +01:00
Emily
37cad5dfd5 swiftPackages.swift{,-unwrapped}: get libc++ headers from Swift’s LLVM
libc++ only supports a limited range of Clang versions, so this was
relying on the LLVM version corresponding to the one used in Swift’s
fork. Since Swift builds its own LLVM 15 anyway, we can simply install
the required libc++ headers along with it.
2025-09-02 04:14:28 +01:00
Emily
809f7d037c swiftPackages.swift{,-unwrapped,-driver}: ignore $NIX_CC
Swift needs Clang to link with. The linker patch breaks linking
when using Swift with a GCC‐based standard environment.

Similarly, the internal Clang headers in the resource directory are
coupled to the corresponding version of Clang. The resource root patch
caused Swift’s Clang to use the resource directory from the version
of Clang used in the build environment, which is only compatible if
the versions match.

Instead, hard‐code the Clang path in the patches and wrappers.
2025-09-02 04:09:46 +01:00
Emily
e0d9c9386f swiftPackages.swift-unwrapped: backport patches for modern LLVM 2025-09-02 04:09:46 +01:00
Emily
810bed0854 swiftPackages.swift-unwrapped: vendor Clang patch
The versions of `llvmPackages` that require this patch are going
away soon.
2025-09-02 04:09:46 +01:00
Emily
efde96d9be swiftPackages.swift-unwrapped: drop unnecessary mkdir
Honestly I did this in the middle of trying things and then forgot
about it, and I just don’t feel like bootstrapping the whole thing
again to drop this commit.
2025-09-02 04:09:46 +01:00
Emily
0ec026a14a swift.tests.cxx-interop-test: init
I used this to verify the libc++ changes.
2025-09-02 04:09:46 +01:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Charlotte 🦝 Deleńkec
61593a72a0 swift: throw on unsupported arch 2025-07-11 22:09:01 -05:00
Olivér Falvai
024f70f64d swift: use Python 3.12
https://hydra.nixos.org/build/299109156

Per the release notes: https://docs.python.org/3/whatsnew/3.13.html

> Remove the PyEval_ThreadsInitialized() function, deprecated in Python 3.9. Since Python 3.7, Py_Initialize() always creates the GIL: calling PyEval_InitThreads() does nothing and PyEval_ThreadsInitialized() always returns non-zero.
2025-06-03 18:43:25 +02:00
Michael Hoang
e3895dafc9 swift: use aarch64 instead of arm64 on Linux 2025-05-05 13:06:42 +10:00
Fernando Rodrigues
05580f4b44 treewide: switch instances of lib.teams.*.members to the new meta.teams attribute
Follow-up to #394797.

Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
2025-04-25 22:20:17 -03:00
Emily
61582c7043 lib/systems: use Darwin architecture names for config and uname
`aarch64-apple-darwin` no longer works with LLVM 20.
2025-04-02 21:22:47 +01:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Wolfgang Walther
b19d0f6d3d treewide: replace substituteAll with replaceVars 2025-02-10 22:51:56 +01:00
Emily
e05898e313 swift: remove code for macOS < 11 2025-01-03 17:41:02 +00:00
Artturin
276fe40ff3 swift: Fix eval failure error: expected a string but found null: null
Dunno if this is correct, there's other `hostPlatform.isDarwin`
conditionals which may be wrong.

Leaving the other conditionals to swift maintainers or people who are
interested in swift cross-compilation

```
$ nix repl --file . --system aarch64-darwin
nix-repl> pkgsCross.aarch64-multiplatform.swift
«derivation /nix/store/kqbaqwdfc9g0yvkq4ffrlqspranprlmy-swift-wrapper-aarch64-unknown-linux-gnu-5.8.drv»

nix-repl> pkgsCross.aarch64-multiplatform.buildPackages.swift
error:
       error: expected a string but found null: null
       at /home/artturin/nixgits/my-nixpkgs/.worktree/2/pkgs/development/compilers/swift/compiler/default.nix:586:11:
          585|         #WATCHOS_SIMULATOR
          586|       }.${targetPlatform.darwinPlatform}}
             |           ^
          587|
```
2024-12-12 21:09:56 +02:00
Zhong Jianxin
8dfed1b9a4 swift: Workaround Hydra darwin build problem
Fail to build with ninja 1.12 when NIX_BUILD_CORES is low (Hydra or Github Actions):

```
ld: warning: directory not found for option '-L/nix/store/g9rbp9m6vs1xj4jl6b6vjb6bm8kgr107-SDKs/MacOSX10.15.sdk/usr/lib/swift'
...
ld: warning: Could not find or use auto-linked library 'swiftCompatibility56'
Undefined symbols for architecture arm64:
  "__swift_FORCE_LOAD_$_swiftCompatibility56", referenced from:
      __swift_FORCE_LOAD_$_swiftCompatibility56_$_Optimizer in libswiftCompilerModules-bootstrapping1.a(Optimizer.o)
  ...
```

Can reproduce using `nix --option cores 2 build -f . swiftPackages.swift-unwrapped`.

Until we find out the exact cause, follow [swift upstream][1], pin ninja to version
1.11.1.

[1]: https://github.com/swiftlang/swift/pull/72989
2024-11-08 12:31:09 +08:00
Randy Eckenrode
15331b1c32 swift: use cctools.libtool directly 2024-10-10 01:07:17 -04:00
Randy Eckenrode
7c0c8fd74a swift: build Swift with associated SDK version
Swift releases are associated with particular Darwin SDK versions. They
don’t _have_ to use that version, but it makes sense to use that version
by default. The deployment target is set to the supported Swift minimum
versions. Unlike C and C++, Swift requires you to availability
annotations, so propagating a newer SDK should be safe.
2024-10-10 01:07:17 -04:00
Randy Eckenrode
083d02ffc4 swift: drop libarclite
libarclite is needed to support ARC on very old deployment targets
(10.10 and older). None of these deployment targets are supported
deployment targets in nixpkgs, especially for Swift. This removes the
need to package the command-line tools executables.
2024-10-10 01:07:17 -04:00
Randy Eckenrode
4d080bdf16 swift: add cctools.libtool as a native build input on Darwin 2024-10-10 01:07:17 -04:00
Randy Eckenrode
1ad3206aea swift: clean up ncurses and libedit references 2024-10-10 01:07:17 -04:00
Randy Eckenrode
cf0003e56f swift: fix build with the new Darwin SDK
Swift’s build makes a few assumptions about how the SDK is set up that
are not true anymore with the new SDK. Fix it to find the SDK at
`$SDKROOT` and copy additional stubs it needs to bootstrap.
2024-10-10 01:07:17 -04:00
Artturin
e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
Emily
b4bfb99048 swift: disable zerocallusedregs on all AArch64 2024-09-12 18:39:57 +01:00
Emily
6bbe65701d swift: add LLVM patches for SWIG 4 2024-09-12 18:11:01 +01:00
Tristan Ross
f9c6960071 swift: use clang 12 purity patch
LLVM 14's clang purity patch was removed as it is a duplicate of 12's.
2024-08-09 15:20:56 -07:00
Anderson Torres
7246208bc7 treewide: update meta.maintainers for Swift suite 2024-07-17 23:34:16 -03:00
Anderson Torres
2a9a026118 treewide: add lib.teams.swift.members to Swift suite 2024-07-17 23:34:16 -03:00