84 Commits

Author SHA1 Message Date
Alba Mendez f6f258efa1 compiler-rt: enable build of libatomic
LLVM stdenvs lack a set of `__atomic_*` routines that compilers
sometimes rely on, making it impossible to build certain C programs in
them. The reason we lack these routines is that we're using neither
compiler-rt's implementation of them (which was disabled by default a
long time ago) nor gcc's implementation (libatomic). See #391740 for a
more detailed explanation and an example of program that cannot be built.

Since no particular preference was expressed as to which approach
should be used to solve this, I'm going with LLVM's implementation
and recommended setup, which seems to be used also in AIX, Fuchsia
and Apple platforms. This consists of enabling a CMake flag,
`COMPILER_RT_BUILD_STANDALONE_LIBATOMIC`, which causes the routines to
be built and shipped in a separate DSO (placing them in a DSO instead
of `builtins.a` is needed for correctness, as it ensures the lock
section is unique in memory).

As with the other builtins, I'm symlinking this DSO to `libatomic.so` so
that downstream packages don't need specific/complicated logic for LLVM.

Other details:
- For static platforms, since no dynamic linking is expected at all, it
  should be correct to ship the symbols in `builtins.a`.
  So, that's what I'm doing in those cases.
- Since v19, compiler-rt allows using pthread locks rather than ad-hoc
  ones for the atomic routines. Since this plays better with
  instrumentation, I'm enabling this whenever libc is available.
- It would be nice to put the DSO in a separate output / derivation, so
  that the rest of compiler-rt isn't pulled into the runtime closure,
  but it isn't high prio since compiler-rt doesn't pull in dependencies
  other than libc, libc++ and unwinder.

