diff --git a/distro/yocto/meta-salmanoff/conf/layer.conf b/distro/yocto/meta-salmanoff/conf/layer.conf new file mode 100644 index 0000000..fdb37d5 --- /dev/null +++ b/distro/yocto/meta-salmanoff/conf/layer.conf @@ -0,0 +1,17 @@ +BBPATH .= ":${LAYERDIR}" + +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "salmanoff" +BBFILE_PATTERN_salmanoff = "^${LAYERDIR}/" +BBFILE_PRIORITY_salmanoff = "10" + +LAYERSERIES_COMPAT_salmanoff = "wrynose" + +# Salmanoff requires shared Boost.System (< 1.89). Pin 1.86 from this layer. +BBMASK += ".*/boost_1.90.0.bb" +BBMASK += ".*/boost-build-native_1.90.0.bb" +PREFERRED_VERSION_boost = "1.86.%" +PREFERRED_VERSION_boost-build-native = "1.86.%" + diff --git a/distro/yocto/meta-salmanoff/conf/salmanoff-local.inc b/distro/yocto/meta-salmanoff/conf/salmanoff-local.inc new file mode 100644 index 0000000..f3f92fb --- /dev/null +++ b/distro/yocto/meta-salmanoff/conf/salmanoff-local.inc @@ -0,0 +1,3 @@ +# Layer-local build settings (require from build/conf/local.conf). +# Enables Mesa Rusticl so libopencl-mesa provides a software OpenCL ICD (llvmpipe). +DISTRO_FEATURES:append = " opencl" diff --git a/distro/yocto/meta-salmanoff/recipes-core/images/salmanoff-image.bb b/distro/yocto/meta-salmanoff/recipes-core/images/salmanoff-image.bb new file mode 100644 index 0000000..a8dfadf --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-core/images/salmanoff-image.bb @@ -0,0 +1,22 @@ +require recipes-core/images/core-image-minimal.bb + +SUMMARY = "Salmanoff runtime image" + +IMAGE_FEATURES += "ssh-server-openssh" + +IMAGE_INSTALL:append = " \ + rseqsliceprobe \ + iproute2 \ + boost-system \ + boost-log \ + libcamera \ + opencl-icd-loader \ + libopencl-mesa \ + libgallium \ + clinfo \ + v4l-utils \ + salmanoff-rusticl-env \ + liburing \ + salmanoff \ +" + diff --git a/distro/yocto/meta-salmanoff/recipes-core/init-ifupdown/init-ifupdown/salmanoff-interfaces b/distro/yocto/meta-salmanoff/recipes-core/init-ifupdown/init-ifupdown/salmanoff-interfaces new file mode 100644 index 0000000..474a52d --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-core/init-ifupdown/init-ifupdown/salmanoff-interfaces @@ -0,0 +1,12 @@ +# Salmanoff lab LAN — static eth0 for bridged QEMU on 10.42.0.0/24. +# Used with: runqemu salmanoff-image snapshot bridge= + +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet static + address 10.42.0.16 + netmask 255.255.255.0 + gateway 10.42.0.1 + dns-nameservers 10.42.0.1 diff --git a/distro/yocto/meta-salmanoff/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend b/distro/yocto/meta-salmanoff/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend new file mode 100644 index 0000000..776905c --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-core/init-ifupdown/init-ifupdown_1.0.bbappend @@ -0,0 +1,7 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append = " file://salmanoff-interfaces" + +do_install:append() { + install -m 0644 ${UNPACKDIR}/salmanoff-interfaces ${D}${sysconfdir}/network/interfaces +} diff --git a/distro/yocto/meta-salmanoff/recipes-kernel/linux/linux-yocto-dev.bbappend b/distro/yocto/meta-salmanoff/recipes-kernel/linux/linux-yocto-dev.bbappend new file mode 100644 index 0000000..6d1bf5d --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-kernel/linux/linux-yocto-dev.bbappend @@ -0,0 +1,4 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append = " file://rseq-slice-extension.cfg" + diff --git a/distro/yocto/meta-salmanoff/recipes-kernel/linux/linux-yocto-dev/rseq-slice-extension.cfg b/distro/yocto/meta-salmanoff/recipes-kernel/linux/linux-yocto-dev/rseq-slice-extension.cfg new file mode 100644 index 0000000..d5bffbc --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-kernel/linux/linux-yocto-dev/rseq-slice-extension.cfg @@ -0,0 +1,3 @@ +CONFIG_RSEQ=y +CONFIG_RSEQ_SLICE_EXTENSION=y + diff --git a/distro/yocto/meta-salmanoff/recipes-salmanoff/salmanoff/salmanoff.bb b/distro/yocto/meta-salmanoff/recipes-salmanoff/salmanoff/salmanoff.bb new file mode 100644 index 0000000..5c7fe45 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-salmanoff/salmanoff/salmanoff.bb @@ -0,0 +1,59 @@ +SUMMARY = "Salmanoff cognitive robotics runtime" +DESCRIPTION = "Sensor management runtime with Livox LiDAR support" +HOMEPAGE = "https://github.com/salmanoff/salmanoff" +LICENSE = "CLOSED" +LIC_FILES_CHKSUM = "file://${S}/LICENSE;beginline=1;endline=1;md5=7902e8a44912c18af1caf7499fb00176" + +DEPENDS += " \ + boost \ + liburing \ + libcamera \ + opencl-headers \ + virtual/libopencl1 \ + flex-native \ + bison-native \ +" + +RDEPENDS:${PN} += " \ + boost-system \ + boost-log \ + liburing \ + libcamera \ + opencl-icd-loader \ + libopencl-mesa \ + libgallium \ + salmanoff-rusticl-env \ +" + +SRC_URI = "gitsm://git@zbz-gitea-as-hayodea/hayodea/salmanoff.git;protocol=ssh;branch=clast" + +SRCREV = "63ff0aa264b62977c5d41781d7802628f771aac0" + +PV = "0.01.001" + +inherit cmake pkgconfig + +# Remap DWARF source paths from WORKDIR to the installed debug source tree. +DEBUG_PREFIX_MAP_EXTRA:append = " -fdebug-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR}" + +EXTRA_OECMAKE += " \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DENABLE_TESTS=OFF \ + -DENABLE_LIB_xcbXorg=OFF \ + -DENABLE_LIB_lcameraDev=ON \ + -DENABLE_STIMBUFFAPI_lcameraBuff=ON \ + -DENABLE_LCAMERADEV_TOOLS=OFF \ + -DCOMPILE_PCL_TOOLS=OFF \ +" + +FILES:${PN} += " \ + ${libdir}/lib*.so.* \ + ${datadir}/salmanoff \ +" + +do_install:append() { + # CMake installs .daps under share/salmanoff/devices; ensure bodies path exists. + if [ ! -d ${D}${datadir}/salmanoff/devices/bodies ]; then + install -d ${D}${datadir}/salmanoff/devices/bodies + fi +} diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost-1.86.0.inc b/distro/yocto/meta-salmanoff/recipes-support/boost/boost-1.86.0.inc new file mode 100644 index 0000000..b4e5b75 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost-1.86.0.inc @@ -0,0 +1,20 @@ +# The Boost web site provides free peer-reviewed portable +# C++ source libraries. The emphasis is on libraries which +# work well with the C++ Standard Library. The libraries are +# intended to be widely useful, and are in regular use by +# thousands of programmers across a broad spectrum of applications. +HOMEPAGE = "http://www.boost.org/" +LICENSE = "BSL-1.0 & MIT & Python-2.0" +LIC_FILES_CHKSUM = "file://LICENSE_1_0.txt;md5=e4224ccaecb14d942c71d31bef20d78c" + +BOOST_VER = "${@"_".join(d.getVar("PV").split("."))}" +BOOST_MAJ = "${@"_".join(d.getVar("PV").split(".")[0:2])}" +BOOST_P = "boost_${BOOST_VER}" + +SRC_URI = "https://archives.boost.io/release/${PV}/source/${BOOST_P}.tar.bz2" +SRC_URI[sha256sum] = "1bed88e40401b2cb7a1f76d4bab499e352fa4d0c5f31c0dbae64e24d34d7513b" + +UPSTREAM_CHECK_URI = "http://www.boost.org/users/download/" +UPSTREAM_CHECK_REGEX = "release/(?P.*)/source/" + +S = "${UNPACKDIR}/${BOOST_P}" diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost-build-native_1.86.0.bb b/distro/yocto/meta-salmanoff/recipes-support/boost/boost-build-native_1.86.0.bb new file mode 100644 index 0000000..742004d --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost-build-native_1.86.0.bb @@ -0,0 +1,26 @@ +SUMMARY = "Boost.Build" +DESCRIPTION = "B2 makes it easy to build C++ projects, everywhere." +HOMEPAGE = "https://github.com/boostorg/build" +SECTION = "devel" + +LICENSE = "BSL-1.0" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e4224ccaecb14d942c71d31bef20d78c" + +SRC_URI = "git://github.com/boostorg/build;protocol=https;branch=master;tag=boost-${PV}" +SRCREV = "4a52d8c06635435b64e31a56eaf7ca5dc912a71d" +PE = "1" + +UPSTREAM_CHECK_GITTAGREGEX = "boost-(?P(\d+(\.\d+)+))" + +inherit native + +do_compile() { + ./bootstrap.sh +} + +do_install() { + HOME=/var/run ./b2 install --prefix=${D}${prefix} +} + +# The build is either release mode (pre-stripped) or debug (-O0). +INSANE_SKIP:${PN} = "already-stripped" diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost.inc b/distro/yocto/meta-salmanoff/recipes-support/boost/boost.inc new file mode 100644 index 0000000..64a57dd --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost.inc @@ -0,0 +1,223 @@ +SUMMARY = "Free peer-reviewed portable C++ source libraries" +DESCRIPTION = "Provides free peer-reviewed portable C++ source libraries. The emphasis is on libraries which work well with the C++ \ +Standard Library. One goal is to establish 'existing practice' and \ +provide reference implementations so that the Boost libraries are suitable for eventual standardization. Some of the libraries have already been proposed for inclusion in the C++ Standards Committee's \ +upcoming C++ Standard Library Technical Report." +SECTION = "libs" +DEPENDS = "boost-build-native zlib bzip2" + +CVE_PRODUCT = "boost:boost" + +ARM_INSTRUCTION_SET:armv4 = "arm" +ARM_INSTRUCTION_SET:armv5 = "arm" + +B = "${WORKDIR}/build" +do_configure[cleandirs] = "${B}" + +BOOST_LIBS = "\ + atomic \ + charconv \ + chrono \ + container \ + context \ + contract \ + coroutine \ + date_time \ + exception \ + fiber \ + filesystem \ + graph \ + headers \ + iostreams \ + json \ + log \ + math \ + process \ + program_options \ + random \ + regex \ + serialization \ + system \ + test \ + thread \ + timer \ + type_erasure \ + url \ + wave \ + ${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \ + bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \ + " + +# optional libraries +PACKAGECONFIG ??= "locale python" +PACKAGECONFIG[locale] = ",,icu" +PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich" +PACKAGECONFIG[mpi] = ",,mpich" +PACKAGECONFIG[python] = ",,python3" + +inherit python3-dir +PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}" + +# Make a package for each library, plus -dev +PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}" +python __anonymous () { + packages = [] + extras = [] + pn = d.getVar("PN") + mlprefix = d.getVar("MLPREFIX") + for lib in d.getVar('BOOST_LIBS').split(): + extras.append("--with-%s" % lib) + pkg = "%s-%s" % (d.getVar("BPN"), lib.replace("_", "-")) + if "-native" in pn: + pkg = pkg + "-native" + packages.append(mlprefix + pkg) + if not d.getVar("FILES:%s%s" % (mlprefix, pkg)): + d.setVar("FILES:%s%s" % (mlprefix, pkg), "${libdir}/libboost_%s*.so.*" % lib) + + d.setVar("BOOST_PACKAGES", " ".join(packages)) + d.setVar("BJAM_EXTRA", " ".join(extras)) +} + +# Override the contents of specific packages +FILES:${PN}-graph_parallel = "${libdir}/libboost_graph_parallel.so.*" +FILES:${PN}-locale = "${libdir}/libboost_locale.so.*" +FILES:${PN}-mpi = "${libdir}/mpi.so ${libdir}/libboost_mpi*.so.*" +FILES:${PN}-serialization = "${libdir}/libboost_serialization*.so.* \ + ${libdir}/libboost_wserialization*.so.*" +FILES:${PN}-test = "${libdir}/libboost_prg_exec_monitor*.so.* \ + ${libdir}/libboost_unit_test_framework*.so.*" + +# -dev last to pick up the remaining stuff +PACKAGES += "${PN}-dev ${PN}-staticdev" +FILES:${PN}-dev = "${includedir} ${libdir}/libboost_*.so ${libdir}/cmake" +FILES:${PN}-staticdev = "${libdir}/libboost_*.a" + +# "boost" is a metapackage which pulls in all boost librabries +PACKAGES += "${PN}" +FILES:${PN} = "" +ALLOW_EMPTY:${PN} = "1" +RRECOMMENDS:${PN} += "${BOOST_PACKAGES}" +RRECOMMENDS:${PN}:class-native = "" + +# to avoid GNU_HASH QA errors added LDFLAGS to ARCH; a little bit dirty but at least it works +TARGET_CC_ARCH += "${LDFLAGS}" + +# Oh yippee, a new build system, it's sooo cooool I could eat my own +# foot. inlining=on lets the compiler choose, I think. At least this +# stuff is documented... +# NOTE: if you leave on then in a debug build the build sys +# objcopy will be invoked, and that won't work. Building debug apparently +# requires hacking gcc-tools.jam +# +# Sometimes I wake up screaming. Famous figures are gathered in the nightmare, +# Steve Bourne, Larry Wall, the whole of the ANSI C committee. They're just +# standing there, waiting, but the truely terrifying thing is what they carry +# in their hands. At first sight each seems to bear the same thing, but it is +# not so for the forms in their grasp are ever so slightly different one from +# the other. Each is twisted in some grotesque way from the other to make each +# an unspeakable perversion impossible to perceive without the onset of madness. +# True insanity awaits anyone who perceives all of these horrors together. +# +# Quotation marks, there might be an easier way to do this, but I can't find +# it. The problem is that the user.hpp configuration file must receive a +# pre-processor macro defined as the appropriate string - complete with "'s +# around it. (<> is a possibility here but the danger to that is that the +# failure case interprets the < and > as shell redirections, creating +# random files in the source tree.) +# +#bjam: '-DBOOST_PLATFORM_CONFIG=\"config\"' +#do_compile: '-sGCC=... '"'-DBOOST_PLATFORM_CONFIG=\"config\"'" +SQD = '"' +EQD = '\"' +#boost.bb: "... '-sGCC=... '${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}config${EQD}'${SQD} ..." +BJAM_CONF = "${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}boost/config/platform/${TARGET_OS}.hpp${EQD}'${SQD}" + +BJAM_TOOLS = "--ignore-site-config \ + '-sTOOLS=gcc' \ + '-sGCC=${CC} '${BJAM_CONF} \ + '-sGXX=${CXX} '${BJAM_CONF} \ + '-sGCC_INCLUDE_DIRECTORY=${STAGING_INCDIR}' \ + '-sGCC_STDLIB_DIRECTORY=${STAGING_LIBDIR}' \ + '-sBUILD=release space multi on off' \ + '-sPYTHON_ROOT=${PYTHON_ROOT}' \ + '--layout=system' \ + " + +# use PARALLEL_MAKE to speed up the build +BOOST_PARALLEL_MAKE = "${@oe.utils.parallel_make_argument(d, '-j%d')}" +BJAM_OPTS = '${BOOST_PARALLEL_MAKE} -d+2 -q \ + ${BJAM_TOOLS} \ + -sBOOST_BUILD_USER_CONFIG=${WORKDIR}/user-config.jam \ + -sICU_PATH=${STAGING_EXECPREFIXDIR} \ + --build-dir=${B} \ + --disable-icu \ + ${BJAM_EXTRA}' + +# Native compilation of bzip2 isn't working +BJAM_OPTS:append:class-native = ' -sNO_BZIP2=1' + +# Adjust the build for x32 +BJAM_OPTS:append:x86-x32 = " abi=x32 address-model=64" + +# cross compiling for arm fails to detect abi, so provide some help +BJAM_OPTS:append:arm = " abi=aapcs architecture=arm" +BJAM_OPTS:append:aarch64 = " abi=aapcs address-model=64 architecture=arm" + +do_configure() { + cd ${S} + cp -f ${S}/boost/config/platform/linux.hpp ${S}/boost/config/platform/linux-gnueabi.hpp + + # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation. + rm -f ${WORKDIR}/user-config.jam + echo 'using gcc : : ${CXX} : "${CFLAGS}" "${CXXFLAGS}" "${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam + + # If we want Python then we need to tell Boost *exactly* where to find it + if ${@bb.utils.contains('BOOST_LIBS', 'python', 'true', 'false', d)}; then + echo "using python : ${PYTHON_BASEVERSION} : ${STAGING_DIR_HOST}${bindir}/python3 : ${STAGING_DIR_HOST}${includedir}/${PYTHON_DIR}${PYTHON_ABI} : ${STAGING_DIR_HOST}${libdir}/${PYTHON_DIR} ;" >> ${WORKDIR}/user-config.jam + fi + + if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then + echo "using mpi : : mpi ;" >> ${WORKDIR}/user-config.jam + fi + + CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=b2 --with-toolset=gcc + + # Boost can't be trusted to find Python on it's own, so remove any mention + # of it from the boost configuration + sed -i '/using python/d' ${S}/project-config.jam +} + +do_compile() { + cd ${S} + b2 ${BJAM_OPTS} \ + --prefix=${prefix} \ + --exec-prefix=${exec_prefix} \ + --libdir=${libdir} \ + --includedir=${includedir} \ + --debug-configuration +} + +do_install() { + cd ${S} + b2 ${BJAM_OPTS} \ + --libdir=${D}${libdir} \ + --includedir=${D}${includedir} \ + install + for lib in ${BOOST_LIBS}; do + if [ -e ${D}${libdir}/libboost_${lib}.a ]; then + ln -s libboost_${lib}.a ${D}${libdir}/libboost_${lib}-mt.a + fi + if [ -e ${D}${libdir}/libboost_${lib}.so ]; then + ln -s libboost_${lib}.so ${D}${libdir}/libboost_${lib}-mt.so + fi + done + + # Cmake files reference full paths to image + find ${D}${libdir}/cmake -type f | \ + grep 'cmake$' | \ + xargs -n 1 sed -e 's,${D}${libdir}/cmake,${libdir}/cmake,' -i + +} + +BBCLASSEXTEND = "native nativesdk" diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost/0001-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch b/distro/yocto/meta-salmanoff/recipes-support/boost/boost/0001-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch new file mode 100644 index 0000000..78f652f --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost/0001-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch @@ -0,0 +1,175 @@ +From f88354966fe3af33fd6d9ec889a8e3926b886a8a Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Tue, 18 Dec 2018 15:42:57 +0100 +Subject: [PATCH] Don't set up arch/instruction-set flags, we do that + +ourselves + +Upstream-Status: Inappropriate +Signed-off-by: Christopher Larson +Signed-off-by: Alexander Kanavin +--- + tools/build/src/tools/gcc.jam | 153 ---------------------------------- + 1 file changed, 153 deletions(-) + +diff --git a/tools/build/src/tools/gcc.jam b/tools/build/src/tools/gcc.jam +index b7825d4e6..ed7e39baf 100644 +--- a/tools/build/src/tools/gcc.jam ++++ b/tools/build/src/tools/gcc.jam +@@ -1144,156 +1144,3 @@ local rule cpu-flags ( toolset variable : architecture : instruction-set + : + $(architecture)/$(instruction-set) + : $(values) ; + } +- +- +-# Set architecture/instruction-set options. +-# +-# x86 and compatible +-# The 'native' option appeared in gcc 4.2 so we cannot safely use it as default. +-# Use i686 instead for 32-bit. +-toolset.flags gcc OPTIONS x86/32/ : -march=i686 ; +-cpu-flags gcc OPTIONS : x86 : native : -march=native ; +-cpu-flags gcc OPTIONS : x86 : i486 : -march=i486 ; +-cpu-flags gcc OPTIONS : x86 : i586 : -march=i586 ; +-cpu-flags gcc OPTIONS : x86 : i686 : -march=i686 ; +-cpu-flags gcc OPTIONS : x86 : pentium : -march=pentium ; +-cpu-flags gcc OPTIONS : x86 : pentium-mmx : -march=pentium-mmx ; +-cpu-flags gcc OPTIONS : x86 : pentiumpro : -march=pentiumpro ; +-cpu-flags gcc OPTIONS : x86 : pentium2 : -march=pentium2 ; +-cpu-flags gcc OPTIONS : x86 : pentium3 : -march=pentium3 ; +-cpu-flags gcc OPTIONS : x86 : pentium3m : -march=pentium3m ; +-cpu-flags gcc OPTIONS : x86 : pentium-m : -march=pentium-m ; +-cpu-flags gcc OPTIONS : x86 : pentium4 : -march=pentium4 ; +-cpu-flags gcc OPTIONS : x86 : pentium4m : -march=pentium4m ; +-cpu-flags gcc OPTIONS : x86 : prescott : -march=prescott ; +-cpu-flags gcc OPTIONS : x86 : nocona : -march=nocona ; +-cpu-flags gcc OPTIONS : x86 : core2 : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : conroe : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : conroe-xe : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : conroe-l : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : allendale : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : wolfdale : -march=core2 -msse4.1 ; +-cpu-flags gcc OPTIONS : x86 : merom : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : merom-xe : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : kentsfield : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : kentsfield-xe : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : yorksfield : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : penryn : -march=core2 ; +-cpu-flags gcc OPTIONS : x86 : corei7 : -march=corei7 ; +-cpu-flags gcc OPTIONS : x86 : nehalem : -march=corei7 ; +-cpu-flags gcc OPTIONS : x86 : corei7-avx : -march=corei7-avx ; +-cpu-flags gcc OPTIONS : x86 : sandy-bridge : -march=corei7-avx ; +-cpu-flags gcc OPTIONS : x86 : core-avx-i : -march=core-avx-i ; +-cpu-flags gcc OPTIONS : x86 : ivy-bridge : -march=core-avx-i ; +-cpu-flags gcc OPTIONS : x86 : haswell : -march=core-avx-i -mavx2 -mfma -mbmi -mbmi2 -mlzcnt ; +-cpu-flags gcc OPTIONS : x86 : broadwell : -march=broadwell ; +-cpu-flags gcc OPTIONS : x86 : skylake : -march=skylake ; +-cpu-flags gcc OPTIONS : x86 : skylake-avx512 : -march=skylake-avx512 ; +-cpu-flags gcc OPTIONS : x86 : cannonlake : -march=skylake-avx512 -mavx512vbmi -mavx512ifma -msha ; +-cpu-flags gcc OPTIONS : x86 : icelake-client : -march=icelake-client ; +-cpu-flags gcc OPTIONS : x86 : icelake-server : -march=icelake-server ; +-cpu-flags gcc OPTIONS : x86 : cascadelake : -march=skylake-avx512 -mavx512vnni ; +-cpu-flags gcc OPTIONS : x86 : cooperlake : -march=cooperlake ; +-cpu-flags gcc OPTIONS : x86 : tigerlake : -march=tigerlake ; +-cpu-flags gcc OPTIONS : x86 : rocketlake : -march=rocketlake ; +-cpu-flags gcc OPTIONS : x86 : alderlake : -march=alderlake ; +-cpu-flags gcc OPTIONS : x86 : sapphirerapids : -march=sapphirerapids ; +-cpu-flags gcc OPTIONS : x86 : k6 : -march=k6 ; +-cpu-flags gcc OPTIONS : x86 : k6-2 : -march=k6-2 ; +-cpu-flags gcc OPTIONS : x86 : k6-3 : -march=k6-3 ; +-cpu-flags gcc OPTIONS : x86 : athlon : -march=athlon ; +-cpu-flags gcc OPTIONS : x86 : athlon-tbird : -march=athlon-tbird ; +-cpu-flags gcc OPTIONS : x86 : athlon-4 : -march=athlon-4 ; +-cpu-flags gcc OPTIONS : x86 : athlon-xp : -march=athlon-xp ; +-cpu-flags gcc OPTIONS : x86 : athlon-mp : -march=athlon-mp ; +-## +-cpu-flags gcc OPTIONS : x86 : k8 : -march=k8 ; +-cpu-flags gcc OPTIONS : x86 : opteron : -march=opteron ; +-cpu-flags gcc OPTIONS : x86 : athlon64 : -march=athlon64 ; +-cpu-flags gcc OPTIONS : x86 : athlon-fx : -march=athlon-fx ; +-cpu-flags gcc OPTIONS : x86 : k8-sse3 : -march=k8-sse3 ; +-cpu-flags gcc OPTIONS : x86 : opteron-sse3 : -march=opteron-sse3 ; +-cpu-flags gcc OPTIONS : x86 : athlon64-sse3 : -march=athlon64-sse3 ; +-cpu-flags gcc OPTIONS : x86 : amdfam10 : -march=amdfam10 ; +-cpu-flags gcc OPTIONS : x86 : barcelona : -march=barcelona ; +-cpu-flags gcc OPTIONS : x86 : bdver1 : -march=bdver1 ; +-cpu-flags gcc OPTIONS : x86 : bdver2 : -march=bdver2 ; +-cpu-flags gcc OPTIONS : x86 : bdver3 : -march=bdver3 ; +-cpu-flags gcc OPTIONS : x86 : bdver4 : -march=bdver4 ; +-cpu-flags gcc OPTIONS : x86 : btver1 : -march=btver1 ; +-cpu-flags gcc OPTIONS : x86 : btver2 : -march=btver2 ; +-cpu-flags gcc OPTIONS : x86 : znver1 : -march=znver1 ; +-cpu-flags gcc OPTIONS : x86 : znver2 : -march=znver2 ; +-cpu-flags gcc OPTIONS : x86 : znver3 : -march=znver3 ; +-cpu-flags gcc OPTIONS : x86 : winchip-c6 : -march=winchip-c6 ; +-cpu-flags gcc OPTIONS : x86 : winchip2 : -march=winchip2 ; +-cpu-flags gcc OPTIONS : x86 : c3 : -march=c3 ; +-cpu-flags gcc OPTIONS : x86 : c3-2 : -march=c3-2 ; +-cpu-flags gcc OPTIONS : x86 : c7 : -march=c7 ; +-## +-cpu-flags gcc OPTIONS : x86 : atom : -march=atom ; +-# Sparc +-cpu-flags gcc OPTIONS : sparc : v7 : -mcpu=v7 : default ; +-cpu-flags gcc OPTIONS : sparc : cypress : -mcpu=cypress ; +-cpu-flags gcc OPTIONS : sparc : v8 : -mcpu=v8 ; +-cpu-flags gcc OPTIONS : sparc : supersparc : -mcpu=supersparc ; +-cpu-flags gcc OPTIONS : sparc : sparclite : -mcpu=sparclite ; +-cpu-flags gcc OPTIONS : sparc : hypersparc : -mcpu=hypersparc ; +-cpu-flags gcc OPTIONS : sparc : sparclite86x : -mcpu=sparclite86x ; +-cpu-flags gcc OPTIONS : sparc : f930 : -mcpu=f930 ; +-cpu-flags gcc OPTIONS : sparc : f934 : -mcpu=f934 ; +-cpu-flags gcc OPTIONS : sparc : sparclet : -mcpu=sparclet ; +-cpu-flags gcc OPTIONS : sparc : tsc701 : -mcpu=tsc701 ; +-cpu-flags gcc OPTIONS : sparc : v9 : -mcpu=v9 ; +-cpu-flags gcc OPTIONS : sparc : ultrasparc : -mcpu=ultrasparc ; +-cpu-flags gcc OPTIONS : sparc : ultrasparc3 : -mcpu=ultrasparc3 ; +-# RS/6000 & PowerPC +-cpu-flags gcc OPTIONS : power : 403 : -mcpu=403 ; +-cpu-flags gcc OPTIONS : power : 505 : -mcpu=505 ; +-cpu-flags gcc OPTIONS : power : 601 : -mcpu=601 ; +-cpu-flags gcc OPTIONS : power : 602 : -mcpu=602 ; +-cpu-flags gcc OPTIONS : power : 603 : -mcpu=603 ; +-cpu-flags gcc OPTIONS : power : 603e : -mcpu=603e ; +-cpu-flags gcc OPTIONS : power : 604 : -mcpu=604 ; +-cpu-flags gcc OPTIONS : power : 604e : -mcpu=604e ; +-cpu-flags gcc OPTIONS : power : 620 : -mcpu=620 ; +-cpu-flags gcc OPTIONS : power : 630 : -mcpu=630 ; +-cpu-flags gcc OPTIONS : power : 740 : -mcpu=740 ; +-cpu-flags gcc OPTIONS : power : 7400 : -mcpu=7400 ; +-cpu-flags gcc OPTIONS : power : 7450 : -mcpu=7450 ; +-cpu-flags gcc OPTIONS : power : 750 : -mcpu=750 ; +-cpu-flags gcc OPTIONS : power : 801 : -mcpu=801 ; +-cpu-flags gcc OPTIONS : power : 821 : -mcpu=821 ; +-cpu-flags gcc OPTIONS : power : 823 : -mcpu=823 ; +-cpu-flags gcc OPTIONS : power : 860 : -mcpu=860 ; +-cpu-flags gcc OPTIONS : power : 970 : -mcpu=970 ; +-cpu-flags gcc OPTIONS : power : 8540 : -mcpu=8540 ; +-cpu-flags gcc OPTIONS : power : power : -mcpu=power ; +-cpu-flags gcc OPTIONS : power : power2 : -mcpu=power2 ; +-cpu-flags gcc OPTIONS : power : power3 : -mcpu=power3 ; +-cpu-flags gcc OPTIONS : power : power4 : -mcpu=power4 ; +-cpu-flags gcc OPTIONS : power : power5 : -mcpu=power5 ; +-cpu-flags gcc OPTIONS : power : powerpc : -mcpu=powerpc ; +-cpu-flags gcc OPTIONS : power : powerpc64 : -mcpu=powerpc64 ; +-cpu-flags gcc OPTIONS : power : rios : -mcpu=rios ; +-cpu-flags gcc OPTIONS : power : rios1 : -mcpu=rios1 ; +-cpu-flags gcc OPTIONS : power : rios2 : -mcpu=rios2 ; +-cpu-flags gcc OPTIONS : power : rsc : -mcpu=rsc ; +-cpu-flags gcc OPTIONS : power : rs64a : -mcpu=rs64 ; +-cpu-flags gcc OPTIONS : s390x : z196 : -march=z196 ; +-cpu-flags gcc OPTIONS : s390x : zEC12 : -march=zEC12 ; +-cpu-flags gcc OPTIONS : s390x : z13 : -march=z13 ; +-cpu-flags gcc OPTIONS : s390x : z14 : -march=z14 ; +-cpu-flags gcc OPTIONS : s390x : z15 : -march=z15 ; +-# ARM +-cpu-flags gcc OPTIONS : arm : cortex-a9+vfpv3 : -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard ; +-cpu-flags gcc OPTIONS : arm : cortex-a53 : -mcpu=cortex-a53 ; +-cpu-flags gcc OPTIONS : arm : cortex-r5 : -mcpu=cortex-r5 ; +-cpu-flags gcc OPTIONS : arm : cortex-r5+vfpv3-d16 : -mcpu=cortex-r5 -mfpu=vfpv3-d16 -mfloat-abi=hard ; +-# AIX variant of RS/6000 & PowerPC +-toolset.flags gcc AROPTIONS 64/aix : "-X64" ; +- +-# Enable response file control +-toolset.flags gcc RESPONSE_FILE_SUB auto : a ; +-toolset.flags gcc RESPONSE_FILE_SUB file : f ; +-toolset.flags gcc RESPONSE_FILE_SUB contents : c ; diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost/0001-dont-setup-compiler-flags-m32-m64.patch b/distro/yocto/meta-salmanoff/recipes-support/boost/boost/0001-dont-setup-compiler-flags-m32-m64.patch new file mode 100644 index 0000000..8f13034 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost/0001-dont-setup-compiler-flags-m32-m64.patch @@ -0,0 +1,41 @@ +From 7130850d74863d1e9a0ae3e85462f1466bdf6d88 Mon Sep 17 00:00:00 2001 +From: Anuj Mittal +Date: Thu, 14 Nov 2019 10:13:53 +0800 +Subject: [PATCH] dont setup compiler flags -m32/-m64 + +We don't want these to be setup by boost as we pass our own flags. + +Upstream-Status: Inappropriate [OE-specific] + +Signed-off-by: Anuj Mittal +--- + tools/build/src/tools/gcc.jam | 16 ---------------- + 1 file changed, 16 deletions(-) + +diff --git a/tools/build/src/tools/gcc.jam b/tools/build/src/tools/gcc.jam +index ed7e39baf..90513f84a 100644 +--- a/tools/build/src/tools/gcc.jam ++++ b/tools/build/src/tools/gcc.jam +@@ -377,22 +377,6 @@ local rule compile-link-flags ( * ) + compile-link-flags shared/$(non-windows) : -fPIC ; + } + +-{ +- # Handle address-model +- compile-link-flags aix/32 : -maix32 ; +- compile-link-flags aix/64 : -maix64 ; +- +- compile-link-flags hpux/32 : -milp32 ; +- compile-link-flags hpux/64 : -mlp64 ; +- +- local generic-os = [ set.difference $(all-os) : aix hpux ] ; +- compile-link-flags $(generic-os)/s390x/32 : -m31 ; +- compile-link-flags $(generic-os)/s390x/64 : -m64 ; +- local arch = power sparc x86 ; +- compile-link-flags $(generic-os)/$(arch)/32 : -m32 ; +- compile-link-flags $(generic-os)/$(arch)/64 : -m64 ; +-} +- + { + # Handle threading + local rule threading-flags ( * ) diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost/boost-math-disable-pch-for-gcc.patch b/distro/yocto/meta-salmanoff/recipes-support/boost/boost/boost-math-disable-pch-for-gcc.patch new file mode 100644 index 0000000..dde21fa --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost/boost-math-disable-pch-for-gcc.patch @@ -0,0 +1,28 @@ +From c6009cdc1fe76db0092443593396e4d5f0eaa86b Mon Sep 17 00:00:00 2001 +From: Jackie Huang +Date: Fri, 23 Sep 2016 01:04:50 -0700 +Subject: [PATCH] boost-math: disable pch for gcc + +Upstream-Status: Inappropriate [*] + +* It's a work around for a defect when build in parallel: +https://svn.boost.org/trac/boost/ticket/12477 + +Signed-off-by: Jackie Huang +--- + libs/math/build/Jamfile.v2 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libs/math/build/Jamfile.v2 b/libs/math/build/Jamfile.v2 +index 6549e06b7..342cbf0b1 100644 +--- a/libs/math/build/Jamfile.v2 ++++ b/libs/math/build/Jamfile.v2 +@@ -13,7 +13,7 @@ project + intel-win:-nologo + #intel-linux:off + intel-darwin:off +- gcc,windows:off ++ gcc:off + #gcc:-fvisibility=hidden + intel-linux:-fvisibility=hidden + #sun:-xldscope=hidden diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost_1.86.0.bb b/distro/yocto/meta-salmanoff/recipes-support/boost/boost_1.86.0.bb new file mode 100644 index 0000000..4b580d0 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost_1.86.0.bb @@ -0,0 +1,7 @@ +require boost-${PV}.inc +require boost.inc + +SRC_URI += "file://boost-math-disable-pch-for-gcc.patch \ + file://0001-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch \ + file://0001-dont-setup-compiler-flags-m32-m64.patch \ + " diff --git a/distro/yocto/meta-salmanoff/recipes-support/boost/boost_1.90.0.bbappend b/distro/yocto/meta-salmanoff/recipes-support/boost/boost_1.90.0.bbappend new file mode 100644 index 0000000..cf13c4e --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/boost/boost_1.90.0.bbappend @@ -0,0 +1,3 @@ +# Wrynose ships Boost 1.90; Salmanoff requires Boost >= 1.69 and < 1.89. +# meta-salmanoff provides boost_1.86.0.bb; layer.conf masks this recipe and +# sets PREFERRED_VERSION_boost = "1.86.%". diff --git a/distro/yocto/meta-salmanoff/recipes-support/rseqsliceprobe/files/rseqsliceprobe.cpp b/distro/yocto/meta-salmanoff/recipes-support/rseqsliceprobe/files/rseqsliceprobe.cpp new file mode 100644 index 0000000..33e8990 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/rseqsliceprobe/files/rseqsliceprobe.cpp @@ -0,0 +1,452 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifndef ENOTSUPP +#define ENOTSUPP 524 +#endif + +#if defined(__x86_64__) +#ifndef ARCH_GET_FS +#define ARCH_GET_FS 0x1003 +#endif +#endif + +#ifndef PR_RSEQ_SLICE_EXTENSION +#define PR_RSEQ_SLICE_EXTENSION 79 +#define PR_RSEQ_SLICE_EXTENSION_GET 1 +#define PR_RSEQ_SLICE_EXTENSION_SET 2 +#define PR_RSEQ_SLICE_EXT_ENABLE 0x01 +#endif + +#ifndef RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE +#define RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE (1U << 4) +#define RSEQ_CS_FLAG_SLICE_EXT_ENABLED (1U << 5) +#endif + +#ifndef RSEQ_SIG +#if defined(__x86_64__) || defined(__i386__) +#define RSEQ_SIG 0x53053053 +#elif defined(__aarch64__) +#define RSEQ_SIG 0x00bc28d4 +#else +#error "Add RSEQ_SIG for this architecture" +#endif +#endif + +#ifndef SYS_rseq +#ifdef __NR_rseq +#define SYS_rseq __NR_rseq +#endif +#endif + +#ifndef SYS_getcpu +#ifdef __NR_getcpu +#define SYS_getcpu __NR_getcpu +#endif +#endif + +extern "C" { +extern __attribute__((weak)) ptrdiff_t __rseq_offset; +extern __attribute__((weak)) unsigned int __rseq_size; +extern __attribute__((weak)) unsigned int __rseq_flags; +} + +struct rseq_slice_ctrl_fields { + uint8_t request; + uint8_t granted; + uint16_t reserved; +}; + +struct rseq_slice_ctrl_compat { + union { + uint32_t all; + rseq_slice_ctrl_fields parts; + }; +}; + +struct rseq_compat { + uint32_t cpu_id_start; + int32_t cpu_id; + uint64_t rseq_cs; + uint32_t flags; + uint32_t node_id; + uint32_t mm_cid; + struct rseq_slice_ctrl_compat slice_ctrl; + uint8_t reserved; +} __attribute__((aligned(32))); + +struct prctl_probe_result { + bool ok; + int value; + int err; +}; + +alignas(32) static thread_local unsigned char local_rseq_storage[512]; + +static unsigned int g_rseq_feature_size; +static unsigned int g_rseq_alloc_size; +static unsigned int g_rseq_align; +static unsigned long g_aux_rseq_feature_size; +static unsigned long g_aux_rseq_align; +static struct rseq *g_registered_rseq; +static struct rseq_compat *g_registered_rseq_compat; +static bool g_own_registration; + +static const char *yes_no(bool value) +{ + return value ? "yes" : "no"; +} + +static const char *set_clear(bool value) +{ + return value ? "set" : "clear"; +} + +static int get_thread_pointer(uintptr_t *tp_out) +{ +#if defined(__x86_64__) + unsigned long fsbase = 0; + + if (syscall(SYS_arch_prctl, ARCH_GET_FS, &fsbase) != 0) + return -1; + *tp_out = fsbase; + return 0; +#elif defined(__aarch64__) + void *tp = nullptr; + + __asm__ volatile("mrs %0, tpidr_el0" : "=r"(tp)); + *tp_out = reinterpret_cast(tp); + return 0; +#else + (void) tp_out; + errno = ENOTSUP; + return -1; +#endif +} + +static int sys_rseq(struct rseq *rseq, uint32_t len, int flags, uint32_t sig) +{ +#ifdef SYS_rseq + return static_cast(syscall(SYS_rseq, rseq, len, flags, sig)); +#else + (void) rseq; + (void) len; + (void) flags; + (void) sig; + errno = ENOSYS; + return -1; +#endif +} + +static int sys_getcpu(unsigned int *cpu, unsigned int *node) +{ +#ifdef SYS_getcpu + return static_cast(syscall(SYS_getcpu, cpu, node, nullptr)); +#else + (void) cpu; + (void) node; + errno = ENOSYS; + return -1; +#endif +} + +static const char *errno_name(int err) +{ + switch (err) { + case 0: return "0"; + case EINVAL: return "EINVAL"; + case ENOSYS: return "ENOSYS"; + case ENOTSUP: return "ENOTSUP"; + case ENOTSUPP: return "ENOTSUPP"; + case ENXIO: return "ENXIO"; + case EPERM: return "EPERM"; + case EBUSY: return "EBUSY"; + default: return "UNKNOWN"; + } +} + +static const char *prctl_failure_meaning(int err) +{ + switch (err) { + case EINVAL: + return "the prctl operation or argument is not accepted by this kernel"; + case ENOTSUPP: + return "the prctl operation exists, but the slice extension is not supported here"; + case EPERM: + return "the kernel denied the requested operation"; + default: + return "the kernel returned an unclassified failure"; + } +} + +static void print_errno_status(const char *label, int err) +{ + std::printf("%s: errno=%d (%s: %s)\n", + label, err, errno_name(err), std::strerror(err)); +} + +static unsigned int max_u32(unsigned int a, unsigned int b) +{ + return a > b ? a : b; +} + +static bool feature_present(size_t end_offset) +{ + return g_rseq_feature_size >= end_offset; +} + +static void print_registration_source(void) +{ + if (g_own_registration) + std::printf("rseq registration: local syscall registration\n"); + else + std::printf("rseq registration: existing libc-owned registration\n"); +} + +static int setup_rseq(void) +{ + g_aux_rseq_feature_size = getauxval(AT_RSEQ_FEATURE_SIZE); + g_aux_rseq_align = getauxval(AT_RSEQ_ALIGN); + + g_rseq_feature_size = g_aux_rseq_feature_size ? + static_cast(g_aux_rseq_feature_size) : 20U; + g_rseq_align = g_aux_rseq_align ? + static_cast(g_aux_rseq_align) : 32U; + g_rseq_alloc_size = max_u32(g_rseq_feature_size, 32U); + + if (&__rseq_size != nullptr && __rseq_size != 0) { + uintptr_t tp = 0; + + if (get_thread_pointer(&tp) != 0) { + std::perror("get_thread_pointer"); + return -1; + } + + g_registered_rseq = reinterpret_cast(tp + __rseq_offset); + g_registered_rseq_compat = reinterpret_cast(tp + __rseq_offset); + g_own_registration = false; + if (__rseq_size < g_rseq_feature_size) + g_rseq_feature_size = __rseq_size; + if (__rseq_size > g_rseq_alloc_size) + g_rseq_alloc_size = __rseq_size; + return 0; + } + + if (g_rseq_alloc_size > sizeof(local_rseq_storage)) { + std::fprintf(stderr, + "local rseq area too small: need %u bytes, have %zu\n", + g_rseq_alloc_size, sizeof(local_rseq_storage)); + errno = EOVERFLOW; + return -1; + } + if ((reinterpret_cast(local_rseq_storage) % g_rseq_align) != 0) { + std::fprintf(stderr, "local rseq area alignment mismatch: need %u\n", + g_rseq_align); + errno = EINVAL; + return -1; + } + + auto *local_rseq = reinterpret_cast(local_rseq_storage); + auto *local_rseq_compat = reinterpret_cast(local_rseq_storage); + std::memset(local_rseq_storage, 0, sizeof(local_rseq_storage)); + local_rseq_compat->cpu_id = RSEQ_CPU_ID_UNINITIALIZED; + + if (sys_rseq(local_rseq, g_rseq_alloc_size, 0, RSEQ_SIG) != 0) { + std::perror("rseq register"); + return -1; + } + + g_registered_rseq = local_rseq; + g_registered_rseq_compat = local_rseq_compat; + g_own_registration = true; + return 0; +} + +static void teardown_rseq(void) +{ + if (!g_own_registration) + return; + auto *local_rseq = reinterpret_cast(local_rseq_storage); + if (sys_rseq(local_rseq, g_rseq_alloc_size, RSEQ_FLAG_UNREGISTER, RSEQ_SIG) != 0) + std::perror("rseq unregister"); +} + +static prctl_probe_result probe_prctl_get(void) +{ + errno = 0; + int rc = prctl(PR_RSEQ_SLICE_EXTENSION, PR_RSEQ_SLICE_EXTENSION_GET, + 0UL, 0UL, 0UL); + int saved_errno = errno; + + if (rc >= 0) + return { true, rc, 0 }; + return { false, -1, saved_errno }; +} + +static prctl_probe_result probe_prctl_set(unsigned long value) +{ + errno = 0; + int rc = prctl(PR_RSEQ_SLICE_EXTENSION, PR_RSEQ_SLICE_EXTENSION_SET, + value, 0UL, 0UL); + int saved_errno = errno; + + if (rc >= 0) + return { true, rc, 0 }; + return { false, -1, saved_errno }; +} + +static void print_prctl_result(const char *label, const prctl_probe_result &result) +{ + if (result.ok) { + std::printf("%s: ok, value=%d\n", label, result.value); + return; + } + print_errno_status(label, result.err); + std::printf("%s meaning: %s\n", label, prctl_failure_meaning(result.err)); +} + +static void print_kernel_version(void) +{ + struct utsname uts; + + if (uname(&uts) != 0) { + std::perror("uname"); + return; + } + std::printf("kernel: %s %s %s %s\n", + uts.sysname, uts.release, uts.version, uts.machine); +} + +static void print_slice_status_summary(bool has_slice_ctrl, bool flags_available, + const prctl_probe_result &get_result) +{ + bool flag_available = flags_available && + (g_registered_rseq_compat->flags & RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE); + bool flag_enabled = flags_available && + (g_registered_rseq_compat->flags & RSEQ_CS_FLAG_SLICE_EXT_ENABLED); + bool prctl_enabled = get_result.ok && + (get_result.value & PR_RSEQ_SLICE_EXT_ENABLE); + + std::printf("status: rseq syscall registered: yes\n"); + std::printf("status: rseq extensible feature area: %s\n", + yes_no(g_rseq_feature_size > 20U)); + std::printf("status: rseq slice_ctrl field present: %s\n", + yes_no(has_slice_ctrl)); + std::printf("status: rseq slice extension available flag: %s\n", + flags_available ? set_clear(flag_available) : "unavailable"); + std::printf("status: rseq slice extension enabled flag: %s\n", + flags_available ? set_clear(flag_enabled) : "unavailable"); + std::printf("status: PR_RSEQ_SLICE_EXTENSION GET usable: %s\n", + yes_no(get_result.ok)); + + if (get_result.ok) { + std::printf("status: PR_RSEQ_SLICE_EXTENSION enabled: %s\n", + yes_no(prctl_enabled)); + std::printf("status: rseq slice extension availability: %s\n", + prctl_enabled || flag_available ? "available" : "available but disabled"); + return; + } + if (get_result.err == ENOTSUPP) { + std::printf("status: rseq slice extension availability: not supported by this kernel/arch/config\n"); + return; + } + if (get_result.err == EINVAL) { + std::printf("status: rseq slice extension availability: no accepted prctl API on this kernel\n"); + return; + } + std::printf("status: rseq slice extension availability: unknown\n"); +} + +static void probe_slice_extension(void) +{ + bool has_slice_ctrl = feature_present(offsetof(struct rseq_compat, slice_ctrl) + + sizeof(g_registered_rseq_compat->slice_ctrl)); + bool flags_available = feature_present(offsetof(struct rseq_compat, flags) + + sizeof(g_registered_rseq_compat->flags)); + prctl_probe_result prctl_get = probe_prctl_get(); + unsigned int cpu = 0; + unsigned int node = 0; + + print_kernel_version(); + std::printf("AT_RSEQ_FEATURE_SIZE raw: %lu\n", g_aux_rseq_feature_size); + std::printf("AT_RSEQ_ALIGN raw: %lu\n", g_aux_rseq_align); + std::printf("effective rseq feature size: %u\n", g_rseq_feature_size); + std::printf("effective rseq alignment: %u\n", g_rseq_align); + std::printf("registered rseq size: %u\n", g_rseq_alloc_size); + print_registration_source(); + if (&__rseq_size != nullptr) { + std::printf("libc __rseq_size=%u __rseq_offset=%td __rseq_flags=0x%x\n", + __rseq_size, __rseq_offset, __rseq_flags); + } + std::printf("registered rseq addr: %p\n", static_cast(g_registered_rseq)); + std::printf("struct rseq has slice_ctrl field available: %s\n", + yes_no(has_slice_ctrl)); + + if (sys_getcpu(&cpu, &node) == 0) + std::printf("getcpu(): cpu=%u node=%u\n", cpu, node); + + std::printf("rseq cpu_id_start=%u cpu_id=%d\n", + g_registered_rseq->cpu_id_start, + static_cast(g_registered_rseq->cpu_id)); + + if (feature_present(offsetof(struct rseq_compat, node_id) + + sizeof(g_registered_rseq_compat->node_id))) { + std::printf("rseq node_id=%u\n", g_registered_rseq_compat->node_id); + } + if (feature_present(offsetof(struct rseq_compat, mm_cid) + + sizeof(g_registered_rseq_compat->mm_cid))) { + std::printf("rseq mm_cid=%u\n", g_registered_rseq_compat->mm_cid); + } + + if (flags_available) { + std::printf("rseq flags=0x%x\n", g_registered_rseq_compat->flags); + std::printf("slice ext available bit: %s\n", + set_clear(g_registered_rseq_compat->flags & RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE)); + std::printf("slice ext enabled bit: %s\n", + set_clear(g_registered_rseq_compat->flags & RSEQ_CS_FLAG_SLICE_EXT_ENABLED)); + } + + if (has_slice_ctrl) { + std::printf("slice_ctrl.request=%u granted=%u raw=0x%x\n", + g_registered_rseq_compat->slice_ctrl.parts.request, + g_registered_rseq_compat->slice_ctrl.parts.granted, + g_registered_rseq_compat->slice_ctrl.all); + } + + print_prctl_result("prctl(PR_RSEQ_SLICE_EXTENSION, GET)", prctl_get); + if (prctl_get.ok) { + prctl_probe_result set_enable = probe_prctl_set(PR_RSEQ_SLICE_EXT_ENABLE); + print_prctl_result("prctl(PR_RSEQ_SLICE_EXTENSION, SET enable)", + set_enable); + prctl_probe_result after_enable = probe_prctl_get(); + print_prctl_result("prctl(PR_RSEQ_SLICE_EXTENSION, GET after enable)", + after_enable); + prctl_probe_result set_disable = probe_prctl_set(0UL); + print_prctl_result("prctl(PR_RSEQ_SLICE_EXTENSION, SET disable)", + set_disable); + } + print_slice_status_summary(has_slice_ctrl, flags_available, prctl_get); +} + +int main() +{ + if (setup_rseq() != 0) + return 1; + + probe_slice_extension(); + teardown_rseq(); + return 0; +} diff --git a/distro/yocto/meta-salmanoff/recipes-support/rseqsliceprobe/rseqsliceprobe.bb b/distro/yocto/meta-salmanoff/recipes-support/rseqsliceprobe/rseqsliceprobe.bb new file mode 100644 index 0000000..285b468 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/rseqsliceprobe/rseqsliceprobe.bb @@ -0,0 +1,15 @@ +SUMMARY = "Probe kernel RSeq timeslice extension" +LICENSE = "CLOSED" + +SRC_URI = "file://rseqsliceprobe.cpp" + +S = "${UNPACKDIR}" + +do_compile() { + ${CXX} ${CXXFLAGS} ${LDFLAGS} ${S}/rseqsliceprobe.cpp -o rseqsliceprobe +} + +do_install() { + install -d ${D}${bindir} + install -m 0755 rseqsliceprobe ${D}${bindir}/rseqsliceprobe +} diff --git a/distro/yocto/meta-salmanoff/recipes-support/salmanoff-rusticl-env/salmanoff-rusticl-env.bb b/distro/yocto/meta-salmanoff/recipes-support/salmanoff-rusticl-env/salmanoff-rusticl-env.bb new file mode 100644 index 0000000..7f143f5 --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/salmanoff-rusticl-env/salmanoff-rusticl-env.bb @@ -0,0 +1,16 @@ +SUMMARY = "Enable Mesa Rusticl llvmpipe OpenCL device in login shells" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI = "file://rusticl-llvmpipe.sh" + +S = "${UNPACKDIR}" + +inherit allarch + +do_install() { + install -d ${D}${sysconfdir}/profile.d + install -m 0644 ${UNPACKDIR}/rusticl-llvmpipe.sh ${D}${sysconfdir}/profile.d/ +} + +FILES:${PN} = "${sysconfdir}/profile.d/rusticl-llvmpipe.sh" diff --git a/distro/yocto/meta-salmanoff/recipes-support/salmanoff-rusticl-env/salmanoff-rusticl-env/rusticl-llvmpipe.sh b/distro/yocto/meta-salmanoff/recipes-support/salmanoff-rusticl-env/salmanoff-rusticl-env/rusticl-llvmpipe.sh new file mode 100644 index 0000000..dccae0b --- /dev/null +++ b/distro/yocto/meta-salmanoff/recipes-support/salmanoff-rusticl-env/salmanoff-rusticl-env/rusticl-llvmpipe.sh @@ -0,0 +1,4 @@ +# Mesa Rusticl lists platforms but no devices until drivers are opted in at +# runtime. llvmpipe uses the CPU as a software gallium OpenCL device (no GPU +# or QEMU graphics device required). +export RUSTICL_ENABLE=llvmpipe diff --git a/distro/yocto/meta-salmanoff/scripts/runqemu-salmanoff-bridge b/distro/yocto/meta-salmanoff/scripts/runqemu-salmanoff-bridge new file mode 100755 index 0000000..f21c466 --- /dev/null +++ b/distro/yocto/meta-salmanoff/scripts/runqemu-salmanoff-bridge @@ -0,0 +1,29 @@ +#!/bin/sh +# Boot salmanoff-image with eth0 bridged onto the host lab LAN (10.42.0.0/24). +# +# Prerequisites on the host: +# 1. A Linux bridge (default: br-smo) whose ports include the NIC on 10.42.0.0/24. +# 2. /etc/qemu/bridge.conf containing: allow br-smo +# 3. qemu-oe-bridge-helper allowed (setuid or root via sudo policy). +# +# Usage (from build/ after sourcing init-build-env): +# ../layers/meta-salmanoff/scripts/runqemu-salmanoff-bridge +# ../layers/meta-salmanoff/scripts/runqemu-salmanoff-bridge br-lab +# ../layers/meta-salmanoff/scripts/runqemu-salmanoff-bridge br-smo 4096 +# +# Guest eth0 is configured statically as 10.42.0.16/24 via init-ifupdown. +# Default RAM is 2G: Mesa Rusticl/llvmpipe (clinfo, Salmanoff OpenCL) OOMs at 256M. + +set -eu + +BRIDGE="${1:-br-smo}" +MEM="${2:-2048}" + +if [ ! -f /etc/qemu/bridge.conf ] || ! grep -q "allow ${BRIDGE}" /etc/qemu/bridge.conf 2>/dev/null; then + echo "Host bridge helper is not configured for '${BRIDGE}'." >&2 + echo "Create /etc/qemu/bridge.conf with a line: allow ${BRIDGE}" >&2 + echo "See: https://docs.yoctoproject.org/dev-manual/qemu.html" >&2 + exit 1 +fi + +exec runqemu salmanoff-image snapshot "bridge=${BRIDGE}" nographic "qemuparams=-m ${MEM}"