edk2/OVMF: Support build on macOS
In order to use OVMF firmware with e.g. qemu on macOS, these packages needed to be made macOS ready. This meant choosing the clang build in this case, because it is the only one working on macOS. Unfortunately, just using clang on all platforms doesn't work because there are hardcoded assumptions in the edk2 build system.
This commit is contained in:
parent
e3efdbf3f8
commit
f5f53288cc
@ -17,9 +17,13 @@ let
|
||||
throw "Unsupported architecture";
|
||||
|
||||
version = lib.getVersion edk2;
|
||||
buildType = if stdenv.isDarwin then
|
||||
"CLANGPDB"
|
||||
else
|
||||
"GCC5";
|
||||
in
|
||||
|
||||
edk2.mkDerivation projectDscPath {
|
||||
edk2.mkDerivation projectDscPath buildType {
|
||||
name = "OVMF-${version}";
|
||||
|
||||
outputs = [ "out" "fd" ];
|
||||
@ -57,6 +61,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"];
|
||||
};
|
||||
}
|
||||
|
@ -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,12 @@ 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;
|
||||
|
||||
edk2 = buildStdenv.mkDerivation {
|
||||
pname = "edk2";
|
||||
version = "201911";
|
||||
|
||||
@ -25,8 +43,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.isDarwin) [ "BUILD_CC=clang BUILD_CXX=clang++ BUILD_AS=clang" ];
|
||||
|
||||
NIX_CFLAGS_COMPILE = "-Wno-return-type" + lib.optionalString (!stdenv.isDarwin) " -Wno-error=stringop-truncation";
|
||||
|
||||
hardeningDisable = [ "format" "fortify" ];
|
||||
|
||||
@ -38,15 +58,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: buildType: attrs: buildStdenv.mkDerivation ({
|
||||
inherit (edk2) src;
|
||||
|
||||
buildInputs = [ bc pythonEnv ] ++ attrs.buildInputs or [];
|
||||
@ -65,7 +85,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
|
||||
'';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user