Commit Graph

631 Commits

Author SHA1 Message Date
Audrey Dutcher
05dc4b5ac8 libllvm: use updateAutotoolsGnuConfigScriptsHook to fix FreeBSD->other cross build 2024-11-20 01:36:31 -07:00
Reno Dakota
f9a5549db2 llvmPackages{12-git}.clang: don't swallow unsupported option errors when compiling + linking
`https://github.com/llvm/llvm-project/issues/116278`

make clang report unsupported option errors / warning when compiling +
linking in the same command.

this works
```
$ clang --target=aarch64 -mpopcnt hello.c
clang: error: unsupported option '-mpopcnt' for target aarch64
```

before change clang swallows the error
```
$ clang --target=aarch64 -mpopcnt hello.c -lc
$ echo $?
0
```

after change error is reported:
```
$ clang --target=aarch64 -mpopcnt hello.c -lc
clang: error: unsupported option '-mpopcnt' for target aarch64
```
2024-11-20 02:33:34 +00:00
Reno Dakota
b4ccd4a123 llvmPackages_{13,14,15,16,17}.compiler-rt: reorder cfi_startproc after label
fixes building with llvm_18+
2024-11-20 02:14:50 +00: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
b600d09aa1 llvmPackages.libcxx: remove code for macOS < 11 2024-11-18 00:14:00 +00:00
Emily
4963ea1eaa llvmPackages.lldb: remove code for macOS < 11 2024-11-18 00:14:00 +00:00
Emily
98d5c93e0a llvmPackages.compiler-rt: remove code for macOS < 11 2024-11-18 00:14:00 +00:00
Emily
ab258a9bfe llvmPackages_12.compiler-rt: fix build race aarch64-darwin (#356814) 2024-11-17 22:00:12 +00:00
Reno Dakota
47a4caf483 llvmPackages_12.compiler-rt: fix build race aarch64-darwin
b31080c596
2024-11-17 13:43:02 -08:00
Emily
597a7ad587 llvmPackages.clang: move add-nostdlibinc-flag.patch to cc-wrapper (#356162) 2024-11-17 14:29:00 +00:00
Peter Waller
7047ba9ccb llvmPackages.clang: move add-nostdlibinc-flag.patch to cc-wrapper
Remove a patch to decrease the divergence from upstream.

Motivation is a continuation of trying to reduce the number of clang
builds floating around. Wrapper builds are cheap, compiler builds are
not.

It's expected that this patch can be removed at some point and replaced
with some other cc-wrapper logic. This will be a little bit easier with
the logic already in the cc-wrapper.

Ongoing discussion in #191152. It would be nice to drop this but we
think it's probably needed at least on systems where /usr/include may be
available to prevent the possibility of picking up unwanted includes.

One potential method for eliminating nostdlibinc in the future is by
providing a non-existent -sysroot but that was reverted in #213185, and
remains a can of worms.

Signed-off-by: Peter Waller <p@pwaller.net>
2024-11-15 15:48:50 +00:00
Peter Waller
7903d0b711 llvmPackages.llvm: Drop dependency on target through libbfd
Currently the target triple leaks into the clang build via llvm using
libbfd, whose build varies according to the target triple.

LLVM only uses libbfd to enable LTO via the linker plugin (called
LLVMgold.so, though multiple linkers can use the same plugin).

Drop the dependency on the libbfd build, and consume the only needed
source instead.  (This would be a good use of CA-derivations FWIW).

The result of this commit is that these match:

* nix eval --raw nixpkgs#clang.cc
* nix eval --raw nixpkgs#pkgsStatic.pkgsLLVM.stdenv.cc.cc
* nix eval --raw nixpkgs#pkgsCross.aarch64-multiplatform.pkgsLLVM.stdenv.cc.cc

This means fewer clang builds will be needed to support cross
configurations, and users wanting to target an exotic cross
configuration should be able to do so without a rebuild of clang.

Also drops libbfd.hasPluginAPI which no longer has any users.

Signed-off-by: Peter Waller <p@pwaller.net>
2024-11-14 21:43:26 +00:00
github-actions[bot]
8a28502668 Merge staging-next into staging 2024-11-13 00:14:48 +00:00
github-actions[bot]
80fdc8b778 Merge master into staging-next 2024-11-13 00:14:23 +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
37437849de llvmPackages_12.clang: use nostdlibinc patch instead of sed command
Seems like the patch we've written for LLVM 13 and above also works for
LLVM 12 which seems a little more robust.
2024-11-08 23:31:05 +01: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]: 665ebfb253/pkgs/development/compilers/llvm/12/default.nix (L392-L430)
2024-11-08 23:30:20 +01:00
sternenseemann
ce6c31c312 llvmPackages_{12,13}.lldb: don't try to find nonexistent patch
We just need to make sure the attribute evaluates so we can cleanly
access `meta.broken` for those versions.
2024-11-08 23:19:52 +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
Peter Waller
801a9a90db llvmPackages.libcxx: Include libc sources in input
Without this, after llvm 6c4267fb1779bc5550bb413f33250f9365acfbc6  you
get a build failure because libcxx can't find headers which now live in
the libc tree.

Ref: https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701/18
Ref: 6c4267fb17
Signed-off-by: Peter Waller <p@pwaller.net>
2024-11-08 12:34:51 +00:00
github-actions[bot]
3533282a88 Merge master into staging-next 2024-11-07 20:49:24 +00:00
Emily
3a6d4d006a treewide: use getLib when accessing clang / libclang / stdenv.cc.cc (#354197) 2024-11-07 18:16:05 +00:00
K900
a3600c0788 Merge remote-tracking branch 'origin/master' into staging-next 2024-11-07 21:06:37 +03:00
Reno Dakota
52bf1163fa treewide: use getLib when accessing clang / libclang / stdenv.cc.cc
In preparation to eliminate the lib output for the unwrapped clang, use
`lib.getLib` to access the `lib` output.
2024-11-07 10:27:41 +00:00
Emily
a886e49239 llvmPackages_19: 19.1.1 -> 19.1.3 (#352781) 2024-11-06 23:52:35 +00:00
Reno Dakota
1ab5205fbb llvmPackages_19.bolt: upstream patch to fix darwin build
5909979869
2024-11-06 15:49:20 -08:00
Reno Dakota
7eb779860d llvmPackages_19.libclc: use unwrapped clang only
The build requires an unwrapped clang due to passing in --arch flags.
However, for c++ it doesn't pass in --arch and requires standard headers
so which requires the wrapped compiler.
2024-11-06 15:49:20 -08:00
seth
fb917de147 llvmPackages_18.libcxx: fix building on windows 2024-11-06 17:29:37 -05:00
seth
ad338630ff llvmPackages_18.compiler-rt: fix building on windows 2024-11-06 17:29:28 -05:00
Reno Dakota
fa8ce61acd llvmPackages_19.compiler_rt: don't codesign
The codesign binary is part of the bootstrapTools and is incompatible
with the version required by the compiler_rt build. Remove
find_program(.., codesign) from the cmake files to prevent the build
from using and then breaking due to an incompatible codesign
2024-11-02 19:00:00 -07:00
github-actions[bot]
f3423cc412 Merge staging-next into staging 2024-10-30 00:14:51 +00:00
github-actions[bot]
dee80e3490 Merge master into staging-next 2024-10-30 00:14:27 +00:00
Peter Waller
9917c9705f llvmPackages.clang: Drop CLANG_DEFAULT_CXX_STDLIB
This is better handled in the cc-wrapper, and makes it possible to avoid
rebuilding clang in some scenarios.

It also appears to be unnecessary since the cc-wrapper already passes
-stdlib=libc++ where needed.

See: 8885a1e21a/pkgs/build-support/cc-wrapper/default.nix (L603)
Signed-off-by: Peter Waller <p@pwaller.net>
2024-10-27 15:25:04 +00:00
github-actions[bot]
88df199edf Merge staging-next into staging 2024-10-26 06:04:44 +00:00
Reno Dakota
d5a850af22 lldb_{14,15,16,17,18,19}: fix x64 darwin
x64 darwin doesn't build with 10.12 sdk after the sdk refactor due to
compile errors. bumping the sdk to 11 fixes the build.

set min deployment target as needed for lldb_14

lldb_14 still broken but due to an unrelated issue.
2024-10-25 06:19:41 +00:00
Emily
514b00cf08 clang: skip the -nostdlibinc patch on Darwin 2024-10-24 17:55:27 +01:00
Emily
7205ddc1ff llvmPackages.clang: limit backport to clang 15 and 16 (#348391) 2024-10-14 18:32:48 +01:00
github-actions[bot]
b9f01e6de3 Merge staging-next into staging 2024-10-14 12:06:08 +00:00
Randy Eckenrode
19db9e3031 llvmPackages.clang: limit backport to clang 15 and 16 2024-10-14 07:40:08 -04:00
sternenseemann
1d6675e530 llvmPackages_13: build from filtered monorepoSrc
This change implements a leftover task from #307211, namely passing
monorepoSrc to the different llvmPackages_13 package expressions. Before
this change, all packages llvmPackages_13 would be built from a
subdirectory of the full LLVM monorepo tree. After this change only the
relevant directories are made available at build time. This

- reduces the size of the source that needs to be made available to the
  builder.
- prevents LLVM from sidestepping our instructions and including extra
  sources from other directories it shouldn't.

Since LLVM 12 and 13 don't have the `cmake` directory at the top level,
the runCommand expressions filtering the source need to be adjusted, but
this causes no rebuild for any other LLVM version (ofborg should confirm
this).

The only problem encountered was in lld:

- We need to make the patch to the inclusion of libunwind headers
  unconditional now. lld needs this on non-darwin as well. In the
  full monorepo, LLVM_MAIN_SRC_DIR would be set correctly, so the
  patch wasn't necessary.
- The substitute mechanism for LLVM 12 and 13 can't be unified yet since
  LLVM 12 still uses a non monorepo build, so we come up with a
  different LLVM_MAIN_SRC_DIR.

Change was tested by building the following expression on x86_64-linux.

    with import ./. {};
    builtins.removeAttrs llvmPackages_13 [ "lldb" "lldbPlugins" ]'

lld was also tested on aarch64-darwin.
2024-10-14 12:15:32 +02:00
Emily
66d78e097f darwin: change the SDK pattern, update the SDKs, and update source releases (#346043) 2024-10-11 00:58:09 +01:00
Randy Eckenrode
34ce30c35a llvmPackages.libllvm: disable tests when built in the Darwin bootstrap
When using the LLVM bootstrap to build LLVM and its libraries,
overriding just LLVM to disable tests during the first build doesn’t
seem to work. This stage name should remain stable, so check for it and
disable tests when building in it.
2024-10-10 16:23:02 -04:00
Randy Eckenrode
18211adceb llvmPackages.libcxx: use a bootstrap stdenv on Darwin
Using a bootstrap stdenv is needed to avoid infinite recursions that
occur due to inputs propagated by SDK that depend on libc++.
2024-10-10 16:23:02 -04:00
Randy Eckenrode
3e5acdacdd llvmPackages.compiler-rt: fix cross-compilation on Darwin
When compiler-rt targets Darwin, it is built with `-target`, which
causes clang to try to invoke `ld` without a target prefix (e.g., it
will try to exec `ld` instead of `x86_64-apple-darwin-ld` on a
cross-build to x86_64-darwin). Specifying `--ld-path` overrides that
behavior, allowing it to find the appropriate cross-linker.
2024-10-10 16:23:02 -04:00
Randy Eckenrode
e6a4c83d20 llvmPackages.compiler-rt: fix compiler-rt bootstrap on Darwin
The first build of compiler-rt in the LLVM bootstrap is build without
libc++ being available, which causes support for the `-g` flag to be
detected incorrectly on Darwin. Overriding the check by specifying that
it’s usable allows the first build of compiler-rt to succeed.
2024-10-10 16:23:01 -04:00
Randy Eckenrode
2fd9a1abeb llvmPackages.compiler-rt: drop use of xcbuild
compiler-rt supports specifying the SDK path and version, so do that to
avoid needing to include `xcrun` as a native build input, which
simplifies the bootstrap.
2024-10-10 16:23:01 -04:00
Randy Eckenrode
7647c6834a llvmPackages.compiler-rt: avoid propagating the SDK in static builds 2024-10-10 16:23:01 -04:00
Randy Eckenrode
654e19fb83 llvmPackages.compiler-rt: always build sanitizers on Darwin
Also enable TSAN since the SDK has xpc. There’s no reason to disable it.
2024-10-10 16:23:01 -04:00