#!/bin/mkpkg # description: Xen hypervisor # url: https://xenproject.org name=xen version=4.22.0 release=2 depends=() makedeps=(python3 iasl perl) source=(https://downloads.xenproject.org/release/xen/$version/xen-$version.tar.gz https://ftp.gnu.org/gnu/binutils/binutils-2.46.0.tar.xz xsa477.patch xsa479.patch xsa480.patch xsa481.patch hotplug-vif-vtrill.patch hotplug-Linux-iscsi-block-handle-lun-1.patch) sha256sums=( "b2a14ca369e3cf26f123a455b1603f3962ae9fcee0b8640a9cc33879de198223" "d75a94f4d73e7a4086f7513e67e439e8fcdcbb726ffe63f4661744e6256b2cf2" "025783441d7db846e717a1e48547b0db7a36fcc6af652b688524c684f0c3d2a7" "82369898d0287e69272d0d65fb0e6be5fd0106bda19cedb3c9f6e75688f6fb4b" "578f8fec3f34656e085419f6376d43987ffd6ed32e067b4024d3c83ce03a5901" "148147e4545a4670578c0f24aa136f67bc203c7b18ec980b8cc80cfbb04ace68" "c3994774305807f607742b6d49691c913fe3455cf1ab871254bc8fe2a4906b43" "a9dfb68d615aa4ee9e1137fa6bcc69a291e9603202db40bb343d50caf30dae3d" ) build() { # Build private GNU ld — needed for PE/EFI link (x86_64-pep target) cd $SRC/binutils-2.46.0 CONFIG_SHELL=/bin/bash ./configure \ --prefix=$SRC/ld-local \ --disable-nls \ --disable-multilib \ --disable-werror \ --disable-gdb \ --disable-gdbserver \ --disable-gold \ --disable-gprofng \ --disable-gas \ --disable-sim \ --disable-libdecnumber \ --disable-readline \ --enable-ld \ --enable-targets=x86_64-linux,x86_64-pep \ --with-system-zlib \ CC=clang CXX=clang++ make make install export PATH="$SRC/ld-local/bin:$PATH" # Verify GNU ld has PE support before proceeding ld -V | grep -i "pep\|pe-x86" || { echo "GNU ld missing PE support"; exit 1; } cd $SRC/xen-$version for p in $SRC/xsa477.patch $SRC/xsa479.patch $SRC/xsa480.patch $SRC/xsa481.patch \ $SRC/hotplug-vif-vtrill.patch $SRC/hotplug-Linux-iscsi-block-handle-lun-1.patch; do [ -f "$p" ] && patch -N -p1 < "$p" || true done unset CFLAGS CXXFLAGS CPPFLAGS ASFLAGS LDFLAGS AR OBJCOPY RANLIB CC LD LANG LC_ALL # These two seds are a pair and the order is load-bearing. # xen/Makefile:293 has '-Werror=unknown-warning-option'; the # strip below reduces it to '=unknown-warning-option', and the # second sed rewrites that to '-Wno-unknown-warning-option'. # Net effect: clang IGNORES warning flags it does not know # instead of erroring on them. Xen adds GCC-only flags via # cc-option-add (e.g. -Wflex-array-member-not-at-end at line # 404), and cc-option probes without -Werror=..., so clang # accepts them at probe time and would reject them at compile # time. Do not 'repair' the strip to preserve -Werror= — that # re-arms the exact error this exists to disarm. find . \( -name '*.mk' -o -name 'Make*' \) \ -exec sed -i -e 's/-Werror//g' {} + sed -i 's/CLANG_FLAGS += =unknown-warning-option/CLANG_FLAGS += -Wno-unknown-warning-option/' \ xen/Makefile sed -e '/-include $(XEN_ROOT)\/.config/d' -i Config.mk sed -i 's/efi-nr-fixups :=.*/efi-nr-fixups := 2/' xen/arch/x86/arch.mk # -fno-jump-tables: clang emits switch tables into # .data.rel.ro..Lswitch.table.*, and Rules.mk:277 rejects any section # outside the init sections when building a .init.o (seen on # common/unzstd.o). EXTRA_CFLAGS_XEN_CORE is the hook xen/Makefile:421 # documents for this; it is appended last, so it also overrides # anything set earlier. Needed on both invocations — install-xen # re-enters the build. make \ CC=clang CXX=clang++ LD=ld \ AR=llvm-ar RANLIB=llvm-ranlib OBJDUMP=llvm-objdump \ HOSTCC=clang HOSTCXX=clang++ \ clang=y XEN_TARGET_ARCH=x86_64 \ EXTRA_CFLAGS_XEN_CORE="-fno-jump-tables" \ xen make \ CC=clang CXX=clang++ LD=ld \ AR=llvm-ar RANLIB=llvm-ranlib OBJDUMP=llvm-objdump \ HOSTCC=clang HOSTCXX=clang++ \ clang=y XEN_TARGET_ARCH=x86_64 \ EXTRA_CFLAGS_XEN_CORE="-fno-jump-tables" \ LIBDIR=lib \ EFI_DIR=/boot \ INSTALL_EFI_STRIP=1 \ DESTDIR=$PKG \ install-xen # Xen's EFI loader walks a config name back through version # components (xen-4.22.0.cfg -> xen-4.22.cfg -> xen-4.cfg -> # xen.cfg), which is what the version-stripped symlinks are # for. The ESP is FAT and has no symlinks, and limine-sync # mirrors regular files only, so drop them all. Generic on # purpose: per-version 'rm -f' lines went stale at each bump. find $PKG/boot -type l -delete rm -rf $PKG/usr } signify() { untrusted comment: public key RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3 } # vim: filetype=sh