Fixes: https://github.com/NixOS/nixpkgs/issues/311930
2026-02-08 10:27:57 +01:00
Vladimír Čunát 9ab74f3ce3 glibc: 2.40-66 -> 2.42-47 (#379542) 2026-01-06 17:24:04 +00:00
Maximilian Bosch e69f759b53 llvmPackages_1{8,9}.compiler-rt: fix build w/ glibc-2.42
Failing Hydra build: https://hydra.nixos.org/build/308327424
2026-01-03 20:39:42 +01:00
Theo Paris 8c4fa80840 llvmPackages.compiler-rt: fix nolibc build
Signed-off-by: Theo Paris <theo@theoparis.com>
Change-Id: Ieae2b7b767f744fac4a4f9fc46e949db6a6a6964
2025-12-23 19:25:40 -08:00
Wolfgang Walther 5e1f5b623b Merge branch 'staging-next' into staging 2025-10-05 11:40:56 +02:00
K900 e93c560b79 Merge remote-tracking branch 'origin/master' into staging-next 2025-10-05 12:17:08 +03:00
Wolfgang Walther 91a8fee3aa treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
Alyssa Ross 4d44f8fa53 llvmPackages.compiler-rt: clean up libxcrypt fix
This is unnecessary since LLVM commit d7bead833631 ("[sanitizer]
Remove crypt and crypt_r interceptors"), included in LLVM 18, the
oldest version we still have in Nixpkgs.
2025-09-30 22:40:41 +02:00
Emily ebbad85342 Reapply "various: fix Scudo allocator due to LLVM update" (#444670) 2025-09-20 16:30:32 +01:00
Emily 85b124cedd Reapply "various: fix Scudo allocator due to LLVM update"
This reverts commit 5119cafc59.
2025-09-20 16:24:40 +01:00
K900 5119cafc59 Revert "various: fix Scudo allocator due to LLVM update" 2025-09-20 17:53:06 +03:00
Lisa Gnedt 753af06dab treewide: fix Scudo options
The commit 01e8f570c6 unpinned the
LLVM version, which led to the following warnings whenever Scudo
is loaded (basically whenever a command is started when used
system-wide):

Scudo WARNING: found 3 unrecognized flag(s):
    DeleteSizeMismatch=0:DeallocationTypeMismatch=0
    DeallocationTypeMismatch=0
    ZeroContents=1

According to the current Scudo documentation [1] the options are
now spelled differently. This commit keeps all existing options
and only updates the spelling.

[1] https://llvm.org/docs/ScudoHardenedAllocator.html

Reported-by: CUB3D <callumthom11@gmail.com>
2025-09-20 13:11:04 +02:00
nixpkgs-ci[bot] 264b97ec67 Merge staging-next into staging 2025-09-15 13:52:03 +00:00
Emily 2dac87bbde llvmPackages_17: drop 2025-09-14 19:03:24 +01:00
Emily 77acbe1f9c llvmPackages_15: drop 2025-09-14 19:03:24 +01:00
Emily f470ea24b6 llvmPackages_14: drop 2025-09-14 19:03:24 +01:00
Emily 791fe23b63 llvmPackages_13: drop 2025-09-14 19:03:24 +01:00
Emily 9b8a66c3a4 llvmPackages_12: drop 2025-09-14 19:03:24 +01:00
Emily f7444c37db llvmPackages: remove unreferenced patches 2025-09-14 19:03:24 +01:00
Tristan Ross ded560caff llvmPackages_{20,21,git}.compiler-rt: no fmv on aarch64 without libc
aarch64 FMV (Function MultiVersioning) is not available before the libc
is available. This causes issues while building with compiler-rt on
aarch64. By disabling FMV before the libc is available resolves missing
symbol errors.
2025-09-13 09:27:17 -07:00
Wolfgang Walther 5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Tristan Ross a041bf2656 llvmPackages_{21: init from 21.1.0-rc1,git: 21.0.0-unstable-2025-07-12 -> 22.0.0-unstable-2025-07-17} 2025-07-17 14:41:42 -07:00
Tristan Ross ac9394463c llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: condense native build inputs 2025-04-09 12:13:06 +02:00
Tristan Ross 228dab381b llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: condense
cmake flags
2025-04-09 12:13:06 +02:00
Tristan Ross a413234974 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: optional string cflags link 2025-04-09 12:13:06 +02:00
Tristan Ross 30d40ddba9 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: organize patches 2025-04-09 12:13:06 +02:00
Tristan Ross db20725541 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: move src 2025-04-09 12:13:06 +02:00
Tristan Ross 4f788a2720 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: move pname 2025-04-09 12:13:06 +02:00
Tristan Ross 1d97340555 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: drop base name 2025-04-09 12:13:06 +02:00
Tristan Ross b39cd95424 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: use final attrs 2025-04-09 12:13:06 +02:00
Tristan Ross a4977f1053 llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: use lib.cmake functions 2025-04-09 12:13:06 +02: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
Tristan Ross c330ebeb4f llvmPackages_{12,13,14,15,16,17,18,19,20,git}.compiler-rt: move patches out of common 2025-03-07 14:17:38 +01:00
Peder Bergebakken Sundt 5aba99242e treewide: fix typos in comments
Made with

```shell
git restore .
fd '\.nix$' pkgs/ --type f -j1 -x bash -xc "$(cat <<"EOF"
    typos --no-check-filenames --write-changes "$1"
    git diff --exit-code "$1" && exit
    #( git diff "$1" | grep -qE "^\+ +[^# ]") && git restore "$1"
    count1="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> ' | wc -l )"
    count2="$( bat --language nix --diff --style changes "$1" --theme "Monokai Extended" --color always | aha --no-header | grep -E '^<span style="color:olive;">~</span> (<span style="color:#f8f8f2;"> *</span>)?<span style="color:#75715e;">.*</span>$' | wc -l )"
    [[ $count1 -ne $count2 ]] && git restore "$1"
EOF
)" -- {}
```

and filtered with `GIT_DIFF_OPTS='--unified=15' git -c interactive.singleKey=true add --patch`

I initially tried using the tree-sitter cli, python bindings and even ast-grep through various means, but this is what I ended up with.
2025-02-24 10:44:41 +01:00
github-actions[bot] 17dc04d068 Merge staging-next into staging 2024-12-17 12:06:41 +00:00
K900 293d08b05f Merge remote-tracking branch 'origin/master' into staging-next 2024-12-17 09:46:26 +03:00
Tristan Ross ba1deff5ad llvmPackages.*: Expose git rev through pkg.src.rev (#354792) 2024-12-16 19:38:25 -08:00
Peter Waller 269fdda927 llvmPackages: sed -i 's/--replace /--replace-fail /g'
Rationale: --replace is deprecated and emits warnings. If these
replacements fail it is probably better to know about it early and come
up with better fixes than the alternative of letting them silently fail
and discover some distal brokenness.

Signed-off-by: Peter Waller <p@pwaller.net>
2024-12-15 16:20:01 +00:00
sternenseemann fcb5d10d26 llvmPackages_12.compiler-rt: move codesign patch into versioned dir
All LLVM versions < 12 have been removed, so this patch can live in the
versioned directory, simplifying the patch list in the process.

(cherry picked from commit 8408b91e8d)
(cherry picked from commit e33308016c10e2c67551e448b420bed634907c62)
2024-11-30 15:11:09 +01:00
sternenseemann f0f66c41d4 llvmPackages_12: build from monorepo source
As mentioned in #305146, keeping LLVM 12 is a source of pain because it
is the only version to be built from individual release tarball instead
of the LLVM monorepo. This commit makes LLVM 12 start from the monorepo
as well, simplifying all common LLVM expressions in the process.

With #347887, some quirks in the expressions for LLVM <14 were ironed
out, so building LLVM through from the monorepo is quite simple now.

- Most expressions only required minor changes, mostly removing the
  special casing for `sourceRoot`.

- The patch lists from llvm/12/default.nix were ported to
  common/default.nix. This only required a few extra conditionals which
  could be reduced via a rebuild also involving other LLVM versions.
  Outstanding tasks of little urgency have been noted in TODO comments.
  I have verified that the patch lists stay the same for all packages
  except LLVM where merely the order changes. An extra set of eyes
  is appreciated, of course.

- clang: The expression was reworked to use the same symlink location
  for clang-tools-extra for all versions including LLVM 12. This
  required adjusting the ad hoc patching of the clangd cmake files
  slightly.

- libunwind: We no longer need to make the libcxx sources available
  manually. We can rely on the monorepo source instead.

- lld: We no longer need to make the libunwind sources available manually.

- llvm: We no longer need to make the polly sources available manually

- On Darwin, we need to bypass CMake's C++ compiler for libcxx and
  libunwind now. It isn't a 100% clear why, probably because we've
  started to use Darwin's bootstrapStdenv for libcxx in the common
  expression compared to LLVM 12 on master [1].
  The reordering of flags for wasm causes a rebuild for some packages
  like firefox, but this should be tolerable on staging.

[1]: https://github.com/NixOS/nixpkgs/blob/665ebfb253caba7b85c2affefe2a92b305def4e6/pkgs/development/compilers/llvm/12/default.nix#L392-L430

(cherry picked from commit ee9eacf23e)
(cherry picked from commit c4e9f17ef944bb7ce0d3d1226d7f922f28e46b02)
2024-11-30 15:11:09 +01:00
K900 3b5cb28a23 Merge remote-tracking branch 'origin/staging-next' into staging 2024-11-26 09:46:04 +03:00
Tristan Ross b994c8ca43 llvmPackages.compiler_rt: Fix version tests for git (#354471) 2024-11-25 07:25:18 -08:00
Emily c51d53002c llvmPackages_{12,13,14,15}.compiler-rt: fix preConfigure
Fixes: dde9606751
2024-11-18 19:37:36 +00:00
Emily dde9606751 llvmPackages.compiler-rt: use $SDKROOT to fix Darwin static 2024-11-18 18:09:48 +00:00
Emily 98d5c93e0a llvmPackages.compiler-rt: remove code for macOS < 11 2024-11-18 00:14:00 +00:00
Peter Waller cdefc40e99 llvmPackages.*: Expose git rev through pkg.src.rev
Also exposes owner, repo, and other attributes available on the original
monorepoSrc. These attributes were previously hidden behind a
runCommand that consumes monorepoSrc and hides this information away.

```
$ nix eval --raw .#llvmPackages_18.llvm.src.rev
llvmorg-18.1.8

$ nix eval --raw .#llvmPackages_git.llvm.src.rev
0e8555d4dbfdfeddc01dc2ecf9a9b6e804f7b645
```

Signed-off-by: Peter Waller <p@pwaller.net>
2024-11-09 15:12:56 +00:00
sternenseemann 8408b91e8d llvmPackages_12.compiler-rt: move codesign patch into versioned dir
All LLVM versions < 12 have been removed, so this patch can live in the
versioned directory, simplifying the patch list in the process.
2024-11-08 23:30:29 +01:00
sternenseemann ee9eacf23e llvmPackages_12: build from monorepo source
As mentioned in #305146, keeping LLVM 12 is a source of pain because it
is the only version to be built from individual release tarball instead
of the LLVM monorepo. This commit makes LLVM 12 start from the monorepo
as well, simplifying all common LLVM expressions in the process.

With #347887, some quirks in the expressions for LLVM <14 were ironed
out, so building LLVM through from the monorepo is quite simple now.

- Most expressions only required minor changes, mostly removing the
  special casing for `sourceRoot`.

- The patch lists from llvm/12/default.nix were ported to
  common/default.nix. This only required a few extra conditionals which
  could be reduced via a rebuild also involving other LLVM versions.
  Outstanding tasks of little urgency have been noted in TODO comments.
  I have verified that the patch lists stay the same for all packages
  except LLVM where merely the order changes. An extra set of eyes
  is appreciated, of course.

- clang: The expression was reworked to use the same symlink location
  for clang-tools-extra for all versions including LLVM 12. This
  required adjusting the ad hoc patching of the clangd cmake files
  slightly.

- libunwind: We no longer need to make the libcxx sources available
  manually. We can rely on the monorepo source instead.

- lld: We no longer need to make the libunwind sources available manually.

- llvm: We no longer need to make the polly sources available manually

- On Darwin, we need to bypass CMake's C++ compiler for libcxx and
  libunwind now. It isn't a 100% clear why, probably because we've
  started to use Darwin's bootstrapStdenv for libcxx in the common
  expression compared to LLVM 12 on master [1].
  The reordering of flags for wasm causes a rebuild for some packages
  like firefox, but this should be tolerable on staging.

[1]: https://github.com/NixOS/nixpkgs/blob/665ebfb253caba7b85c2affefe2a92b305def4e6/pkgs/development/compilers/llvm/12/default.nix#L392-L430
2024-11-08 23:30:20 +01:00
Peter Waller 2c14728202 llvmPackages.compiler_rt: Fix compiler_rt version tests for git
Without these fixes, the git build currently fails because the tests are
out of date.

One is updated since it was fixed upstream, the other is still needed
for the git build, but testing `version` resulted in a test against the
`unstable-*` string and not the one with the version number in it.

Signed-off-by: Peter Waller <p@pwaller.net>
2024-11-08 12:36:25 +00:00
K900 a3600c0788 Merge remote-tracking branch 'origin/master' into staging-next 2024-11-07 21:06:37 +03:00