this allows a compiler derivation to provide a
hardeningUnsupportedFlagsByTargetPlatform passthru attr
that will be called with the targetPlatform to determine
the unsupported hardening flags for that platform.
we can do this because even though a clang compiler is
multi-target by nature, cc-wrapper effectively fixes the
target platform at wrapping time. otherwise we'd have to
sniff the intended target at runtime, which wouldn't
be fun at all.
the advantage of using a new attribute instead of
allowing hardeningUnsupportedFlags to optionally be a
function is that hardeningUnsupportedFlags retains its
simple overriding pattern for simple cases (i.e.
`(prev.hardeningUnsupportedFlags or []) ++ [ "foo" ]`
) which will continue to work as long as the bottom-most
function of hardeningUnsupportedFlagsByTargetPlatform
falls back to hardeningUnsupportedFlags.
c33c7c3d5f ("clang_11: Fix RISC-V builds for compiler-rt. (#135718)")
already marked tihs as broken for LLVM 11, but didn't apply the same
change to other affected LLVM versions.
This change applies the upstream PR
https://github.com/llvm/llvm-project/pull/77218 so the same link flags
on darwin are used as when LIBCXX_CXX_ABI=libcxxabi. Specifically, this
adds
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
which prevents libcxx from segfaulting on darwin
Before the change `llvmPackages.bintools.bintools.targetPrefix` was not
present. This exposed as a discrepansy between `binutils` and `llvm`:
`binutils`:
nix-repl> stdenv.cc.bintools.bintools.targetPrefix
""
nix-repl> stdenv.cc.bintools.targetPrefix
""
`llvm`:
nix-repl> pkgsLLVM.stdenv.cc.bintools.targetPrefix
"x86_64-unknown-linux-gnu-"
nix-repl> pkgsLLVM.stdenv.cc.bintools.bintools.targetPrefix
error:
error: attribute 'targetPrefix' missing
As a result some attributes like `pkgsLLVM.actionlint` failed to
evaluate:
$ nix build --no-link -f. pkgsLLVM.actionlint
...
error: attribute 'targetPrefix' missing
at pkgs/development/compilers/ghc/9.4.8.nix:232:46:
231| export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
232| export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
| ^
The change exposes binary prefix the same way as `binutils` does.
It appears that LLVM's build system no longer sets the executable's
rpath to include the faux resource root we pass in, so we need to make
sure cc-wrapper does this.