17 Commits

Author SHA1 Message Date
David McFarland 0650c7b316 swift.swift: fix linux build 2026-02-10 23:26:07 -04:00
Sam 5b123afb9a swiftPackages.swift: prefix unguarded-availability flag with -Xcc
The Swift wrapper uses a hook directly from cc-wrapper to set the
`-target` flag appropriately. This works because Clang and Swift use the
same syntax for `-target`, but there was never a guarantee that this
compatibility would be true for every option set in the hook. Indeed,
commit 369cc5c66b (PR #445119) made
availability warnings into errors by setting the
`-Werror=unguarded-availability` flag in this hook, which Swift doesn't
accept at the top level. This caused all invocations of Swift to fail
with the error `unknown argument: '-Werror=unguarded-availability'` -
including the bootstrap Swift, which meant that `swiftPackages.swift`
would fail.

This commit adds all `-Werror` flags to the list of flags that need to
be prefixed with `-Xcc`. I could have just dropped the flag, since Swift
already makes this an error, but you can have C/C++ targets in Swift
packages and we'd want to pass this flag on to them. (I'm not sure
whether the clang used for those targets is already wrapped, but if it
is there is no harm done.)
2025-11-09 00:00:27 -07:00
Sam b2e971ac41 swiftPackages.swift: check for modern CXX interop flag in wrapper
This check is what determines whether the appropriate CFLAGS are set so
that Swift can find the C++ headers it needs for interop
2025-10-10 19:51:06 -07: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 0ec026a14a swift.tests.cxx-interop-test: init
I used this to verify the libc++ changes.
2025-09-02 04:09:46 +01:00
Emily a9ae918dcc swift: source darwin-sdk-setup.bash (#360207) 2024-12-28 22:13:36 +00:00
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
Randy Eckenrode c578c48b7f swift: source darwin-sdk-setup.bash
Fixes builds using xcbuild that redefine SDKROOT in the xcbuild wrapper.
SDKROOT will be set using the same logic that other wrappers use.
2024-11-29 14:46:00 -05:00
Randy Eckenrode 7d5f19a354 swift-wrapper: set up Darwin SDK paths for Swift 2024-10-10 01:07:16 -04:00
Alyssa Ross 6f756b4065 clang: don't set machine flags for overridden target
We already did this for -march in 12b0e8ac74 ("clang: don't set
-march for overridden target"), but it should have been done for all
machine flags, for the same reason.

Example bug this fixes:

	nix-shell -E '
	  with import ./. {
	    crossSystem = {
	      system = "powerpc64le-linux";
	      gcc.cpu = "power10";
	    };
	  };
	  clangStdenv.mkDerivation { name = "test"; }
	' --run '$CC -target wasm32-unknown-unknown -c /dev/null'

Which previously failed with:

      clang: error: unsupported option '-mcpu=' for target 'wasm32-unknown-unknown'
2024-06-15 08:02:29 +02:00
Sam 9fd2efac08 swiftc: pass -Xcc before -march 2024-04-02 21:41:45 -07:00
Stéphan Kochen f85d12198f swift: 5.7.3 -> 5.8 2023-04-30 15:03:20 +02:00
Felix Buehler cdb39a86e0 treewide: use optionalString 2023-02-13 21:52:34 +01:00
Stéphan Kochen 72ba293675 swift: remove internal wrapperParams arg 2022-11-21 11:15:01 +01:00
Stéphan Kochen dcb0eaf66d swift-driver: init at 5.7 2022-10-10 21:26:50 +02:00
Stéphan Kochen 8ed924c07a swift: compiler only build & darwin support 2022-10-10 21:26:47 +02:00