Skip to content

Commit

Permalink
llvmPackages_15.compiler-rt: fixes for Darwin
Browse files Browse the repository at this point in the history
this introduces a codesigning related patch that we can drop once NixOS#195107
goes through

see: NixOS#194634 (comment)
  • Loading branch information
rrbutani committed Jan 8, 2023
1 parent 22ae91c commit 23d1a17
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
33 changes: 0 additions & 33 deletions pkgs/development/compilers/llvm/15/compiler-rt/codesign.patch

This file was deleted.

25 changes: 24 additions & 1 deletion pkgs/development/compilers/llvm/15/compiler-rt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ stdenv.mkDerivation {
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
"-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"

# `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin:
# https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153
"-DCOMPILER_RT_ENABLE_IOS=OFF"
];

outputs = [ "out" "dev" ];
Expand All @@ -78,7 +82,26 @@ stdenv.mkDerivation {
./normalize-var.patch
] # Prevent a compilation error on darwin
++ lib.optional stdenv.hostPlatform.isDarwin ./darwin-targetconditionals.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch

# The `compiler-rt` build inspects `ld` to figure out whether it needs to
# explicitly call `codesign`:
# https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/Modules/AddCompilerRT.cmake#L409-L422
#
# In our case, despite (currently) having an `ld` version than 609, we don't
# need an explicit codesigning step because `postLinkSignHook` handles this
# for us.
#
# Unfortunately there isn't an easy way to override
# `NEED_EXPLICIT_ADHOC_CODESIGN`.
#
# Adding `codesign` as a build input also doesn't currently work because, as
# of this writing, `codesign` in nixpkgs doesn't support the `--sign` alias
# which the `compiler-rt` build uses. See here for context:
# https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272116014
#
# So, for now, we patch `compiler-rt` to skip the explicit codesigning step.
++ lib.optional stdenv.targetPlatform.isDarwin ./skip-explicit-codesign.patch;

# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -406,7 +406,7 @@ function(add_compiler_rt_runtime name type)
if (HAD_ERROR)
message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
endif()
- set(NEED_EXPLICIT_ADHOC_CODESIGN 1)
+ set(NEED_EXPLICIT_ADHOC_CODESIGN 0) # `postLinkSignHook` handles this for us
if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
if (HOST_LINK_VERSION VERSION_GREATER_EQUAL 609)

0 comments on commit 23d1a17

Please sign in to comment.