diff --git a/pkgs/development/compilers/llvm/7/libc++abi.nix b/pkgs/development/compilers/llvm/7/libc++abi.nix index 97141a0bd402..7f2ec528f3c1 100644 --- a/pkgs/development/compilers/llvm/7/libc++abi.nix +++ b/pkgs/development/compilers/llvm/7/libc++abi.nix @@ -1,4 +1,5 @@ { stdenv, cmake, fetch, libcxx, llvm, version +, standalone ? false # on musl the shared objects don't build , enableShared ? ! stdenv.hostPlatform.isMusl }: @@ -20,7 +21,9 @@ stdenv.mkDerivation { patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} ''; - cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF"; + cmakeFlags = + stdenv.lib.optional standalone "-DLLVM_ENABLE_LIBCXX=ON" ++ + stdenv.lib.optional (!enableShared) "-DLIBCXXABI_ENABLE_SHARED=OFF"; installPhase = if stdenv.isDarwin then '' diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 5386213f2ad7..fbd5f1cf3f01 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -74,44 +74,48 @@ in rec { inherit (last) stdenv; }; - coreutils = { name = "${name}-coreutils"; outPath = bootstrapTools; }; - gnugrep = { name = "${name}-gnugrep"; outPath = bootstrapTools; }; + mkExtraBuildCommands = cc: '' + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/${cc.version}/include" "$rsrc" + ln -s "${last.pkgs.llvmPackages_7.compiler-rt.out}/lib" "$rsrc/lib" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + ''; - bintools = import ../../build-support/bintools-wrapper { - inherit shell; - inherit (last) stdenvNoCC; + mkCC = overrides: import ../../build-support/cc-wrapper ( + let args = { + inherit shell; + inherit (last) stdenvNoCC; - nativeTools = false; - nativeLibc = false; - inherit buildPackages coreutils gnugrep; - libc = last.pkgs.darwin.Libsystem; - bintools = { name = "${name}-binutils"; outPath = bootstrapTools; }; - }; - - cc = if last == null then "/dev/null" else import ../../build-support/cc-wrapper { - inherit shell; - inherit (last) stdenvNoCC; + nativeTools = false; + nativeLibc = false; + inherit buildPackages libcxx; + inherit (last.pkgs) coreutils gnugrep; + bintools = last.pkgs.darwin.binutils; + libc = last.pkgs.darwin.Libsystem; + isClang = true; + cc = last.pkgs.llvmPackages_7.clang-unwrapped; + }; in args // (overrides args)); + cc = if last == null then "/dev/null" else mkCC ({ cc, ... }: { extraPackages = [ - # last.pkgs.llvmPackages_7.libcxxabi # TODO: is this required? if not, why not? + last.pkgs.llvmPackages_7.libcxxabi last.pkgs.llvmPackages_7.compiler-rt ]; + extraBuildCommands = mkExtraBuildCommands cc; + }); + ccNoLibcxx = if last == null then "/dev/null" else mkCC ({ cc, ... }: { + libcxx = null; + extraPackages = [ + last.pkgs.llvmPackages_7.compiler-rt + ]; extraBuildCommands = '' - rsrc="$out/resource-root" - mkdir "$rsrc" - ln -s "${bootstrapTools}/lib/clang/${bootstrapClangVersion}/include" "$rsrc" - ln -s "${last.pkgs.llvmPackages_7.compiler-rt.out}/lib" "$rsrc/lib" - echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags - ''; - - nativeTools = false; - nativeLibc = false; - inherit buildPackages coreutils gnugrep bintools libcxx; - libc = last.pkgs.darwin.Libsystem; - isClang = true; - cc = { name = "${name}-clang"; outPath = bootstrapTools; }; - }; + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags + echo "-B${last.pkgs.llvmPackages_7.compiler-rt}/lib" >> $out/nix-support/cc-cflags + echo "-nostdlib++" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }); thisStdenv = import ../generic { name = "${name}-stdenv-darwin"; @@ -150,7 +154,10 @@ in rec { extraAttrs = { inherit macosVersionMin appleSdkVersion platform; }; - overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; }; + overrides = self: super: (overrides self super) // { + inherit ccNoLibcxx; + fetchurl = thisStdenv.fetchurlBoot; + }; }; in { @@ -160,6 +167,9 @@ in rec { stage0 = stageFun 0 null { overrides = self: super: with stage0; { + coreutils = { name = "bootstrap-stage0-coreutils"; outPath = bootstrapTools; }; + gnugrep = { name = "bootstrap-stage0-gnugrep"; outPath = bootstrapTools; }; + darwin = super.darwin // { Libsystem = stdenv.mkDerivation { name = "bootstrap-stage0-Libsystem"; @@ -170,9 +180,26 @@ in rec { ''; }; dyld = bootstrapTools; + + binutils = lib.makeOverridable (import ../../build-support/bintools-wrapper) { + shell = "${bootstrapTools}/bin/bash"; + inherit (self) stdenvNoCC; + + nativeTools = false; + nativeLibc = false; + inherit (self) buildPackages coreutils gnugrep; + libc = self.pkgs.darwin.Libsystem; + bintools = { name = "bootstrap-stage0-binutils"; outPath = bootstrapTools; }; + }; }; llvmPackages_7 = { + clang-unwrapped = { + name = "bootstrap-stage0-clang"; + outPath = bootstrapTools; + version = bootstrapClangVersion; + }; + libcxx = stdenv.mkDerivation { name = "bootstrap-stage0-libcxx"; phases = [ "installPhase" "fixupPhase" ]; @@ -219,10 +246,19 @@ in rec { ninja = super.ninja.override { buildDocs = false; }; llvmPackages_7 = super.llvmPackages_7 // (let - libraries = super.llvmPackages_7.libraries.extend (_: _: { - inherit (llvmPackages_7) compiler-rt; + tools = super.llvmPackages_7.tools.extend (_: _: { + inherit (llvmPackages_7) clang-unwrapped; }); - in { inherit libraries; } // libraries); + libraries = super.llvmPackages_7.libraries.extend (_: _: { + inherit (llvmPackages_7) compiler-rt libcxx libcxxabi; + }); + in { inherit tools libraries; } // tools // libraries); + + darwin = super.darwin // { + binutils = darwin.binutils.override { + libc = self.darwin.Libsystem; + }; + }; }; in with prevStage; stageFun 1 prevStage { extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\""; @@ -248,14 +284,24 @@ in rec { libssh2 nghttp2 libkrb5 ninja; llvmPackages_7 = super.llvmPackages_7 // (let - libraries = super.llvmPackages_7.libraries.extend (_: _: { - inherit (llvmPackages_7) compiler-rt; + tools = super.llvmPackages_7.tools.extend (_: _: { + inherit (llvmPackages_7) clang-unwrapped; }); - in { inherit libraries; } // libraries); + libraries = super.llvmPackages_7.libraries.extend (_: libSuper: { + inherit (llvmPackages_7) compiler-rt; + libcxx = libSuper.libcxx.override { + stdenv = overrideCC self.stdenv self.ccNoLibcxx; + }; + libcxxabi = libSuper.libcxxabi.override { + stdenv = overrideCC self.stdenv self.ccNoLibcxx; + standalone = true; + }; + }); + in { inherit tools libraries; } // tools // libraries); darwin = super.darwin // { inherit (darwin) - dyld Libsystem xnu configd ICU libdispatch libclosure launchd CF; + binutils dyld Libsystem xnu configd ICU libdispatch libclosure launchd CF; }; }; in with prevStage; stageFun 2 prevStage { @@ -270,8 +316,9 @@ in rec { allowedRequisites = [ bootstrapTools ] ++ (with pkgs; [ - xz.bin xz.out libcxx libcxxabi llvmPackages_7.compiler-rt zlib - libxml2.out curl.out openssl.out libssh2.out nghttp2.lib libkrb5 + xz.bin xz.out libcxx libcxxabi llvmPackages_7.compiler-rt + zlib libxml2.out curl.out openssl.out libssh2.out + nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv ]) ++ (with pkgs.darwin; [ dyld Libsystem CF ICU locale ]); @@ -320,8 +367,9 @@ in rec { allowedRequisites = [ bootstrapTools ] ++ (with pkgs; [ - xz.bin xz.out bash libcxx libcxxabi llvmPackages_7.compiler-rt zlib - libxml2.out curl.out openssl.out libssh2.out nghttp2.lib libkrb5 + xz.bin xz.out bash libcxx libcxxabi llvmPackages_7.compiler-rt + zlib libxml2.out curl.out openssl.out libssh2.out + nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv ]) ++ (with pkgs.darwin; [ dyld ICU Libsystem locale ]);