Skip to contentSkip to conversation

ovmf: add some rework to the recipe

PATCH In review João Marcos Costa 1 participant 5 messages May 14

lore
Share & tools
lore
#0 lore raw

cover ovmf: add some rework to the recipe

Hello,

This patch series contains, first of all, a slight issue with PACKAGECONFIG previously evoked by Q. Schulz (cc'ed) in the mailing list.

The main point of the series is the support for Clang, which I tested with the latest version llvm/clang available as of now in oe-core. I also tested the result with the help of runqemu.

Moreover, some of the settings are obsolete and can be removed.

Best regards,

---

Changes since v1:
- clarify the behaviour change in PACKAGECONFIG's assignment
- in the second patch, make it clear that the flag is obsolete because it was already upstreamed (and is part of the currently used tag), not because of GCC's version

João Marcos Costa (3):
ovmf: simplify PACKAGECONFIG's default value
ovmf: drop upstreamed BUILD_CFLAGS setting
ovmf: add support for Clang toolchain

 meta/recipes-core/ovmf/ovmf_git.bb | 51 ++++++------------------------
 1 file changed, 9 insertions(+), 42 deletions(-)
Signature · 1 line
2.47.0
#1 lore raw

PATCH 1/3 ovmf: simplify PACKAGECONFIG's default value

The two append operations call bb.utils.contains, while a single contains_any() does the trick in a cleaner way.

Regarding the default value, if tpm is not enabled, PACKAGECONFIG ends up with a couple empty spaces, and this can be avoided by redefining the default value to the result of contains_any().

Even though this replacement comes with a change in behaviour (at least in edge cases), we prefer a consistent PACKAGECONFIG (weak) default assignment across recipes.

---
 meta/recipes-core/ovmf/ovmf_git.bb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
meta/recipes-core/ovmf/ovmf_git.bb +1 -3
index 958f42fc10..cc251bbc00 100644
@@ -9,9 +9,7 @@ LIC_FILES_CHKSUM = "file://OvmfPkg/License.txt;md5=06357ddc23f46577c2aeaeaf7b776
 # Enabling Secure Boot adds a dependency on OpenSSL and implies
 # compiling OVMF twice, so it is disabled by default. Distros
 # may change that default.
-PACKAGECONFIG ??= ""
-PACKAGECONFIG += "${@bb.utils.filter('MACHINE_FEATURES', 'tpm', d)}"
-PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)}"
+PACKAGECONFIG ??= "${@bb.utils.contains_any('MACHINE_FEATURES', 'tpm tpm2', 'tpm', '', d)}"
 PACKAGECONFIG[debug] = ",,,"
 PACKAGECONFIG[secureboot] = ",,,"
 PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,,"
Signature · 1 line
2.47.0
#2 lore raw

PATCH 2/3 ovmf: drop upstreamed BUILD_CFLAGS setting

In reply to João Marcos Costa

This same gcc (v12) warning was handled upstream a while ago:

22130dcd98b4 ("Basetools: turn off gcc12 warning")

This change is available in the tag we currently use: edk2-stable202511.

In fact, it is available since edk2-stable202205, and the -Wno-error=stringop-overflow flag [1] was added for the same reason we have it in ovmf's recipe.

[1] https://github.com/tianocore/edk2/blob/master/BaseTools/Source/C/DevicePath/GNUmakefile#L27

---
 meta/recipes-core/ovmf/ovmf_git.bb | 4 ----
 1 file changed, 4 deletions(-)
meta/recipes-core/ovmf/ovmf_git.bb +0 -4
index cc251bbc00..f91f458006 100644
@@ -14,10 +14,6 @@ PACKAGECONFIG[debug] = ",,,"
 PACKAGECONFIG[secureboot] = ",,,"
 PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,,"
 
-# GCC12 trips on it
-#see https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch
-BUILD_CFLAGS += "-Wno-error=stringop-overflow"
-
 SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;tag=${PV} \
            file://0001-ovmf-update-path-to-native-BaseTools.patch \
            file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
Signature · 1 line
2.47.0
#3 lore raw

PATCH 3/3 ovmf: add support for Clang toolchain

In reply to João Marcos Costa

ovmf can be built with clang by using "CLANGDWARF" toolchain, so add TARGET_TOOLS variable to represent the switch between "GCC" and "CLANGDWARF".

Since the targets represented by FIXED_GCCVER were deprecated upstream, remove them (and FIXED_GCCVER itself) from the recipe and use "GCC" instead.

---
 meta/recipes-core/ovmf/ovmf_git.bb | 43 ++++++------------------------
 1 file changed, 8 insertions(+), 35 deletions(-)
meta/recipes-core/ovmf/ovmf_git.bb +8 -35
index f91f458006..25c857bdf9 100644
@@ -55,6 +55,7 @@ inherit deploy
 PARALLEL_MAKE = ""
 
 DEPENDS = "nasm-native acpica-native ovmf-native util-linux-native"
+DEPENDS:append:toolchain-clang = " lld-native"
 
 EDK_TOOLS_DIR = "edk2_basetools"
 
