Loading boards/nas-itx/nas-itx.dts +14 −4 Changes for boards/nas-itx/nas-itx.dts: 14 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ #address-cells = <1>; #size-cells = <1>; /* same layout as U-Boot's mtdparts (nas_itx_NAND_defconfig) */ /* the vendor U-Boot's layout: U-Boot at 0, its environment * at 0x300000 (found the hard way: saveenv there) */ partition@0 { /* SPL, TPL and U-Boot */ reg = <0x00000000 0x00100000>; Loading @@ -61,8 +62,10 @@ }; partition@100000 { /* an old U-Boot environment (not the current one) */ reg = <0x00100000 0x00100000>; label = "env"; label = "env-old"; read-only; }; partition@200000 { Loading @@ -71,8 +74,15 @@ }; partition@300000 { /* uImage, up to 16 MiB */ reg = <0x00300000 0x01000000>; /* the environment of the vendor U-Boot 2012.07 * (its saveenv erases and writes this block) */ reg = <0x00300000 0x00100000>; label = "env"; }; partition@400000 { /* uImage, up to 15 MiB */ reg = <0x00400000 0x00f00000>; label = "kernel"; }; Loading build-chroot.sh +27 −3 Changes for build-chroot.sh: 27 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -164,6 +164,8 @@ ISO_HOSTNAME="${ISO_HOSTNAME:-fenriros}" # FenrirOS files (rpm specs, macros, GNU-free CMake builds) from the # scripts repository, used by the 'rpm' and 'packages' steps FENRIR_FILES="$(realpath -m "${FENRIR_FILES:-$SYSTEMPP_SRC/../scripts/files}")" # where stage_sources() puts the RPM sources: the chroot's rpmbuild tree; # the 'sources' step (build-cross.sh) points it elsewhere CMAKE_REF="${CMAKE_REF:-v4.4.3}" JOBS="${JOBS:-$(nproc)}" HOST_CC="${HOST_CC:-clang}" Loading @@ -180,6 +182,7 @@ CHROOT="$WORK/chroot" LOGS="$WORK/logs" BUILD="$WORK/build" RPMROOT="$WORK/rpmroot" SOURCES_DIR="$(realpath -m "${SOURCES_DIR:-$CHROOT/build/rpmbuild/SOURCES}")" msg() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } die() { printf '\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; } Loading Loading @@ -1021,7 +1024,7 @@ fetch_url() { [[ -s $cache/$f.part ]] || die "could not download $f (tried: $*)" mv "$cache/$f.part" "$cache/$f" fi cp "$cache/$f" "$CHROOT/build/rpmbuild/SOURCES/$f" cp "$cache/$f" "$SOURCES_DIR/$f" } # The kernel options build_kernel() in build-os.sh adds to x86_64's Loading Loading @@ -1208,7 +1211,7 @@ llvm_wrappers() { # stage_sources <spec> -- everything its Source/Patch lines name, into # the chroot's SOURCES stage_sources() { local spec="$1" pkg name version srcdir="$CHROOT/build/rpmbuild/SOURCES" local spec="$1" pkg name version srcdir="$SOURCES_DIR" pkg="$(basename "$spec" .spec)" name="$(spec_field "$spec" Name)"; version="$(spec_field "$spec" Version)" mkdir -p "$srcdir" Loading Loading @@ -1323,7 +1326,7 @@ stage_sources() { if [[ $src == http*://* ]]; then fetch_url "$f" "${src%%#*}" elif [[ $pkg == kernel && $f == kernel-config-* ]]; then kernel_config "$version" [[ -n ${KERNEL_CONFIG_SKIP:-} ]] || kernel_config "$version" elif [[ $pkg == llvm-project && $f == llvm-project-wrappers.tar.gz ]]; then llvm_wrappers "$version" "$srcdir/$f" # local files: named <dir>-<file> after the scripts repo's Loading Loading @@ -1833,6 +1836,26 @@ chroot_unmounted() { $mnts" } # sources: only the RPM sources of $PACKAGES into $SOURCES_DIR (and the # specs into $SOURCES_DIR/../SPECS), no chroot -- for build-cross.sh, which # runs rpmbuild for another architecture on the host. The kernel's # config is that build's business (it skips kernel-config-*). step_sources() { local pkg spec mkdir -p "$SOURCES_DIR" "$SOURCES_DIR/../SPECS" for pkg in $PACKAGES; do spec="$FENRIR_FILES/rpm/specs/$pkg.spec" [[ -f $spec ]] || die "no spec $spec" cp "$spec" "$SOURCES_DIR/../SPECS/" if [[ $pkg == kernel ]]; then KERNEL_CONFIG_SKIP=1 stage_sources "$spec" else stage_sources "$spec" fi done msg "sources: $PACKAGES -> $SOURCES_DIR" } step_clean() { chroot_unmounted msg "removing $BUILD $SYSROOT $RPMROOT $TOOLCHAIN $CHROOT $LOGS (keeping llvm-project)" Loading @@ -1849,6 +1872,7 @@ for s in "${steps[@]}"; do case "$s" in systempp|toolchain|host-tblgen|llvm|fresh|tools|rpm|chroot|packages|repo|iso|docker|fenstore) check_deps; mkdir -p "$WORK" "$BUILD"; "step_${s//-/_}" ;; sources) mkdir -p "$WORK" "$LOGS"; step_sources ;; enter) step_enter ;; clean) step_clean ;; -h|--help) sed -n '2,/^$/s/^# \{0,1\}//p' "$0"; exit 0 ;; Loading build-cross.sh +187 −2 Changes for build-cross.sh: 187 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -82,6 +82,17 @@ HOST_CXX="${HOST_CXX:-clang++}" JOBS="${JOBS:-$(nproc)}" HOSTNAME_FENRIR="${HOSTNAME_FENRIR:-$BOARD}" FENRIR_FILES="$(realpath -m "${FENRIR_FILES:-$SYSTEMPP_SRC/../scripts/files}")" # the RPM architecture of the board's packages RPM_ARCH="${RPM_ARCH:-ppc}" # FenrirOS specs cross-built by the 'packages' step, in dependency order # (libyaml before libconfplus: its backends need it, which the x86 chroot # just happens to have) CROSS_PACKAGES="${CROSS_PACKAGES:-systempp fresh zlib zstd bzip2 libjson-c libbrotli libcmdplus libuuidp libnetplus libyaml libconfplus libhttppp libressl syslite sharedd adconnect storaged iscsid upsd firewalld tinyxml2 snmpdd ntpplus containerd webctl popt lua file libelf libsqlite3 rpm ca-certificates fenriros-release liblzma libxml2 libarchive glib2 curl libsolv librepo fmt toml11 libsmartcols dnf5}" PREFIX=/usr INTERP="$PREFIX/lib/ld-linux-$PROC.so" BUILD="$WORK/build" Loading Loading @@ -280,6 +291,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # host tools a target build must not pick up: documentation (the specs # package what the build chroot, which has no Doxygen, produces) set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen TRUE) # LibreSSL portable announces powerpc bignum assembler routines # (crypto/bn/arch/powerpc) it has no sources for: its C implementation set(ENABLE_ASM OFF CACHE BOOL "no assembler routines (LibreSSL on 32-bit powerpc)") EOF if command -v qemu-$PROC >/dev/null; then echo "set(CMAKE_CROSSCOMPILING_EMULATOR $(command -v qemu-$PROC) -cpu e500v2 -L $SYSROOT)" >>"$TOOLCHAIN/$TRIPLE.cmake" Loading Loading @@ -357,6 +374,7 @@ NAME="FenrirOS" ID=fenriros PRETTY_NAME="FenrirOS ($BOARD)" EOF # the accounts build-chroot.sh's write_system_config sets up cat >"$root/etc/user.yaml" <<'EOF' - name: root passwd: x Loading @@ -365,12 +383,34 @@ EOF gecos: root dir: /root shell: /bin/sh - name: sshd passwd: x uid: 74 gid: 74 gecos: sshd privilege separation dir: /var/empty shell: /bin/false - name: webctl passwd: x uid: 990 gid: 990 gecos: webctl web interface dir: /var/empty shell: /bin/false EOF cat >"$root/etc/group.yaml" <<'EOF' - name: root passwd: x gid: 0 members: [] - name: sshd passwd: x gid: 74 members: [] - name: webctl passwd: x gid: 990 members: [] EOF cat >"$root/etc/shadow.yaml" <<'EOF' - name: root Loading Loading @@ -408,9 +448,11 @@ EOF step_rootfs() { local d if ! compgen -G "$WORK/rpmbuild/RPMS/$RPM_ARCH/systempp-[0-9]*.rpm" >/dev/null; then for d in systempp fresh syslite; do [[ -f $BUILD/$d/build.ninja ]] || die "$d not built -- run the '$d' step first" done fi [[ -d $KBUILD/arch ]] || die "kernel not built -- run the 'kernel' step first" msg "rootfs: assembling $ROOTFS" rm -rf --one-file-system "$ROOTFS" Loading @@ -419,6 +461,25 @@ step_rootfs() { chmod 700 "$ROOTFS/root" ln -s usr/bin "$ROOTFS/bin"; ln -s usr/sbin "$ROOTFS/sbin"; ln -s usr/lib "$ROOTFS/lib" local rpmdir="$WORK/rpmbuild/RPMS/$RPM_ARCH" if compgen -G "$rpmdir/systempp-[0-9]*.rpm" >/dev/null; then # RPM-based (the 'packages' step ran): every runtime package, with # the rpmdb in the root, so that dnf5 can update the system. The # host's rpm installs (--ignorearch: it is $RPM_ARCH); scriptlets # run in the root through binfmt's qemu-$PROC, as mapped root. local list="$BUILD/rootfs-rpms" # (noarch: ca-certificates, fenriros-release, ...) find "$rpmdir" "$WORK/rpmbuild/RPMS/noarch" -name '*.rpm' ! -name '*-dev-*' ! -name '*-devel-*' \ ! -name '*-debuginfo-*' 2>/dev/null | sort >"$list" msg "rootfs: installing $(wc -l <"$list") RPMs" run rootfs unshare -r rpm --root "$ROOTFS" --initdb if ! unshare -r rpm --root "$ROOTFS" --ignorearch -ivh $(cat "$list") >>"$LOGS/rootfs.log" 2>&1; then grep -E 'is needed by|conflicts with' "$LOGS/rootfs.log" | sort -u | head -40 >&2 die "rootfs: RPM dependencies unresolved (see above, log: $LOGS/rootfs.log)" fi mkdir -p "$ROOTFS/etc/rpm" install -m 644 "$FENRIR_FILES/rpm/macros.fenriros" "$ROOTFS/etc/rpm/" else run rootfs env DESTDIR="$ROOTFS" cmake --install "$BUILD/systempp" --strip run rootfs env DESTDIR="$ROOTFS" cmake --install "$BUILD/fresh" --strip run rootfs env DESTDIR="$ROOTFS" cmake --install "$BUILD/syslite" --strip Loading @@ -426,9 +487,10 @@ step_rootfs() { rm -rf "$ROOTFS$PREFIX/include" "$ROOTFS$PREFIX/lib/cmake" "$ROOTFS$PREFIX/share/doc" find "$ROOTFS$PREFIX/lib" -maxdepth 1 -name '*.a' -delete for l in dl rt; do ln -sf libc.so "$ROOTFS$PREFIX/lib/lib$l.so"; done fi # PID 1 [[ -x $ROOTFS$PREFIX/sbin/syslite ]] || die "no /usr/sbin/syslite in the rootfs" ln -sf syslite "$ROOTFS$PREFIX/sbin/init" [[ -e $ROOTFS$PREFIX/sbin/init ]] || ln -sf syslite "$ROOTFS$PREFIX/sbin/init" msg "rootfs: kernel modules" run rootfs kmake INSTALL_MOD_PATH="$ROOTFS$PREFIX" INSTALL_MOD_STRIP=1 DEPMOD=true modules_install Loading Loading @@ -513,6 +575,128 @@ step_installer() { msg "installer ready: $OUT/installer.uimg ($(du -h "$OUT/installer.uimg" | cut -f1))" } # cross_fixup <pkg> -- what the x86 build chroot has besides a package's RPM # and later specs rely on, added to the sysroot after <pkg> cross_fixup() { case "$1" in zstd) # zstd.spec builds with make: no CMake package. The chroot's comes # from step_rpm's CMake build of zstd; containerd needs zstd::libzstd mkdir -p "$SYSROOT$PREFIX/lib/cmake/zstd" cat >"$SYSROOT$PREFIX/lib/cmake/zstd/zstdConfig.cmake" <<'EOF' # generated by build-cross.sh: zstd.spec installs only libzstd.a + libzstd.pc get_filename_component(_zstd_prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) if(NOT TARGET zstd::libzstd) add_library(zstd::libzstd STATIC IMPORTED) set_target_properties(zstd::libzstd PROPERTIES IMPORTED_LOCATION "${_zstd_prefix}/lib/libzstd.a" INTERFACE_INCLUDE_DIRECTORIES "${_zstd_prefix}/include") add_library(zstd::libzstd_static ALIAS zstd::libzstd) endif() set(zstd_FOUND TRUE) EOF ;; esac } # cross_prebuild <pkg> <spec> -- for specs that only repackage something the # x86 build chroot built outside RPM: build it for the target, prints the # spec rpmbuild is to use cross_prebuild() { local pkg="$1" spec="$2" case "$pkg" in libsqlite3) # build-chroot.sh's step_rpm: the amalgamation into /usr/local, which # libsqlite3.spec packages -- here under the sysroot local v=3470200 src="$WORK/chroot-src/src/sqlite-autoconf-3470200" out="$SYSROOT/usr/local" if [[ ! -f $src/sqlite3.c ]]; then mkdir -p "$WORK/chroot-src/src" curl -fsSL "https://www.sqlite.org/2024/sqlite-autoconf-$v.tar.gz" | tar -xz -C "$WORK/chroot-src/src" fi mkdir -p "$out/lib/pkgconfig" "$out/include" "$TOOLCHAIN/bin/$TRIPLE-cc" -O2 -DSQLITE_ENABLE_FTS5 -DSQLITE_THREADSAFE=1 -c "$src/sqlite3.c" -o "$BUILD/sqlite3.o" rm -f "$out/lib/libsqlite3.a" "$TOOLCHAIN/bin/$TRIPLE-ar" rcs "$out/lib/libsqlite3.a" "$BUILD/sqlite3.o" cp "$src/sqlite3.h" "$src/sqlite3ext.h" "$out/include/" printf 'prefix=/usr\nlibdir=${prefix}/lib\nincludedir=${prefix}/include\n\nName: SQLite\nDescription: SQL database engine\nVersion: 3.47.2\nLibs: -L${libdir} -lsqlite3\nCflags: -I${includedir}\n' >"$out/lib/pkgconfig/sqlite3.pc" sed "s|/usr/local/|$out/|g" "$spec" >"$spec.cross" echo "$spec.cross" ;; *) echo "$spec" ;; esac } # (the host rpm's pkgconfig dependency generator is off: it only runs where # pkg-config is installed -- not in the x86 build chroot -- and FenrirOS has # no package that provides /usr/bin/pkg-config) # packages: the FenrirOS specs of CROSS_PACKAGES as $RPM_ARCH RPMs, built # by the host's rpmbuild (--target) with the cross toolchain: the specs # build with plain `cmake -S . -B build`, and CMake takes the toolchain file # from the environment (CMAKE_TOOLCHAIN_FILE, CMake 3.21+). Every finished # package (its -dev subpackages too) is unpacked into the sysroot, where # the following ones find it. Sources come from build-chroot.sh's # stage_sources ('sources' step). step_packages() { [[ -f $TOOLCHAIN/$TRIPLE.cmake ]] || die "toolchain missing -- run the 'toolchain' step first" [[ -d $FENRIR_FILES/rpm/specs ]] || die "no FenrirOS specs in $FENRIR_FILES (set FENRIR_FILES)" command -v rpmbuild >/dev/null && command -v rpm2cpio >/dev/null || die "rpmbuild/rpm2cpio missing" local top="$WORK/rpmbuild" pkg log mkdir -p "$top"/{BUILD,BUILDROOT,RPMS,SRPMS,SOURCES,SPECS} "$LOGS/packages" msg "packages: staging sources ($CROSS_PACKAGES)" run sources env WORK="$WORK/chroot-src" SOURCES_DIR="$top/SOURCES" FENRIR_FILES="$FENRIR_FILES" \ PACKAGES="$CROSS_PACKAGES" "$SYSTEMPP_SRC/build-chroot.sh" sources # macros.fenriros with this tree's paths sed -e "s|/build/rpmbuild|$top|g" "$FENRIR_FILES/rpm/macros.fenriros" >"$top/macros.cross" # specs that call the compiler by name (`make CC=clang`, zstd): first in # PATH, clang/cc/gcc and the binutils names are the target's local shadow="$TOOLCHAIN/shadow" t mkdir -p "$shadow" for t in clang cc gcc; do ln -sf "$TOOLCHAIN/bin/$TRIPLE-cc" "$shadow/$t"; done for t in clang++ c++ g++; do ln -sf "$TOOLCHAIN/bin/$TRIPLE-c++" "$shadow/$t"; done for t in ar ranlib nm strip objcopy objdump readelf; do ln -sf "$TOOLCHAIN/bin/$TRIPLE-$t" "$shadow/$t"; done local ok=() failed=() for pkg in $CROSS_PACKAGES; do log="$LOGS/packages/$pkg.log" msg "packages: rpmbuild $pkg ($RPM_ARCH)" touch "$top/.built-$pkg" local spec spec="$(cross_prebuild "$pkg" "$top/SPECS/$pkg.spec" 2>>"$log")" || { failed+=("$pkg(prebuild)"); continue; } # systempp itself is built with plain clang and its own toolchain # file (the wrappers need its finished libc.so) local pkgpath="$shadow:$PATH" pkgtc="$TOOLCHAIN/$TRIPLE.cmake" if [[ $pkg == systempp ]]; then pkgpath="$PATH"; pkgtc="$TOOLCHAIN_FILE"; fi if env PATH="$pkgpath" CC="$TOOLCHAIN/bin/$TRIPLE-cc" CXX="$TOOLCHAIN/bin/$TRIPLE-c++" \ SYSTEMPP_BUILTINS="$BUILTINS" \ AR="$TOOLCHAIN/bin/$TRIPLE-ar" RANLIB="$TOOLCHAIN/bin/$TRIPLE-ranlib" \ STRIP="$TOOLCHAIN/bin/$TRIPLE-strip" \ CMAKE_TOOLCHAIN_FILE="$pkgtc" \ CMAKE_POLICY_VERSION_MINIMUM=3.5 \ QEMU_LD_PREFIX="$SYSROOT" QEMU_CPU=e500v2 \ PKG_CONFIG_SYSROOT_DIR="$SYSROOT" \ PKG_CONFIG_LIBDIR="$SYSROOT$PREFIX/lib/pkgconfig:$SYSROOT$PREFIX/share/pkgconfig" \ rpmbuild -bb --nodeps --target "$RPM_ARCH-linux" \ --load "$top/macros.cross" --define "_topdir $top" \ --define "_enable_debug_packages 0" --define "debug_package %{nil}" \ --define "__os_install_post %{nil}" --define "_build_id_links none" \ --define "_default_patch_fuzz 2" \ --define "__pkgconfig_requires %{nil}" --define "__pkgconfig_provides %{nil}" \ "$spec" >>"$log" 2>&1; then ok+=("$pkg") local r while IFS= read -r r; do (cd "$SYSROOT" && rpm2cpio "$r" | cpio -idmu --quiet) >>"$log" 2>&1 || failed+=("$pkg(unpack)") done < <(find "$top/RPMS" -name '*.rpm' -newer "$top/.built-$pkg") cross_fixup "$pkg" >>"$log" 2>&1 else failed+=("$pkg") printf ' %s FAILED, last lines of %s:\n' "$pkg" "$log" >&2 tail -n 15 "$log" | sed 's/^/ /' >&2 fi done msg "packages: built ${#ok[@]}: ${ok[*]}" ((${#failed[@]} == 0)) || die "packages: failed: ${failed[*]} (logs: $LOGS/packages)" } step_clean() { msg "removing $WORK (keeping $SRCDIR)" rm -rf --one-file-system "$WORK" Loading @@ -521,12 +705,13 @@ step_clean() { # --------------------------------------------------------------------------- ALL_STEPS=(headers systempp builtins toolchain fresh syslite kernel rootfs image installer) # not in the default run: packages (needs the FenrirOS specs, FENRIR_FILES) steps=("$@") ((${#steps[@]})) || steps=("${ALL_STEPS[@]}") for s in "${steps[@]}"; do case "$s" in headers|systempp|builtins|toolchain|fresh|syslite|kernel|rootfs|image|installer) headers|systempp|builtins|toolchain|fresh|syslite|kernel|rootfs|image|installer|packages) check_deps; mkdir -p "$WORK" "$BUILD"; "step_$s" ;; clean) step_clean ;; -h|--help) sed -n '2,/^$/s/^# \{0,1\}//p' "$0"; exit 0 ;; Loading cmake/toolchain-powerpc-e500.cmake +6 −0 Changes for cmake/toolchain-powerpc-e500.cmake: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,12 @@ set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld") set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld") set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld") # the compiler runtime libc.so and the tests link (see src/CMakeLists.txt); # from the environment for builds that can't pass -D (rpmbuild) if(DEFINED ENV{SYSTEMPP_BUILTINS} AND NOT SYSTEMPP_BUILTINS) set(SYSTEMPP_BUILTINS "$ENV{SYSTEMPP_BUILTINS}" CACHE FILEPATH "compiler-rt builtins archive") endif() # no libc for the target yet: compiler checks must not try to link set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) Loading src/test/e2e/CMakeLists.txt +6 −0 Changes for src/test/e2e/CMakeLists.txt: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3761,3 +3761,9 @@ target_link_libraries(e2e_thread_reclaim PRIVATE add_dependencies(e2e_thread_reclaim crti Scrt1 crtbeginS crtn systempp) add_test(NAME e2e_thread_reclaim COMMAND e2e_thread_reclaim) # Under qemu-user /proc/self/status describes the emulator process (a # 32-bit powerpc test sees a 4.4 GB VM that grows with qemu's translation # cache): the address-space check is only meaningful natively. if(CMAKE_CROSSCOMPILING_EMULATOR) set_tests_properties(e2e_thread_reclaim PROPERTIES DISABLED TRUE) endif() Loading
boards/nas-itx/nas-itx.dts +14 −4 Changes for boards/nas-itx/nas-itx.dts: 14 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ #address-cells = <1>; #size-cells = <1>; /* same layout as U-Boot's mtdparts (nas_itx_NAND_defconfig) */ /* the vendor U-Boot's layout: U-Boot at 0, its environment * at 0x300000 (found the hard way: saveenv there) */ partition@0 { /* SPL, TPL and U-Boot */ reg = <0x00000000 0x00100000>; Loading @@ -61,8 +62,10 @@ }; partition@100000 { /* an old U-Boot environment (not the current one) */ reg = <0x00100000 0x00100000>; label = "env"; label = "env-old"; read-only; }; partition@200000 { Loading @@ -71,8 +74,15 @@ }; partition@300000 { /* uImage, up to 16 MiB */ reg = <0x00300000 0x01000000>; /* the environment of the vendor U-Boot 2012.07 * (its saveenv erases and writes this block) */ reg = <0x00300000 0x00100000>; label = "env"; }; partition@400000 { /* uImage, up to 15 MiB */ reg = <0x00400000 0x00f00000>; label = "kernel"; }; Loading
build-chroot.sh +27 −3 Changes for build-chroot.sh: 27 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -164,6 +164,8 @@ ISO_HOSTNAME="${ISO_HOSTNAME:-fenriros}" # FenrirOS files (rpm specs, macros, GNU-free CMake builds) from the # scripts repository, used by the 'rpm' and 'packages' steps FENRIR_FILES="$(realpath -m "${FENRIR_FILES:-$SYSTEMPP_SRC/../scripts/files}")" # where stage_sources() puts the RPM sources: the chroot's rpmbuild tree; # the 'sources' step (build-cross.sh) points it elsewhere CMAKE_REF="${CMAKE_REF:-v4.4.3}" JOBS="${JOBS:-$(nproc)}" HOST_CC="${HOST_CC:-clang}" Loading @@ -180,6 +182,7 @@ CHROOT="$WORK/chroot" LOGS="$WORK/logs" BUILD="$WORK/build" RPMROOT="$WORK/rpmroot" SOURCES_DIR="$(realpath -m "${SOURCES_DIR:-$CHROOT/build/rpmbuild/SOURCES}")" msg() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } die() { printf '\033[1;31mERROR:\033[0m %s\n' "$*" >&2; exit 1; } Loading Loading @@ -1021,7 +1024,7 @@ fetch_url() { [[ -s $cache/$f.part ]] || die "could not download $f (tried: $*)" mv "$cache/$f.part" "$cache/$f" fi cp "$cache/$f" "$CHROOT/build/rpmbuild/SOURCES/$f" cp "$cache/$f" "$SOURCES_DIR/$f" } # The kernel options build_kernel() in build-os.sh adds to x86_64's Loading Loading @@ -1208,7 +1211,7 @@ llvm_wrappers() { # stage_sources <spec> -- everything its Source/Patch lines name, into # the chroot's SOURCES stage_sources() { local spec="$1" pkg name version srcdir="$CHROOT/build/rpmbuild/SOURCES" local spec="$1" pkg name version srcdir="$SOURCES_DIR" pkg="$(basename "$spec" .spec)" name="$(spec_field "$spec" Name)"; version="$(spec_field "$spec" Version)" mkdir -p "$srcdir" Loading Loading @@ -1323,7 +1326,7 @@ stage_sources() { if [[ $src == http*://* ]]; then fetch_url "$f" "${src%%#*}" elif [[ $pkg == kernel && $f == kernel-config-* ]]; then kernel_config "$version" [[ -n ${KERNEL_CONFIG_SKIP:-} ]] || kernel_config "$version" elif [[ $pkg == llvm-project && $f == llvm-project-wrappers.tar.gz ]]; then llvm_wrappers "$version" "$srcdir/$f" # local files: named <dir>-<file> after the scripts repo's Loading Loading @@ -1833,6 +1836,26 @@ chroot_unmounted() { $mnts" } # sources: only the RPM sources of $PACKAGES into $SOURCES_DIR (and the # specs into $SOURCES_DIR/../SPECS), no chroot -- for build-cross.sh, which # runs rpmbuild for another architecture on the host. The kernel's # config is that build's business (it skips kernel-config-*). step_sources() { local pkg spec mkdir -p "$SOURCES_DIR" "$SOURCES_DIR/../SPECS" for pkg in $PACKAGES; do spec="$FENRIR_FILES/rpm/specs/$pkg.spec" [[ -f $spec ]] || die "no spec $spec" cp "$spec" "$SOURCES_DIR/../SPECS/" if [[ $pkg == kernel ]]; then KERNEL_CONFIG_SKIP=1 stage_sources "$spec" else stage_sources "$spec" fi done msg "sources: $PACKAGES -> $SOURCES_DIR" } step_clean() { chroot_unmounted msg "removing $BUILD $SYSROOT $RPMROOT $TOOLCHAIN $CHROOT $LOGS (keeping llvm-project)" Loading @@ -1849,6 +1872,7 @@ for s in "${steps[@]}"; do case "$s" in systempp|toolchain|host-tblgen|llvm|fresh|tools|rpm|chroot|packages|repo|iso|docker|fenstore) check_deps; mkdir -p "$WORK" "$BUILD"; "step_${s//-/_}" ;; sources) mkdir -p "$WORK" "$LOGS"; step_sources ;; enter) step_enter ;; clean) step_clean ;; -h|--help) sed -n '2,/^$/s/^# \{0,1\}//p' "$0"; exit 0 ;; Loading
build-cross.sh +187 −2 Changes for build-cross.sh: 187 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -82,6 +82,17 @@ HOST_CXX="${HOST_CXX:-clang++}" JOBS="${JOBS:-$(nproc)}" HOSTNAME_FENRIR="${HOSTNAME_FENRIR:-$BOARD}" FENRIR_FILES="$(realpath -m "${FENRIR_FILES:-$SYSTEMPP_SRC/../scripts/files}")" # the RPM architecture of the board's packages RPM_ARCH="${RPM_ARCH:-ppc}" # FenrirOS specs cross-built by the 'packages' step, in dependency order # (libyaml before libconfplus: its backends need it, which the x86 chroot # just happens to have) CROSS_PACKAGES="${CROSS_PACKAGES:-systempp fresh zlib zstd bzip2 libjson-c libbrotli libcmdplus libuuidp libnetplus libyaml libconfplus libhttppp libressl syslite sharedd adconnect storaged iscsid upsd firewalld tinyxml2 snmpdd ntpplus containerd webctl popt lua file libelf libsqlite3 rpm ca-certificates fenriros-release liblzma libxml2 libarchive glib2 curl libsolv librepo fmt toml11 libsmartcols dnf5}" PREFIX=/usr INTERP="$PREFIX/lib/ld-linux-$PROC.so" BUILD="$WORK/build" Loading Loading @@ -280,6 +291,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # host tools a target build must not pick up: documentation (the specs # package what the build chroot, which has no Doxygen, produces) set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen TRUE) # LibreSSL portable announces powerpc bignum assembler routines # (crypto/bn/arch/powerpc) it has no sources for: its C implementation set(ENABLE_ASM OFF CACHE BOOL "no assembler routines (LibreSSL on 32-bit powerpc)") EOF if command -v qemu-$PROC >/dev/null; then echo "set(CMAKE_CROSSCOMPILING_EMULATOR $(command -v qemu-$PROC) -cpu e500v2 -L $SYSROOT)" >>"$TOOLCHAIN/$TRIPLE.cmake" Loading Loading @@ -357,6 +374,7 @@ NAME="FenrirOS" ID=fenriros PRETTY_NAME="FenrirOS ($BOARD)" EOF # the accounts build-chroot.sh's write_system_config sets up cat >"$root/etc/user.yaml" <<'EOF' - name: root passwd: x Loading @@ -365,12 +383,34 @@ EOF gecos: root dir: /root shell: /bin/sh - name: sshd passwd: x uid: 74 gid: 74 gecos: sshd privilege separation dir: /var/empty shell: /bin/false - name: webctl passwd: x uid: 990 gid: 990 gecos: webctl web interface dir: /var/empty shell: /bin/false EOF cat >"$root/etc/group.yaml" <<'EOF' - name: root passwd: x gid: 0 members: [] - name: sshd passwd: x gid: 74 members: [] - name: webctl passwd: x gid: 990 members: [] EOF cat >"$root/etc/shadow.yaml" <<'EOF' - name: root Loading Loading @@ -408,9 +448,11 @@ EOF step_rootfs() { local d if ! compgen -G "$WORK/rpmbuild/RPMS/$RPM_ARCH/systempp-[0-9]*.rpm" >/dev/null; then for d in systempp fresh syslite; do [[ -f $BUILD/$d/build.ninja ]] || die "$d not built -- run the '$d' step first" done fi [[ -d $KBUILD/arch ]] || die "kernel not built -- run the 'kernel' step first" msg "rootfs: assembling $ROOTFS" rm -rf --one-file-system "$ROOTFS" Loading @@ -419,6 +461,25 @@ step_rootfs() { chmod 700 "$ROOTFS/root" ln -s usr/bin "$ROOTFS/bin"; ln -s usr/sbin "$ROOTFS/sbin"; ln -s usr/lib "$ROOTFS/lib" local rpmdir="$WORK/rpmbuild/RPMS/$RPM_ARCH" if compgen -G "$rpmdir/systempp-[0-9]*.rpm" >/dev/null; then # RPM-based (the 'packages' step ran): every runtime package, with # the rpmdb in the root, so that dnf5 can update the system. The # host's rpm installs (--ignorearch: it is $RPM_ARCH); scriptlets # run in the root through binfmt's qemu-$PROC, as mapped root. local list="$BUILD/rootfs-rpms" # (noarch: ca-certificates, fenriros-release, ...) find "$rpmdir" "$WORK/rpmbuild/RPMS/noarch" -name '*.rpm' ! -name '*-dev-*' ! -name '*-devel-*' \ ! -name '*-debuginfo-*' 2>/dev/null | sort >"$list" msg "rootfs: installing $(wc -l <"$list") RPMs" run rootfs unshare -r rpm --root "$ROOTFS" --initdb if ! unshare -r rpm --root "$ROOTFS" --ignorearch -ivh $(cat "$list") >>"$LOGS/rootfs.log" 2>&1; then grep -E 'is needed by|conflicts with' "$LOGS/rootfs.log" | sort -u | head -40 >&2 die "rootfs: RPM dependencies unresolved (see above, log: $LOGS/rootfs.log)" fi mkdir -p "$ROOTFS/etc/rpm" install -m 644 "$FENRIR_FILES/rpm/macros.fenriros" "$ROOTFS/etc/rpm/" else run rootfs env DESTDIR="$ROOTFS" cmake --install "$BUILD/systempp" --strip run rootfs env DESTDIR="$ROOTFS" cmake --install "$BUILD/fresh" --strip run rootfs env DESTDIR="$ROOTFS" cmake --install "$BUILD/syslite" --strip Loading @@ -426,9 +487,10 @@ step_rootfs() { rm -rf "$ROOTFS$PREFIX/include" "$ROOTFS$PREFIX/lib/cmake" "$ROOTFS$PREFIX/share/doc" find "$ROOTFS$PREFIX/lib" -maxdepth 1 -name '*.a' -delete for l in dl rt; do ln -sf libc.so "$ROOTFS$PREFIX/lib/lib$l.so"; done fi # PID 1 [[ -x $ROOTFS$PREFIX/sbin/syslite ]] || die "no /usr/sbin/syslite in the rootfs" ln -sf syslite "$ROOTFS$PREFIX/sbin/init" [[ -e $ROOTFS$PREFIX/sbin/init ]] || ln -sf syslite "$ROOTFS$PREFIX/sbin/init" msg "rootfs: kernel modules" run rootfs kmake INSTALL_MOD_PATH="$ROOTFS$PREFIX" INSTALL_MOD_STRIP=1 DEPMOD=true modules_install Loading Loading @@ -513,6 +575,128 @@ step_installer() { msg "installer ready: $OUT/installer.uimg ($(du -h "$OUT/installer.uimg" | cut -f1))" } # cross_fixup <pkg> -- what the x86 build chroot has besides a package's RPM # and later specs rely on, added to the sysroot after <pkg> cross_fixup() { case "$1" in zstd) # zstd.spec builds with make: no CMake package. The chroot's comes # from step_rpm's CMake build of zstd; containerd needs zstd::libzstd mkdir -p "$SYSROOT$PREFIX/lib/cmake/zstd" cat >"$SYSROOT$PREFIX/lib/cmake/zstd/zstdConfig.cmake" <<'EOF' # generated by build-cross.sh: zstd.spec installs only libzstd.a + libzstd.pc get_filename_component(_zstd_prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) if(NOT TARGET zstd::libzstd) add_library(zstd::libzstd STATIC IMPORTED) set_target_properties(zstd::libzstd PROPERTIES IMPORTED_LOCATION "${_zstd_prefix}/lib/libzstd.a" INTERFACE_INCLUDE_DIRECTORIES "${_zstd_prefix}/include") add_library(zstd::libzstd_static ALIAS zstd::libzstd) endif() set(zstd_FOUND TRUE) EOF ;; esac } # cross_prebuild <pkg> <spec> -- for specs that only repackage something the # x86 build chroot built outside RPM: build it for the target, prints the # spec rpmbuild is to use cross_prebuild() { local pkg="$1" spec="$2" case "$pkg" in libsqlite3) # build-chroot.sh's step_rpm: the amalgamation into /usr/local, which # libsqlite3.spec packages -- here under the sysroot local v=3470200 src="$WORK/chroot-src/src/sqlite-autoconf-3470200" out="$SYSROOT/usr/local" if [[ ! -f $src/sqlite3.c ]]; then mkdir -p "$WORK/chroot-src/src" curl -fsSL "https://www.sqlite.org/2024/sqlite-autoconf-$v.tar.gz" | tar -xz -C "$WORK/chroot-src/src" fi mkdir -p "$out/lib/pkgconfig" "$out/include" "$TOOLCHAIN/bin/$TRIPLE-cc" -O2 -DSQLITE_ENABLE_FTS5 -DSQLITE_THREADSAFE=1 -c "$src/sqlite3.c" -o "$BUILD/sqlite3.o" rm -f "$out/lib/libsqlite3.a" "$TOOLCHAIN/bin/$TRIPLE-ar" rcs "$out/lib/libsqlite3.a" "$BUILD/sqlite3.o" cp "$src/sqlite3.h" "$src/sqlite3ext.h" "$out/include/" printf 'prefix=/usr\nlibdir=${prefix}/lib\nincludedir=${prefix}/include\n\nName: SQLite\nDescription: SQL database engine\nVersion: 3.47.2\nLibs: -L${libdir} -lsqlite3\nCflags: -I${includedir}\n' >"$out/lib/pkgconfig/sqlite3.pc" sed "s|/usr/local/|$out/|g" "$spec" >"$spec.cross" echo "$spec.cross" ;; *) echo "$spec" ;; esac } # (the host rpm's pkgconfig dependency generator is off: it only runs where # pkg-config is installed -- not in the x86 build chroot -- and FenrirOS has # no package that provides /usr/bin/pkg-config) # packages: the FenrirOS specs of CROSS_PACKAGES as $RPM_ARCH RPMs, built # by the host's rpmbuild (--target) with the cross toolchain: the specs # build with plain `cmake -S . -B build`, and CMake takes the toolchain file # from the environment (CMAKE_TOOLCHAIN_FILE, CMake 3.21+). Every finished # package (its -dev subpackages too) is unpacked into the sysroot, where # the following ones find it. Sources come from build-chroot.sh's # stage_sources ('sources' step). step_packages() { [[ -f $TOOLCHAIN/$TRIPLE.cmake ]] || die "toolchain missing -- run the 'toolchain' step first" [[ -d $FENRIR_FILES/rpm/specs ]] || die "no FenrirOS specs in $FENRIR_FILES (set FENRIR_FILES)" command -v rpmbuild >/dev/null && command -v rpm2cpio >/dev/null || die "rpmbuild/rpm2cpio missing" local top="$WORK/rpmbuild" pkg log mkdir -p "$top"/{BUILD,BUILDROOT,RPMS,SRPMS,SOURCES,SPECS} "$LOGS/packages" msg "packages: staging sources ($CROSS_PACKAGES)" run sources env WORK="$WORK/chroot-src" SOURCES_DIR="$top/SOURCES" FENRIR_FILES="$FENRIR_FILES" \ PACKAGES="$CROSS_PACKAGES" "$SYSTEMPP_SRC/build-chroot.sh" sources # macros.fenriros with this tree's paths sed -e "s|/build/rpmbuild|$top|g" "$FENRIR_FILES/rpm/macros.fenriros" >"$top/macros.cross" # specs that call the compiler by name (`make CC=clang`, zstd): first in # PATH, clang/cc/gcc and the binutils names are the target's local shadow="$TOOLCHAIN/shadow" t mkdir -p "$shadow" for t in clang cc gcc; do ln -sf "$TOOLCHAIN/bin/$TRIPLE-cc" "$shadow/$t"; done for t in clang++ c++ g++; do ln -sf "$TOOLCHAIN/bin/$TRIPLE-c++" "$shadow/$t"; done for t in ar ranlib nm strip objcopy objdump readelf; do ln -sf "$TOOLCHAIN/bin/$TRIPLE-$t" "$shadow/$t"; done local ok=() failed=() for pkg in $CROSS_PACKAGES; do log="$LOGS/packages/$pkg.log" msg "packages: rpmbuild $pkg ($RPM_ARCH)" touch "$top/.built-$pkg" local spec spec="$(cross_prebuild "$pkg" "$top/SPECS/$pkg.spec" 2>>"$log")" || { failed+=("$pkg(prebuild)"); continue; } # systempp itself is built with plain clang and its own toolchain # file (the wrappers need its finished libc.so) local pkgpath="$shadow:$PATH" pkgtc="$TOOLCHAIN/$TRIPLE.cmake" if [[ $pkg == systempp ]]; then pkgpath="$PATH"; pkgtc="$TOOLCHAIN_FILE"; fi if env PATH="$pkgpath" CC="$TOOLCHAIN/bin/$TRIPLE-cc" CXX="$TOOLCHAIN/bin/$TRIPLE-c++" \ SYSTEMPP_BUILTINS="$BUILTINS" \ AR="$TOOLCHAIN/bin/$TRIPLE-ar" RANLIB="$TOOLCHAIN/bin/$TRIPLE-ranlib" \ STRIP="$TOOLCHAIN/bin/$TRIPLE-strip" \ CMAKE_TOOLCHAIN_FILE="$pkgtc" \ CMAKE_POLICY_VERSION_MINIMUM=3.5 \ QEMU_LD_PREFIX="$SYSROOT" QEMU_CPU=e500v2 \ PKG_CONFIG_SYSROOT_DIR="$SYSROOT" \ PKG_CONFIG_LIBDIR="$SYSROOT$PREFIX/lib/pkgconfig:$SYSROOT$PREFIX/share/pkgconfig" \ rpmbuild -bb --nodeps --target "$RPM_ARCH-linux" \ --load "$top/macros.cross" --define "_topdir $top" \ --define "_enable_debug_packages 0" --define "debug_package %{nil}" \ --define "__os_install_post %{nil}" --define "_build_id_links none" \ --define "_default_patch_fuzz 2" \ --define "__pkgconfig_requires %{nil}" --define "__pkgconfig_provides %{nil}" \ "$spec" >>"$log" 2>&1; then ok+=("$pkg") local r while IFS= read -r r; do (cd "$SYSROOT" && rpm2cpio "$r" | cpio -idmu --quiet) >>"$log" 2>&1 || failed+=("$pkg(unpack)") done < <(find "$top/RPMS" -name '*.rpm' -newer "$top/.built-$pkg") cross_fixup "$pkg" >>"$log" 2>&1 else failed+=("$pkg") printf ' %s FAILED, last lines of %s:\n' "$pkg" "$log" >&2 tail -n 15 "$log" | sed 's/^/ /' >&2 fi done msg "packages: built ${#ok[@]}: ${ok[*]}" ((${#failed[@]} == 0)) || die "packages: failed: ${failed[*]} (logs: $LOGS/packages)" } step_clean() { msg "removing $WORK (keeping $SRCDIR)" rm -rf --one-file-system "$WORK" Loading @@ -521,12 +705,13 @@ step_clean() { # --------------------------------------------------------------------------- ALL_STEPS=(headers systempp builtins toolchain fresh syslite kernel rootfs image installer) # not in the default run: packages (needs the FenrirOS specs, FENRIR_FILES) steps=("$@") ((${#steps[@]})) || steps=("${ALL_STEPS[@]}") for s in "${steps[@]}"; do case "$s" in headers|systempp|builtins|toolchain|fresh|syslite|kernel|rootfs|image|installer) headers|systempp|builtins|toolchain|fresh|syslite|kernel|rootfs|image|installer|packages) check_deps; mkdir -p "$WORK" "$BUILD"; "step_$s" ;; clean) step_clean ;; -h|--help) sed -n '2,/^$/s/^# \{0,1\}//p' "$0"; exit 0 ;; Loading
cmake/toolchain-powerpc-e500.cmake +6 −0 Changes for cmake/toolchain-powerpc-e500.cmake: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,12 @@ set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld") set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld") set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld") # the compiler runtime libc.so and the tests link (see src/CMakeLists.txt); # from the environment for builds that can't pass -D (rpmbuild) if(DEFINED ENV{SYSTEMPP_BUILTINS} AND NOT SYSTEMPP_BUILTINS) set(SYSTEMPP_BUILTINS "$ENV{SYSTEMPP_BUILTINS}" CACHE FILEPATH "compiler-rt builtins archive") endif() # no libc for the target yet: compiler checks must not try to link set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) Loading
src/test/e2e/CMakeLists.txt +6 −0 Changes for src/test/e2e/CMakeLists.txt: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3761,3 +3761,9 @@ target_link_libraries(e2e_thread_reclaim PRIVATE add_dependencies(e2e_thread_reclaim crti Scrt1 crtbeginS crtn systempp) add_test(NAME e2e_thread_reclaim COMMAND e2e_thread_reclaim) # Under qemu-user /proc/self/status describes the emulator process (a # 32-bit powerpc test sees a 4.4 GB VM that grows with qemu's translation # cache): the address-space check is only meaningful natively. if(CMAKE_CROSSCOMPILING_EMULATOR) set_tests_properties(e2e_thread_reclaim PROPERTIES DISABLED TRUE) endif()