249 Commits

Author SHA1 Message Date
Marcin Serwin f3275a1555 bintools-wrapper: use tr for uppercase (#495212) 2026-05-29 06:56:09 +00:00
Aliaksandr ce3c5727ee bintools-wrapper: replace // optionalAttrs with nullable attr names
Same pattern as cc-wrapper: inline mapAttrs+optionalString for Darwin
env vars and replace optionalAttrs for fallback_sdk.
2026-05-18 03:54:27 +03:00
Null Terminator 23c46c60c0 bintools-wrapper: use tr for uppercase
Since bash's parameter expansion for uppercase creates invalid
identifiers in certain locales (like Turkish), it is more ideal
to use `tr` for locale-agnostic string substitution.
2026-03-27 23:28:18 +03:00
Robert Scott d8d07a0e82 bintools-wrapper: disable libcxxhardeningextensive hardening flag by default 2026-02-14 11:40:27 +00:00
Robert Scott 9a6599e26f bintools-wrapper: enable strictflexarrays1 hardening flag by default (#473648) 2026-02-11 22:11:13 +00:00
nixpkgs-ci[bot] 7374f2c496 Merge staging-next into staging 2026-01-24 21:22:17 +00:00
John Ericson 4f217cb085 {cc,bintools}-wrapper: use executable extension when set (#479741) 2026-01-24 18:02:36 +00:00
John Ericson 5351e73e53 bintools-wrapper: Also define RC<suffix> (#482391) 2026-01-22 14:52:37 +00:00
John Ericson f47cd80b29 bintools-wrapper: Also define RC<suffix>
Additionally, if there is a `windres` but no `rc`, `RC<suffix>` is
defined to point to `WINDRES<suffix>`.

My justification is essentially what I wrote in
https://github.com/mesonbuild/meson/pull/15438. Microsoft recommends
`RC`, CMake only supports `RC`, and Meson now supports both. In
addition, CMake and Meson are fine with "reversed" usage like
`RC=windres` and `WINDRES=rc`, so this simple defaulting logic should be
fine.
2026-01-21 14:11:49 -05:00
David McFarland df12a53d55 {cc,bintools}-wrapper: use executable extension when set
On windows platforms we want links to executables to have the .exe
extension, but wrapper scripts shouldn't.
2026-01-13 12:44:10 -04:00
Robert Scott 6980bafab2 bintools-wrapper: enable strictflexarrays1 hardening flag by default 2025-12-23 19:06:56 +00:00
Haonan Chen 67898b4f6e bintools-wrapper: fix rpath handling with symlinks in the store #454199 2025-12-22 11:36:19 +08:00
Robert Scott 2a45fd1039 cc-wrapper: add support for libcxxhardeningfast/extensive hardening flags
as with glibcxxassertions, we don't yet have a nice mechanism
for deferring support decisions to the c++ library in use, so
for now at least enabling this hardening flag will cause
_LIBCPP_HARDENING_MODE to be defined on all compilers
2025-10-08 18:53:17 +01:00
Philip Taron 33816365de {cc-wrapper,bintools-wrapper}: drop pie hardening flag (#442510) 2025-10-07 11:47:04 -07:00
NAHO c8d4dabc43 pkgs: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --type file \
      . \
      pkgs \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2025-10-04 19:02:37 +02:00
Luna Nova 0b3b48fb5f {cc-wrapper,bintools-wrapper}: drop pie hardening flag
We expect compilers to enable PIE by default via --enable-default-pie
or similar.
2025-09-30 09:21:41 -07:00
David McFarland cba263139f cc-wrapper: add w32api paths on cygwin
Co-authored-by: Brian McKenna <brian@brianmckenna.org>
2025-09-27 13:33:43 -03:00
Wolfgang Walther 5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Zhaofeng Li 5953ae56d8 Don't trigger the evaluation of apple-sdk in Linux stdenv
During the Apple SDK revamp of #346043, cc-wrapper and bintools-wrapper
were modified to automatically add a fallback SDK if $DEVELOPER_DIR is
not set [^1]. However, because of the order of the && operands,
apple-sdk is always evaluated even when it's not needed.

Flip the && operands so we only trigger the evaluation when targeting
Darwin.

[^1]: 51755b0c00
2025-05-21 16:53:22 -06: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](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/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
Robert Scott 04791f4a4d bintools-wrapper: enable stackclashprotection by default 2025-01-11 12:31:08 +00:00
Philip Taron 558c04a4dc cc-wrapper, bintools-wrapper: Improve hooks that run before invocation (#366960) 2024-12-23 13:30:33 -08:00
Peter Waller 3fc1a00773 bintools-wrapper: introduce ld-wrapper-hook
The existing post-link-hook is in an unfortunate position since it does
not enable interposing the arguments of the compiler.

This is an RFC to add a hook which enables that.

Signed-off-by: Peter Waller <p@pwaller.net>
2024-12-20 23:53:25 +00:00
Julian Stecklina 822e728ac3 bintools-wrapper: wrap LLVM strip as well 2024-12-18 16:34:07 +01:00
github-actions[bot] af17642ca2 Merge master into staging-next 2024-12-15 22:47:48 +00:00
John Ericson 70c2f444e3 llvmPackages.bintuils: Hack ranlib to ignore -t
Old versions of libtool for OpenBSD insist on adding the `-t` flag to
ranlib, which updates the timestamp. llvm-ranlib does not support `-t`
and as no plans to do so [1], since it makes builds less reproducable.
OpenBSD upstream deals with this by patching ranlib to ignore the `-t`
flag [2].

Instead of writing patches for all LLVM versions or re-running `autoreconf`
on all packages that use libtool, we can wrap ranlib to ignore the flag.

[1]: https://github.com/llvm/llvm-project/issues/57129
[2]: https://github.com/openbsd/src/commit/d00990cc11fce25520b9dde416bb8cf50990e992
2024-11-26 19:37:18 +00:00
Reno Dakota 028069d767 darwin: remove -arch from cc/ld wrapper
`-arch` in the cc/ld wrapper causes problems when specifying different
`--target` options, which would succeed except for the conflicting
`-arch` specifier.

Reverts fc0456bed1 and
b26e0bac8d
2024-11-20 02:14:51 +00:00
Philip Taron 9a18caa5cd bintools-wrapper: fix late‐bound command references (#351531) 2024-10-28 07:05:32 -07:00
Emily 04ba4d1a3b bintools-wrapper: fix late‐bound command references
This ports 985072e2ce to bintools-wrapper.

Co-authored-by: Artturin <Artturin@artturin.com>
Co-authored-by: IlyaNiklyaev <ilya.niklyaev@gmail.com>
2024-10-27 00:32:46 +03:00
Emily e047c69ed4 {bintools-wrapper,cc-wrapper}: allow paths relative to the Darwin SDK
`-L` and `-I` are interpreted relative to the `$SDKROOT` by the
Darwin toolchain, so we have to avoid filtering out such paths in the
purity filter hacks in order to not break e.g. the .NET Core build
system. It’s also just the correct thing to do for the platform.
2024-10-26 15:28:50 +01:00
Emily 9142a07030 {bintools-wrapper,cc-wrapper}: factor out Darwin SDK logic
This reduces code duplication, makes the SDK variables available
earlier in the wrappers, and makes the behaviour between the two
wrappers more consistent.
2024-10-26 01:03:16 +01:00
Emily 4b8e58e813 clang: skip the -nostdlibinc patch on Darwin; ld64: search standard library locations (#349555) 2024-10-25 01:56:20 +01:00
github-actions[bot] ef782655d2 Merge master into staging-next 2024-10-24 18:04:38 +00:00
Emily b75c70282f ld64: search standard library locations
This is basically harmless for the same reason as it is for Clang, and
lets us avoid doing wrapper hacks to fix things like the .NET build.

This reverts commit 4340a5addb.
2024-10-24 18:11:34 +01:00
Artemis Tosini 6da0a87109 bintools-wrapper: Set dynamic-linker on OpenBSD
Now that ld.so is symlinked into the libc derivation,
we can use it as a dynamic linker.
In my testing, OpenBSD does not have any issues with executing from
a symlinked ld.so.
2024-10-24 00:43:24 +00:00
Randy Eckenrode 4340a5addb bintools-wrapper: ensure Swift auto-linked libraries can be found
While the Swift wrapper should take care of this, not everything that
links these libraries goes through the wrapper.
2024-10-15 12:36:07 -04:00
github-actions[bot] 31b11f1926 Merge staging-next into staging 2024-10-15 00:14:36 +00:00
Randy Eckenrode 826edbf719 {bintools,cc}-wrapper: fix static builds on Darwin
Without this change, all Darwin platforms mangle to the same suffix
salt. That is normally not an issue because build = host should mean a
non-cross build, but it causes issues on Darwin with static builds
because `DEVELOPER_DIR_FOR_BUILD` and `DEVELOPER_DIR` will refer to
different SDKs but mangle to the same `DEVELOPER_DIR` with suffix salt.

The fix is to mangle static builds differently from non-static ones on
Darwin, which allows building for a static Darwin target on a
same-architecture Darwin host. This fix is applied only to Dariwn
because the issue does not appear to affect other platforms.
2024-10-10 16:23:00 -04:00
Randy Eckenrode 51755b0c00 {bintools,cc}-wrapper: use a fallback SDK when DEVELOPER_DIR is not set
It is unusual to invoke a wrapped compiler without setting
`DEVELOPER_DIR`, but it can happen when a user adds a compiler to their
installed packages or when a package intentionally invokes the compiler
without an environment (such as the GHC binary packages).
2024-10-10 16:22:59 -04:00
Randy Eckenrode 97d75cb619 {bintools,cc}-wrapper: set up Darwin SDK paths
Some compilers may know to check these paths when `SDKROOT` is set, but
it’s not assumed they do. `SDKROOT` is instead derived from the
`DEVELOPER_DIR`, and `NIX_CFLAGS_COMPILE` is set up with the sysroot and
necessary framework and include search paths.
2024-10-10 16:22:59 -04:00
Emily b2cb2a8d44 {clang-sierraHack{,-stdenv},tests.macOSSierraShared}: drop
This is some thing introduced in 2017 to work around a problem that
no longer seems to exist. Nothing uses it except its own test, which
these days passes even with the standard `clangStdenv`.
2024-10-05 21:29:07 +01:00
John Ericson 5f134ec6cf Clean up cross bootstrapping
For a long time, we've had `crossLibcStdenv`, `*Cross` libc attributes,
and `*bsdCross` pre-libc package sets. This was always bad because
having "cross" things is "not declarative": the naming doesn't reflect
what packages *need* but rather how we *provide* something. This is
ugly, and creates needless friction between cross and native building.

Now, almost all of these `*Cross` attributes are gone: just these are
kept:

- Glibc's and Musl's are kept, because those packages are widely used
  and I didn't want to risk changing the native builds of those at this
  time.

- generic `libcCross`, `theadsCross`, and friends, because these relate
  to the convolulted GCC bootstrap which still needs to be redone.

The BSD and obscure Linux or freestnanding libcs have conversely all
been made to use a new `stdenvNoLibc`, which is like the old
`crossLibcStdenv` except:

1. It usable for native and cross alike

2. It named according to what it *is* ("a standard environment without
   libc but with a C compiler"), rather than some non-compositional
   jargon ("the stdenv used for building libc when cross compiling",
   yuck).

I should have done this change long ago, but I was stymied because of
"infinite recursions". The problem was that in too many cases we are
overriding `stdenv` to *remove* things we don't need, and this risks
cyles since those more minimal stdenvs are used to build things in the
more maximal stdenvs.

The solution is to pass `stage.nix` `stdenvNoCC`, so we can override to
*build up* rather than *tear down*. For now, the full `stdenv` is also
passed, so I don't need to change the native bootstraps, but I can see
this changing as we make things more uniform and clean those up.

(adapted from commit 51f1ecaa59)
(adapted from commit 1743662e55)
2024-09-06 10:26:56 -04:00
github-actions[bot] 62f43c3094 Merge master into staging-next 2024-08-12 18:02:11 +00:00
Alyssa Ross 6f95189f88 wrapBintoolsWith: add s390(x)-linux dynamic linkers
This fixes autoPatchElfHook for these platforms.
2024-08-12 17:52:03 +02:00
github-actions[bot] cf88251824 Merge staging-next into staging 2024-08-05 18:01:40 +00:00
bl0v3 bdb500ace1 bintools-wrapper: add dynamicLinker for s390x 2024-08-05 12:30:26 +02:00
Randy Eckenrode 2c54952847 darwin.apple_sdk.frameworks: remove NIX_COREFOUNDATION_RPATH hook
Darwin no longer supports switching between CoreFoundation implementations as of https://github.com/NixOS/nixpkgs/pull/265102. The setup hook is vestigial and was mostly harmless until https://github.com/NixOS/nixpkgs/pull/329526 was necessitated to fix build failures on staging-next https://github.com/NixOS/nixpkgs/pull/328673.

The correct fix is to remove the hook. It’s not used by the 11.0 or 12.3 SDKs. This makes the 10.12 SDK a bit more like the other SDKs.
2024-07-26 12:41:45 -04:00
Randy Eckenrode c922cb27b6 bintools-wrapper: drop postLinkSignHook
When the linker signs a Mach-O binary, it sets a flag in the signature’s code directory indicating that the signature was generated by a linker. Tools such as `strip` and `install_name_tool` read this flag and will
update ad hoc signatures after they perform their modifications.

The updated l64 supports signing binaries automatically. Both the updated cctools and LLVM will check for the linker-signed flag and resign binaries they modify automatically when it’s present. Given that, use of postLinkSignHook is unnecessary and potentially harmful.

In particular, if the hook is used and an unwrapped `strip` or `install_name_tool` is on the user’s path, they will not automatically update an ad hoc signature. Instead, they will issue a warning and create a binary with a broken signature.

It is more robust to let the tools handled this since the only time a signature would not be linker-signed is when the user is manually invoking `codesign` (or another tool such as `sigtool` or `rcodesign`), which by nature of the invocation updates the signature to a valid  one.

Since `strip` no longer needs to be wrapped for code-signing, binutils-wrapper now uses the GNU strip wrapper on Darwin.

Fixes https://github.com/NixOS/nixpkgs/issues/208951.
2024-07-13 17:54:36 -04:00
Randy Eckenrode 1cb1853573 ld-wrapper: use a temporary file for reponse file
This changes ld-wrapper to use a temporary file for the response file
passed to ld instead of using process substitution.

ld64 does not handle long command-lines when reading from the response
file, which defeats the point of using a response file to handle long
command-lines. cctools-port was patched to work around this, but nixpkgs
is now using Apple’s source release directly instead of the port.

Since it’s preferable not to patch Apple’s release heavily (to reduce
the difficulty of updating to new versions and to match upstream’s
behavior), use the approach that was adopted in cc-wrapper to work
around issues with response files in newer versions of clang.

Related PRs (cctools-port):
- https://github.com/NixOS/nixpkgs/pull/213831
- https://github.com/tpoechtrager/cctools-port/pull/132

Related PRs (cc-wrapper):
- https://github.com/NixOS/nixpkgs/pull/245282
- https://github.com/NixOS/nixpkgs/pull/258608
2024-07-13 10:59:41 -04:00
John Ericson 000b58721f Merge remote-tracking branch 'upstream/master' into openbsd-static 2024-07-09 18:18:47 -04:00