[meta-virtualization] [PATCH 1/7] xen: Define the standard values needed for stubdoms

Kurt Bodiker kurt.bodiker at braintrust-us.com
Mon Mar 5 07:35:01 PST 2018


From: kebodiker <kurt.bodiker at braintrust-us.com>

This commit introduces the stubdom.inc file that is required for each
recipe that is/will be built for Xen stubdomains. This file defines the
standard values to be used such as common dependencies, the version of
Xen that is being built by the separate Xen recipe, and unsets every
flag and build tool that is exported into the OE environment.

Xen stubdomains are cross-compiled with the MiniOS, which creates some
issues when trying to compile stubdomains in an OpenEmbedded
environment. To address these issues and to ensure the stubdoms are
built as Xen had intended, all of the build flags and build tools that
are exported into the environment by OE have been unset. Each of the new
recipes introduced here then implements the build flags and the tools as
though the build had been run in the bare-metal environment.

Signed-off-by: Kurt Bodiker <kurt.bodiker at braintrust-us.com>
---
 recipes-extended/xen/stubdom.inc | 141 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 141 insertions(+)
 create mode 100644 recipes-extended/xen/stubdom.inc

diff --git a/recipes-extended/xen/stubdom.inc b/recipes-extended/xen/stubdom.inc
new file mode 100644
index 0000000..4bc556d
--- /dev/null
+++ b/recipes-extended/xen/stubdom.inc
@@ -0,0 +1,141 @@
+# Copyright (C) 2017 Kurt Bodiker <kurt.bodiker at braintrust-us.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+require xen-arch.inc
+
+# Don't want to use the default tools and dependencies from OE
+# and many of these recipes build static instead of shared libraries
+INHIBIT_DEFAULT_DEPS = "1"
+INHIBIT_PACKAGE_STRIP = "0"
+EXCLUDE_FROM_SHLIBS = "1"
+
+# Couldn't find any other way to access the version of Xen used as a dependency. 
+# This version number needs changed to match version of Xen recipe  used in builds.
+XEN_VERSION = "4.9.0"
+
+
+# convenience variable that may or may not be needed for each recipe
+TRANSLATED_PV = "${@d.getVar('PV').replace('.', '_')}"
+
+# mini-os source code for everyone
+SRC_URI += "\
+    git://xenbits.xen.org/mini-os.git;protocol=git;rev=xen-RELEASE-${XEN_VERSION};nobranch=1;destsuffix=mini-os;name=mini-os \
+"
+
+# base set of dependencies
+DEPENDS += "\
+    xen \
+    lwip \
+    virtual/${TARGET_PREFIX}gcc \
+"
+
+
+export XEN_TARGET_ARCH="${@map_xen_arch(d.getVar('TARGET_ARCH'), d)}"
+export XEN_COMPILE_ARCH="${@map_xen_arch(d.getVar('BUILD_ARCH'), d)}"
+
+# Not sure if we need to (or even can) support 32-bit stubdoms
+# If we we do not need to support the 32-bit environment, then this section and the 
+# export statement afterwards can be removed. 
+python () {
+    gnu_dict = {
+            'x86_32': 'i686',
+            'x86_64': 'x86_64',
+        }
+        
+    if d.expand('${XEN_TARGET_ARCH}') == 'x86_32':
+        d.setVar("GNU_TARGET_ARCH",gnu_dict[d.expand('${XEN_TARGET_ARCH}')])
+        d.setVar("PACKAGE_ARCH","core2-32")
+    elif d.expand('${XEN_TARGET_ARCH}') == 'x86_64':
+        d.setVar("GNU_TARGET_ARCH",gnu_dict[d.expand('${XEN_TARGET_ARCH}')])
+}
+export GNU_TARGET_ARCH
+
+# Base set of CPPFLAGS, CFLAGS needed for each component used to build MiniOS-based stubdoms
+# LDFLAGS are only used when building stubdoms, so only used in stubdom recipes
+# Generic name given because each library uses DEF_, BUILD_, TARGET_, and xxxFLAGS differently
+STUBDOM_CPPFLAGS += "-isystem ${WORKDIR}/mini-os/include"
+STUBDOM_CPPFLAGS += "-D__MINIOS__ -DHAVE_LIBC"
+STUBDOM_CPPFLAGS += "-isystem ${WORKDIR}/mini-os/include/posix"
+STUBDOM_CPPFLAGS += "-isystem ${RECIPE_SYSROOT}/usr/include/xenstore-compat"
+STUBDOM_CPPFLAGS += "-isystem ${WORKDIR}/mini-os/include/x86 -isystem ${WORKDIR}/mini-os/include/x86/${XEN_TARGET_ARCH}"
+STUBDOM_CPPFLAGS += "-U __linux__ -U __FreeBSD__ -U __sun__"
+STUBDOM_CPPFLAGS += "-nostdinc"
+CPPFLAGS_INCLUDE_DIR = "-isystem ${RECIPE_SYSROOT}/cross-root-${XEN_TARGET_ARCH}/${GNU_TARGET_ARCH}-xen-elf/include"
+STUBDOM_CPPFLAGS += "${CPPFLAGS_INCLUDE_DIR}"
+STUBDOM_CPPFLAGS += "-isystem ${RECIPE_SYSROOT}/cross-root-${XEN_TARGET_ARCH}/lwip/include -isystem ${RECIPE_SYSROOT}/cross-root-${XEN_TARGET_ARCH}/lwip/include/ipv4"
+STUBDOM_CPPFLAGS += "-isystem ${RECIPE_SYSROOT}/usr/include/xen"
+
+STUBDOM_CFLAGS += "-mno-red-zone -O1 -fno-omit-frame-pointer -m64 -fno-reorder-blocks -fno-asynchronous-unwind-tables -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -fno-stack-protector -fno-exceptions"
+
+STUBDOM_LDFLAGS = "-nostdlib -L${RECIPE_SYSROOT}/cross-root-${XEN_TARGET_ARCH}/${GNU_TARGET_ARCH}-xen-elf/lib"
+
+# unset EVERYTHING from the OE environment. Weird things happen when these are exported into the environment.
+unset CFLAGS
+unset BUILD_CFLAGS
+unset TARGET_CFLAGS
+unset CFLAGS_FOR_BUILD
+
+unset CPPFLAGS
+unset BUILD_CPPFLAGS
+unset TARGET_CPPFLAGS
+unset CPPFLAGS_FOR_BUILD
+
+unset LDFLAGS
+unset BUILD_LDFLAGS
+unset TARGET_LDFLAGS
+unset LDFLAGS_FOR_BUILD
+
+unset CXXFLAGS
+unset TARGET_CXXFLAGS
+unset BUILD_CXXFLAGS
+unset CXXFLAGS_FOR_BUILD
+
+unset BUILD_CC
+unset BUILD_CPP
+unset BUILD_CXX
+unset BUILD_LD
+unset BUILD_AR
+unset BUILD_AS
+unset BUILD_CCLD
+unset BUILD_FC
+unset BUILD_RANLIB
+unset BUILD_NM
+unset BUILD_STRIP
+unset BUILD_READELF
+unset BUILD_OBJCOPY
+unset BUILD_OBJDUMP
+unset CC
+unset CPP
+unset CXX
+unset LD
+unset AR
+unset AS
+unset NM
+unset RANLIB
+unset STRIP
+unset STRINGS
+unset READELF
+unset OBJCOPY
+unset OBJDUMP
+unset READELF
+unset CCLD
+unset FC
+
+# Need to redefine these for stubdom-related builds. It all starts because of the prefix newlib 
+# and then continues because we don't want to cross-contaminate stubdom-related recipes with 
+# headers and libraries in the OE-defined locations
+export prefix="/cross-root-${XEN_TARGET_ARCH}"
+export includedir="${prefix}/${GNU_TARGET_ARCH}-xen-elf/include"
+export libdir="${prefix}/${GNU_TARGET_ARCH}-xen-elf/lib"
+export libexecdir="${libdir}"
+export STAGING_INCDIR
+export STAGING_LIBDIR
+
+# These values need defined to trigger some values in the Makefiles
+export debug="y"
+export stubdom="y"
+export XEN_OS="MiniOS"
+
+do_configure_prepend() {
+    ${MAKE} -C ${WORKDIR}/mini-os links
+}
-- 
2.14.2


-- 

*This email and all attachments are considered confidential and the 
proprietary information of BrainTrust Holdings.  Unauthorized disclosure is 
prohibited.  *


More information about the meta-virtualization mailing list