llvmPackages_20.libc: enable scudo & link Scrt1

This commit is contained in:
Tristan Ross
2025-03-24 06:55:06 -07:00
parent 05219927d0
commit 9f9526053a
@@ -23,6 +23,7 @@ let
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/runtimes "$out"
cp -r ${monorepoSrc}/llvm "$out"
cp -r ${monorepoSrc}/compiler-rt "$out"
cp -r ${monorepoSrc}/${pname} "$out"
'');
in
@@ -60,18 +61,28 @@ stdenv.mkDerivation (finalAttrs: {
cd ../runtimes
'';
postInstall = lib.optionalString (!isFullBuild) ''
substituteAll ${./libc-shim.tpl} $out/lib/libc.so
'';
postInstall =
lib.optionalString (!isFullBuild) ''
substituteAll ${./libc-shim.tpl} $out/lib/libc.so
''
# LLVM libc doesn't recognize static vs dynamic yet.
# Treat LLVM libc as a static libc, requires this symlink until upstream fixes it.
+ lib.optionalString (isFullBuild && stdenv.hostPlatform.isLinux) ''
ln $out/lib/crt1.o $out/lib/Scrt1.o
'';
libc = if (!isFullBuild) then stdenv.cc.libc else null;
cmakeFlags =
[
(lib.cmakeBool "LLVM_LIBC_FULL_BUILD" isFullBuild)
(lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc")
(lib.cmakeFeature "LLVM_ENABLE_RUNTIMES" "libc;compiler-rt")
# Tests requires the host to have a libc.
(lib.cmakeBool "LLVM_INCLUDE_TESTS" (stdenv.cc.libc != null))
(lib.cmakeBool "LLVM_LIBC_INCLUDE_SCUDO" true)
(lib.cmakeBool "COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC" true)
(lib.cmakeBool "COMPILER_RT_BUILD_GWP_ASAN" false)
(lib.cmakeBool "COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED" false)
]
++ lib.optional (isFullBuild && stdenv.cc.libc == null) [
# CMake runs a check to see if the compiler works.