@@ -145,39 +146,13 @@ fix_toolchain:append:class-native() {
 export NASM_PREFIX_MAP = "--debug-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR}"
 export GCC_PREFIX_MAP = "${DEBUG_PREFIX_MAP} -Wno-stringop-overflow -Wno-maybe-uninitialized"
 
-GCC_VER = "$(${CC} -v 2>&1 | tail -n1 | awk '{print $3}')"
-
-fixup_target_tools() {
-    case ${1} in
-      4.4.*)
-        FIXED_GCCVER=GCC44
-        ;;
-      4.5.*)
-        FIXED_GCCVER=GCC45
-        ;;
-      4.6.*)
-        FIXED_GCCVER=GCC46
-        ;;
-      4.7.*)
-        FIXED_GCCVER=GCC47
-        ;;
-      4.8.*)
-        FIXED_GCCVER=GCC48
-        ;;
-      4.9.*)
-        FIXED_GCCVER=GCC49
-        ;;
-      *)
-        FIXED_GCCVER=GCC5
-        ;;
-    esac
-    echo ${FIXED_GCCVER}
-}
-
 do_compile:class-native() {
     oe_runmake -C ${S}/BaseTools
 }
 
+TARGET_TOOLS ?= "GCC"
+TARGET_TOOLS:toolchain-clang = "CLANGDWARF"
+
 do_compile:class-target() {
     export LFLAGS="${LDFLAGS}"
     PARALLEL_JOBS="${@oe.utils.parallel_make_argument(d, '-n %d')}"
@@ -198,13 +173,12 @@ do_compile:class-target() {
     rm -rf ${WORKDIR}/ovmf
     mkdir ${WORKDIR}/ovmf
     OVMF_DIR_SUFFIX="X64"
-    FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
-    bbnote FIXED_GCCVER is ${FIXED_GCCVER}
-    build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/${OVMF_BUILD_TYPE}_${FIXED_GCCVER}"
+    bbnote TARGET_TOOLS is ${TARGET_TOOLS}
+    build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/${OVMF_BUILD_TYPE}_${TARGET_TOOLS}"
 
     bbnote "Building without Secure Boot."
     rm -rf ${S}/Build/Ovmf$OVMF_DIR_SUFFIX
-    ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b ${OVMF_BUILD_TYPE} -t ${FIXED_GCCVER} ${PACKAGECONFIG_CONFARGS}
+    ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b ${OVMF_BUILD_TYPE} -t ${TARGET_TOOLS} ${PACKAGECONFIG_CONFARGS}
     ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.fd
     ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.code.fd
     ln ${build_dir}/FV/OVMF_VARS.fd ${WORKDIR}/ovmf/ovmf.vars.fd
@@ -214,7 +188,7 @@ do_compile:class-target() {
         # Repeat build with the Secure Boot flags.
         bbnote "Building with Secure Boot."
         rm -rf ${S}/Build/Ovmf$OVMF_DIR_SUFFIX
-        ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b ${OVMF_BUILD_TYPE} -t ${FIXED_GCCVER} ${PACKAGECONFIG_CONFARGS} ${OVMF_SECURE_BOOT_FLAGS}
+        ${S}/OvmfPkg/build.sh $PARALLEL_JOBS -a $OVMF_ARCH -b ${OVMF_BUILD_TYPE} -t ${TARGET_TOOLS} ${PACKAGECONFIG_CONFARGS} ${OVMF_SECURE_BOOT_FLAGS}
         ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/ovmf.secboot.fd
         ln ${build_dir}/FV/OVMF_CODE.fd ${WORKDIR}/ovmf/ovmf.secboot.code.fd
         ln ${build_dir}/${OVMF_ARCH}/EnrollDefaultKeys.efi ${WORKDIR}/ovmf/
@@ -277,4 +251,3 @@ do_deploy:class-target() {
 addtask do_deploy after do_compile before do_build
 
 BBCLASSEXTEND = "native"
-TOOLCHAIN = "gcc"
Signature · 1 line
2.47.0
#4 lore raw
In reply to João Marcos Costa

I forgot to add the 'v2' tag, so please ignore this series and let me re-send it.

Quoted 29 lines · João Marcos Costa

Hello,

This patch series contains, first of all, a slight issue with PACKAGECONFIG previously evoked by Q. Schulz (cc'ed) in the mailing list.

The main point of the series is the support for Clang, which I tested with the latest version llvm/clang available as of now in oe-core. I also tested the result with the help of runqemu.

Moreover, some of the settings are obsolete and can be removed.

Best regards,

---

Changes since v1:
- clarify the behaviour change in PACKAGECONFIG's assignment
- in the second patch, make it clear that the flag is obsolete because it was already upstreamed (and is part of the currently used tag), not because of GCC's version

João Marcos Costa (3):
ovmf: simplify PACKAGECONFIG's default value
ovmf: drop upstreamed BUILD_CFLAGS setting
ovmf: add support for Clang toolchain

  meta/recipes-core/ovmf/ovmf_git.bb | 51 ++++++------------------------
  1 file changed, 9 insertions(+), 42 deletions(-)
Signature · 2 lines
Best regards,
João Marcos Costa