From 03389d4b37ecab294c07874e67f44856ef40aee0 Mon Sep 17 00:00:00 2001 From: Tobias Faller Date: Sun, 4 Jul 2021 18:26:30 +0200 Subject: [PATCH] Added bundle to build GCC support library --- src/minimal_overlay/bundles/libgcc_s/.config | 5 +++ .../bundles/libgcc_s/01_get.sh | 38 ++++++++++++++++ .../bundles/libgcc_s/02_build.sh | 45 +++++++++++++++++++ .../bundles/libgcc_s/bundle.sh | 10 +++++ 4 files changed, 98 insertions(+) create mode 100644 src/minimal_overlay/bundles/libgcc_s/.config create mode 100755 src/minimal_overlay/bundles/libgcc_s/01_get.sh create mode 100755 src/minimal_overlay/bundles/libgcc_s/02_build.sh create mode 100755 src/minimal_overlay/bundles/libgcc_s/bundle.sh diff --git a/src/minimal_overlay/bundles/libgcc_s/.config b/src/minimal_overlay/bundles/libgcc_s/.config new file mode 100644 index 000000000..e0571cc1c --- /dev/null +++ b/src/minimal_overlay/bundles/libgcc_s/.config @@ -0,0 +1,5 @@ +# You can find the latest nano source bundles here: +# +# https://ftpmirror.gnu.org/gcc/ +# +GCC_SOURCE_URL=https://ftpmirror.gnu.org/gcc/gcc-11.1.0/gcc-11.1.0.tar.xz diff --git a/src/minimal_overlay/bundles/libgcc_s/01_get.sh b/src/minimal_overlay/bundles/libgcc_s/01_get.sh new file mode 100755 index 000000000..d03a66ce9 --- /dev/null +++ b/src/minimal_overlay/bundles/libgcc_s/01_get.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +# Read the common configuration properties. +DOWNLOAD_URL=`read_property GCC_SOURCE_URL` +USE_LOCAL_SOURCE=`read_property USE_LOCAL_SOURCE` + +# Grab everything after the last '/' character. +ARCHIVE_FILE=${DOWNLOAD_URL##*/} + +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." + USE_LOCAL_SOURCE="false" +fi + +cd $MAIN_SRC_DIR/source/overlay + +if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then + # Downloading gcc source bundle file. The '-c' option allows the download to resume. + echo "Downloading gcc source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local gcc source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted gcc. +echo "Removing gcc work area. This may take a while." +rm -rf $WORK_DIR/overlay/$BUNDLE_NAME +mkdir $WORK_DIR/overlay/$BUNDLE_NAME + +# Extract gcc to folder 'work/overlay/gcc'. +# Full path will be something like 'work/overlay/gcc/gcc-11.1.0'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/$BUNDLE_NAME + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/libgcc_s/02_build.sh b/src/minimal_overlay/bundles/libgcc_s/02_build.sh new file mode 100755 index 000000000..2f81cd28f --- /dev/null +++ b/src/minimal_overlay/bundles/libgcc_s/02_build.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +cd $WORK_DIR/overlay/$BUNDLE_NAME + +# Change to the gcc source directory which ls finds, e.g. 'gcc-11.1.0'. +cd $(ls -d gcc-*) + +if [ -f Makefile ] ; then + echo "Preparing '$BUNDLE_NAME' work area. This may take a while." + make -j $NUM_JOBS clean || true +else + echo "The clean phase for '$BUNDLE_NAME' has been skipped." +fi + +rm -rf $DEST_DIR + +echo "Configuring '$BUNDLE_NAME'." +CFLAGS="$CFLAGS" ./configure \ + --prefix=/usr \ + --enable-languages=c \ + --disable-multilib \ + --disable-static \ + --disable-libquadmath \ + --enable-shared + +echo "Building '$BUNDLE_NAME'." +make -j $NUM_JOBS all-gcc +make -j $NUM_JOBS all-target-libgcc + +echo "Installing '$BUNDLE_NAME'." +make -j $NUM_JOBS install-target-libgcc DESTDIR=$DEST_DIR + +mkdir -p $OVERLAY_ROOTFS/lib +# With '--remove-destination' all possibly existing soft links in +# '$OVERLAY_ROOTFS' will be overwritten correctly. +cp -r --remove-destination $DEST_DIR/usr/lib64/libgcc_s.so* \ + $OVERLAY_ROOTFS/lib/ + +echo "Bundle '$BUNDLE_NAME' has been installed." + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/libgcc_s/bundle.sh b/src/minimal_overlay/bundles/libgcc_s/bundle.sh new file mode 100755 index 000000000..e132bc25f --- /dev/null +++ b/src/minimal_overlay/bundles/libgcc_s/bundle.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +./01_get.sh +./02_build.sh + +cd $SRC_DIR