diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2020-05-04 16:41:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-04 16:41:00 +0100 |
commit | 2b08905caebc323e4138b259c921baeb733e0eaa (patch) | |
tree | decec5760eebf9282138b6573f16ea63cf86e8ec | |
parent | 8471593028a412399f01f79ffbc6207f2590a4bb (diff) | |
parent | faf984d12de03cba018fe3099a1de1d607c038da (diff) | |
download | nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.tar nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.tar.gz nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.tar.bz2 nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.tar.lz nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.tar.xz nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.tar.zst nixlib-2b08905caebc323e4138b259c921baeb733e0eaa.zip |
Merge pull request #85603 from parthy/edk2-macos
edk2: Support build on macOS
-rw-r--r-- | pkgs/applications/virtualization/OVMF/default.nix | 2 | ||||
-rw-r--r-- | pkgs/development/compilers/edk2/default.nix | 41 |
2 files changed, 34 insertions, 9 deletions
diff --git a/pkgs/applications/virtualization/OVMF/default.nix b/pkgs/applications/virtualization/OVMF/default.nix index 310d41df36da..19ba8ced4973 100644 --- a/pkgs/applications/virtualization/OVMF/default.nix +++ b/pkgs/applications/virtualization/OVMF/default.nix @@ -57,6 +57,6 @@ edk2.mkDerivation projectDscPath { description = "Sample UEFI firmware for QEMU and KVM"; homepage = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF"; license = stdenv.lib.licenses.bsd2; - platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"]; + platforms = ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin"]; }; } diff --git a/pkgs/development/compilers/edk2/default.nix b/pkgs/development/compilers/edk2/default.nix index 703ff4fa083b..8a18b6306c27 100644 --- a/pkgs/development/compilers/edk2/default.nix +++ b/pkgs/development/compilers/edk2/default.nix @@ -1,4 +1,17 @@ -{ stdenv, fetchgit, fetchpatch, libuuid, python3, iasl, bc }: +{ + stdenv, + clangStdenv, + fetchgit, + fetchpatch, + libuuid, + python3, + iasl, + bc, + clang_9, + llvmPackages_9, + overrideCC, + lib, +}: let pythonEnv = python3.withPackages (ps: [ps.tkinter]); @@ -12,7 +25,17 @@ else if stdenv.isAarch64 then else throw "Unsupported architecture"; -edk2 = stdenv.mkDerivation { +buildStdenv = if stdenv.isDarwin then + overrideCC clangStdenv [ clang_9 llvmPackages_9.llvm llvmPackages_9.lld ] +else + stdenv; + +buildType = if stdenv.isDarwin then + "CLANGPDB" + else + "GCC5"; + +edk2 = buildStdenv.mkDerivation { pname = "edk2"; version = "201911"; @@ -25,8 +48,10 @@ edk2 = stdenv.mkDerivation { buildInputs = [ libuuid pythonEnv ]; - makeFlags = [ "-C BaseTools" ]; - NIX_CFLAGS_COMPILE = "-Wno-return-type -Wno-error=stringop-truncation"; + makeFlags = [ "-C BaseTools" ] + ++ lib.optional (stdenv.cc.isClang) [ "BUILD_CC=clang BUILD_CXX=clang++ BUILD_AS=clang" ]; + + NIX_CFLAGS_COMPILE = "-Wno-return-type" + lib.optionalString (stdenv.cc.isGNU) " -Wno-error=stringop-truncation"; hardeningDisable = [ "format" "fortify" ]; @@ -38,15 +63,15 @@ edk2 = stdenv.mkDerivation { enableParallelBuilding = true; - meta = with stdenv.lib; { + meta = with lib; { description = "Intel EFI development kit"; homepage = "https://sourceforge.net/projects/edk2/"; license = licenses.bsd2; - platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ]; + platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ]; }; passthru = { - mkDerivation = projectDscPath: attrs: stdenv.mkDerivation ({ + mkDerivation = projectDscPath: attrs: buildStdenv.mkDerivation ({ inherit (edk2) src; buildInputs = [ bc pythonEnv ] ++ attrs.buildInputs or []; @@ -65,7 +90,7 @@ edk2 = stdenv.mkDerivation { buildPhase = '' runHook preBuild - build -a ${targetArch} -b RELEASE -t GCC5 -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags + build -a ${targetArch} -b RELEASE -t ${buildType} -p ${projectDscPath} -n $NIX_BUILD_CORES $buildFlags runHook postBuild ''; |