@@ -36,8 +36,12 @@ in stdenv.mkDerivation rec {
3636
3737 # Fix a segfault in llc
3838 # See http://lists.llvm.org/pipermail/llvm-dev/2016-October/106500.html
39− patches = [ ./D17533-1.patch ] ++
40− stdenv.lib.optionals (!stdenv.isDarwin) [./fix-llvm-config.patch];
39+ patches = [ ./D17533-1.patch ]
40+ ++ stdenv.lib.optional (!stdenv.isDarwin) ./fix-llvm-config.patch
41+ ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
42+ ../TLI-musl.patch
43+ ../dynamiclibrary-musl.patch
44+ ];
4145
4246 # hacky fix: New LLVM releases require a newer macOS SDK than
4347 # 10.9. This is a temporary measure until nixpkgs darwin support is
@@ -81,6 +85,14 @@ in stdenv.mkDerivation rec {
8185 ++ stdenv.lib.optionals ( isDarwin) [
8286 "-DLLVM_ENABLE_LIBCXX=ON"
8387 "-DCAN_TARGET_i386=false"
88+ ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
89+ "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
90+ "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
91+ "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
92+ # Not yet supported
93+ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
94+ "-DCOMPILER_RT_BUILD_XRAY=OFF"
95+
8496 ];
8597
8698 postBuild = ''