arm/hafnium: add missing pkg-config dependency
PATCH 1/8 arm/hafnium: add missing pkg-config dependency
pkg-config-native is used, so we best depend on it.
--- meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb +1 -1
@@ -5,7 +5,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=782b40c14bad5294672c500501edc103" PACKAGE_ARCH = "${MACHINE_ARCH}" -inherit deploy python3native +inherit deploy python3native pkgconfig SRC_URI = "gitsm://git.trustedfirmware.org/hafnium/hafnium.git;protocol=https \ file://pkg-config-native.patch"
Signature · 1 line
2.25.1
PATCH 2/8 arm/hafnium: remove python symlink workaround
Hafnium drops a python symlink into HOSTTOOLS_DIR, which is visible to all recipes, so building hafnium changes the build environment.
Hafnium, since 6c63a26 (2.4 onwards), uses python3 in its own hashbangs. The prebuilt clang currently uses python hangbangs but this is fixed in git, and can be temporarily worked around with a patch instead.
--- .../hafnium/hafnium/hashbang.patch | 34 +++++++++++++++++++ meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb | 7 +--- 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 meta-arm/recipes-bsp/hafnium/hafnium/hashbang.patch
meta-arm/recipes-bsp/hafnium/hafnium/hashbang.patch new file +34 -0
@@ -0,0 +1,34 @@ +Update Clang hashbangs to call python3 instead of python, as that doesn't exist +in our hosttools. + +Upstream-Status: Backport [partial, fixed upstream] +Signed-off-by: Ross Burton <[email protected]> + +diff --git a/linux-x64/clang/bin/clang b/prebuilts/linux-x64/clang/bin/clang +index 081cb20a..ce9cc267 100755 +--- a/prebuilts/linux-x64/clang/bin/clang ++++ b/prebuilts/linux-x64/clang/bin/clang +@@ -1 +1 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 +diff --git a/prebuilts/linux-x64/clang/bin/clang++ b/prebuilts/linux-x64/clang/bin/clang++ +index 081cb20a..ce9cc267 100755 +--- a/prebuilts/linux-x64/clang/bin/clang++ ++++ b/prebuilts/linux-x64/clang/bin/clang++ +@@ -1 +1 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 +diff --git a/prebuilts/linux-x64/clang/bin/clang-tidy b/prebuilts/linux-x64/clang/bin/clang-tidy +index 081cb20a..ce9cc267 100755 +--- a/prebuilts/linux-x64/clang/bin/clang-tidy ++++ b/prebuilts/linux-x64/clang/bin/clang-tidy +@@ -1 +1 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 +diff --git a/prebuilts/linux-x64/clang/bin/scan-view b/prebuilts/linux-x64/clang/bin/scan-view +index 6165432e..07effbca 100755 +--- a/prebuilts/linux-x64/clang/bin/scan-view ++++ b/prebuilts/linux-x64/clang/bin/scan-view +@@ -1 +1 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3
meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb +1 -6
@@ -8,6 +8,7 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" inherit deploy python3native pkgconfig SRC_URI = "gitsm://git.trustedfirmware.org/hafnium/hafnium.git;protocol=https \ + file://hashbang.patch \ file://pkg-config-native.patch" SRCREV = "3a149eb219467c0d9336467ea1fb9d3fb65da94b" S = "${WORKDIR}/git"
@@ -33,12 +34,6 @@ DEPENDS = "bison-native bc-native openssl-native" # set project to build EXTRA_OEMAKE += "PROJECT=${HAFNIUM_PROJECT}" -do_compile:prepend() { - # Hafnium expects 'python'. Create symlink python to python3 - real=$(which ${PYTHON}) - ln -snf $real $(dirname $real)/python -} - do_install() { install -d -m 755 ${D}/firmware for bldfile in ${HAFNIUM_INSTALL_TARGET}; do
Signature · 1 line
2.25.1
PATCH 3/8 arm/hafnium: do out-of-tree builds
In reply to Ross BurtonSet OUT_DIR to do out-of-tree builds in a directory we control, so we can wipe it on rebuilds.
--- meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb +14 -8
@@ -12,6 +12,7 @@ SRC_URI = "gitsm://git.trustedfirmware.org/hafnium/hafnium.git;protocol=https \ file://pkg-config-native.patch" SRCREV = "3a149eb219467c0d9336467ea1fb9d3fb65da94b" S = "${WORKDIR}/git" +B = "${WORKDIR}/build" COMPATIBLE_MACHINE ?= "invalid"
@@ -21,10 +22,6 @@ HAFNIUM_PROJECT ?= "reference" # Platform must be set for each machine HAFNIUM_PLATFORM ?= "invalid" -# hafnium build directory -# Append _clang as the build rule in hafnium adds this to the platform name. -HAFNIUM_BUILD_DIR_PLAT = "out/${HAFNIUM_PROJECT}/${HAFNIUM_PLATFORM}_clang" - # do_deploy will install everything listed in this variable. It is set by # default to hafnium HAFNIUM_INSTALL_TARGET ?= "hafnium"
@@ -34,20 +31,29 @@ DEPENDS = "bison-native bc-native openssl-native" # set project to build EXTRA_OEMAKE += "PROJECT=${HAFNIUM_PROJECT}" +EXTRA_OEMAKE += "OUT_DIR=${B}" + +do_configure[cleandirs] += "${B}" + +do_compile() { + oe_runmake -C ${S} +} + do_install() { + cd ${B}/${HAFNIUM_PLATFORM}_clang install -d -m 755 ${D}/firmware for bldfile in ${HAFNIUM_INSTALL_TARGET}; do processed="0" - if [ -f ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.bin ]; then + if [ -f $bldfile.bin ]; then echo "Install $bldfile.bin" - install -m 0755 ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.bin \ + install -m 0755 $bldfile.bin \ ${D}/firmware/$bldfile-${HAFNIUM_PLATFORM}.bin ln -sf $bldfile-${HAFNIUM_PLATFORM}.bin ${D}/firmware/$bldfile.bin processed="1" fi - if [ -f ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.elf ]; then + if [ -f $bldfile.elf ]; then echo "Install $bldfile.elf" - install -m 0755 ${S}/${HAFNIUM_BUILD_DIR_PLAT}/$bldfile.elf \ + install -m 0755 $bldfile.elf \ ${D}/firmware/$bldfile-${HAFNIUM_PLATFORM}.elf ln -sf $bldfile-${HAFNIUM_PLATFORM}.elf ${D}/firmware/$bldfile.elf processed="1"
Signature · 1 line
2.25.1
PATCH 4/8 arm/hafnium: clean up install
In reply to Ross BurtonHafnium hard-codes a lot of this logic, so do_install can be simplified.
--- meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb +1 -19
@@ -43,25 +43,7 @@ do_install() { cd ${B}/${HAFNIUM_PLATFORM}_clang install -d -m 755 ${D}/firmware for bldfile in ${HAFNIUM_INSTALL_TARGET}; do - processed="0" - if [ -f $bldfile.bin ]; then - echo "Install $bldfile.bin" - install -m 0755 $bldfile.bin \ - ${D}/firmware/$bldfile-${HAFNIUM_PLATFORM}.bin - ln -sf $bldfile-${HAFNIUM_PLATFORM}.bin ${D}/firmware/$bldfile.bin - processed="1" - fi - if [ -f $bldfile.elf ]; then - echo "Install $bldfile.elf" - install -m 0755 $bldfile.elf \ - ${D}/firmware/$bldfile-${HAFNIUM_PLATFORM}.elf - ln -sf $bldfile-${HAFNIUM_PLATFORM}.elf ${D}/firmware/$bldfile.elf - processed="1" - fi - if [ "$processed" = "0" ]; then - bberror "Unsupported HAFNIUM_INSTALL_TARGET target $bldfile" - exit 1 - fi + install -m 0755 $bldfile.bin $bldfile.elf ${D}/firmware/ done }
Signature · 1 line
2.25.1
PATCH 5/8 arm/hafnium: package the ELF in hafnium-dbg
In reply to Ross BurtonThe .elf is only useful for debugging, so put it in the dbg package.
--- meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb +3 -2
@@ -47,10 +47,11 @@ do_install() { done } -FILES:${PN} = "/firmware" +FILES:${PN} = "/firmware/*.bin" +FILES:${PN}-dbg = "/firmware/*.elf" SYSROOT_DIRS += "/firmware" -# skip QA tests: {'ldflags'} INSANE_SKIP:${PN} = "ldflags" +INSANE_SKIP:${PN}-dbg = "ldflags" do_deploy() { cp -rf ${D}/firmware/* ${DEPLOYDIR}/
Signature · 1 line
2.25.1
PATCH 6/8 arm: add recipe for gn
In reply to Ross BurtonThis is a Google build tool used by Hafnium. It will end up in meta-oe eventually, but until then it can live here.
--- meta-arm/recipes-devtools/gn/gn_git.bb | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 meta-arm/recipes-devtools/gn/gn_git.bb
meta-arm/recipes-devtools/gn/gn_git.bb new file +34 -0
@@ -0,0 +1,34 @@ +SUMMARY = "GN is a meta-build system that generates build files for Ninja" +DEPENDS += "ninja-native" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=0fca02217a5d49a14dfe2d11837bb34d" + +SRC_URI = "git://gn.googlesource.com/gn;protocol=https;branch=main" +SRCREV = "69ec4fca1fa69ddadae13f9e6b7507efa0675263" +PV = "0+git${SRCPV}" + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +# TODO: os map like meson. mingw32 -> mingw + +do_configure[cleandirs] += "${B}" +do_configure() { + python3 ${S}/build/gen.py \ + --platform=${TARGET_OS} \ + --host=${HOST_OS} \ + --out-path=${B} \ + --no-strip +} + +do_compile() { + ninja -C ${B} --verbose +} + +do_install() { + install -d ${D}${bindir} + install ${B}/gn ${D}${bindir} +} + +BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.25.1
PATCH 7/8 arm/hafnium: use our gn/ninja/dtc
In reply to Ross BurtonInstead of relying on the prebuilt GN/Ninja/dtc binaries that come with Hafnium via the hafnium-prebuilts repository, use the recipes that we build.
We still need to use the prebuilt compilers, but that is being worked on upstream.
--- .../recipes-bsp/hafnium/hafnium/native-dtc.patch | 14 ++++++++++++++ meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb | 10 +++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 meta-arm/recipes-bsp/hafnium/hafnium/native-dtc.patch
meta-arm/recipes-bsp/hafnium/hafnium/native-dtc.patch new file +14 -0
@@ -0,0 +1,14 @@ +diff --git a/build/image/dtc.py b/build/image/dtc.py +index d0778186..a5d831be 100755 +--- a/build/image/dtc.py ++++ b/build/image/dtc.py +@@ -18,6 +18,9 @@ DTC_ROOT = os.path.join(HF_ROOT, "prebuilts", "linux-x64", "dtc") + DTC = os.path.join(DTC_ROOT, "dtc") + FDTOVERLAY = os.path.join(DTC_ROOT, "fdtoverlay") + ++DTC = "dtc" ++FDTOVERLAY = "fdtoverlay" ++ + def cmd_compile(args): + exec_args = [ + DTC,
meta-arm/recipes-bsp/hafnium/hafnium_2.5.bb +7 -3
@@ -1,5 +1,7 @@ SUMMARY = "Hafnium" DESCRIPTION = "A reference Secure Partition Manager (SPM) for systems that implement the Armv8.4-A Secure-EL2 extension" +DEPENDS = "gn-native ninja-native bison-native bc-native dtc-native openssl-native" + LICENSE = "BSD-3-Clause & GPLv2" LIC_FILES_CHKSUM = "file://LICENSE;md5=782b40c14bad5294672c500501edc103"
@@ -9,7 +11,8 @@ inherit deploy python3native pkgconfig SRC_URI = "gitsm://git.trustedfirmware.org/hafnium/hafnium.git;protocol=https \ file://hashbang.patch \ - file://pkg-config-native.patch" + file://pkg-config-native.patch \ + file://native-dtc.patch" SRCREV = "3a149eb219467c0d9336467ea1fb9d3fb65da94b" S = "${WORKDIR}/git" B = "${WORKDIR}/build"
@@ -26,13 +29,14 @@ HAFNIUM_PLATFORM ?= "invalid" # default to hafnium HAFNIUM_INSTALL_TARGET ?= "hafnium" -DEPENDS = "bison-native bc-native openssl-native" - # set project to build EXTRA_OEMAKE += "PROJECT=${HAFNIUM_PROJECT}" EXTRA_OEMAKE += "OUT_DIR=${B}" +# Don't use prebuilt binaries for gn and ninja +EXTRA_OEMAKE += "GN=${STAGING_BINDIR_NATIVE}/gn NINJA=${STAGING_BINDIR_NATIVE}/ninja" + do_configure[cleandirs] += "${B}" do_compile() {
Signature · 1 line
2.25.1
PATCH 8/8 CI: build a proper TC0 image on x86-64
In reply to Ross Burton--- .gitlab-ci.yml | 4 ++++ ci/tc0.yml | 4 ++++ ci/tc1.yml | 4 ++++ 3 files changed, 12 insertions(+)
.gitlab-ci.yml +4 -0
@@ -186,9 +186,13 @@ sgi575: tc0: extends: .build + tags: + - x86_64 tc1: extends: .build + tags: + - x86_64 toolchains: extends: .build
ci/tc0.yml +4 -0
@@ -4,3 +4,7 @@ header: - base.yml machine: tc0 + +target: + - tc-artifacts-image + - perf
ci/tc1.yml +4 -0
@@ -4,3 +4,7 @@ header: - base.yml machine: tc1 + +target: + - tc-artifacts-image + - perf
Signature · 1 line
2.25.1