diff --git a/.travis.yml b/.travis.yml index 80f21f2082..3f2876efd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ matrix: - name: "linux-x64" os: linux dist: bionic + env: EXTRA_FLAGS='target_cpu="x64"' - name: "linux-x86" os: linux dist: bionic @@ -19,6 +20,10 @@ matrix: os: linux dist: bionic env: EXTRA_FLAGS='target_cpu="arm"' + - name: "openwrt-mipsel_24kc" + os: linux + dist: bionic + env: EXTRA_FLAGS='target_cpu="mipsel" mips_arch_variant="r2" mips_float_abi="soft" mips_tune="24kc" use_allocator="none" use_allocator_shim=false is_openwrt=true ldso_path="/lib/ld-musl-mipsel-sf.so.1" use_lld=false use_gold=false' OPENWRT_FLAGS='arch=mipsel_24kc release=19.07.0-rc1 gcc_ver=7.4.0 target=ramips subtarget=rt305x' - name: "osx" os: osx osx_image: xcode10.2 @@ -33,7 +38,10 @@ addons: packages: - ninja - ccache -cache: ccache +cache: + directories: + - $HOME/.ccache + - src/out/sysroot-build/openwrt script: - ./tools/import-upstream.sh - ( cd src; ./get-clang.sh ) diff --git a/src/build.sh b/src/build.sh index 4824ea364d..8840019179 100755 --- a/src/build.sh +++ b/src/build.sh @@ -34,6 +34,7 @@ fi flags="$flags"' is_clang=true linux_use_bundled_binutils=false + use_sysroot=false fatal_linker_warnings=false treat_warnings_as_errors=false @@ -62,6 +63,12 @@ if [ "$(uname)" = Linux ]; then ozone_auto_platforms=false ozone_platform="headless" ozone_platform_headless=true' + . ./get-sysroot.sh + sysroot=$(get_sysroot) + if [ "$sysroot" ]; then + flags="$flags + target_sysroot=\"//$sysroot\"" + fi fi rm -rf "./$out" diff --git a/src/build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh b/src/build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh index 9d5a51fc6c..4fa58e8976 100755 --- a/src/build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh +++ b/src/build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh @@ -45,16 +45,23 @@ DEBIAN_PACKAGES_ARM64=' libitm1 libubsan0 ' +DEBIAN_PACKAGES_MIPS64EL=' +' # Disables libdbus workarounds ln -sf /bin/true strip ln -sf /bin/true arm-linux-gnueabihf-strip +ln -sf /bin/true mipsel-linux-gnu-strip +ln -sf /bin/true mips64el-linux-gnuabi64-strip export PATH="$PWD:$PATH" cp() { [ "${1##*/}" = libdbus-1-3-symbols ] && return /bin/cp "$@" } +tar() { + echo tar "$@" +} -trap "cd $PWD; rm strip arm-linux-gnueabihf-strip" EXIT +trap "cd $PWD; rm strip *-strip" EXIT . "${SCRIPT_DIR}/sysroot-creator.sh" diff --git a/src/get-clang.sh b/src/get-clang.sh index 7622a5ae6f..87a58a8092 100755 --- a/src/get-clang.sh +++ b/src/get-clang.sh @@ -7,30 +7,22 @@ case "$ARCH" in MSYS*) ARCH=Windows;; esac -eval "$EXTRA_FLAGS" - build_sysroot() { - local lower="$(echo "$1" | tr '[:upper:]' '[:lower:]')" ./build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh "BuildSysroot$1" - rm -rf "./build/linux/debian_sid_$lower-sysroot" - mkdir "./build/linux/debian_sid_$lower-sysroot" - tar xf "./out/sysroot-build/sid/debian_sid_${lower}_sysroot.tar.xz" -C "./build/linux/debian_sid_$lower-sysroot" } if [ "$ARCH" = Linux ]; then - build_sysroot Amd64 - case "$target_cpu" in - arm64) - build_sysroot ARM64 - ;; - arm) - build_sysroot I386 - build_sysroot ARM - ;; - x86) - build_sysroot I386 - ;; - esac + if [ "$OPENWRT_FLAGS" ]; then + ./get-openwrt.sh + else + eval "$EXTRA_FLAGS" + case "$target_cpu" in + x64) build_sysroot Amd64;; + x86) build_sysroot I386;; + arm64) build_sysroot ARM64;; + arm) build_sysroot ARM;; + esac + fi fi # Clang diff --git a/src/get-openwrt.sh b/src/get-openwrt.sh new file mode 100755 index 0000000000..0ce461c018 --- /dev/null +++ b/src/get-openwrt.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +set -ex + +eval "$OPENWRT_FLAGS" + +sysroot=$PWD/out/sysroot-build/openwrt/$release/$arch +if [ -d $sysroot/lib ]; then + exit 0 +fi +mkdir -p $sysroot + +SDK_PATH=openwrt-sdk-$release-$target-${subtarget}_gcc-${gcc_ver}_musl.Linux-x86_64 +SDK_URL=https://downloads.openwrt.org/releases/$release/targets/$target/$subtarget/$SDK_PATH.tar.xz +rm -rf $SDK_PATH +curl $SDK_URL | tar xJf - +cd $SDK_PATH +./scripts/feeds update base packages +./scripts/feeds install libnss +make defconfig +for flag in ALL_NONSHARED ALL_KMODS ALL SIGNED_PACKAGES; do + sed -i "s/CONFIG_$flag=y/# CONFIG_$flag is not set/" .config +done +make oldconfig +make +full_root=staging_dir/toolchain-${arch}_gcc-${gcc_ver}_musl +cp -r staging_dir/target-${arch}_musl/usr $full_root +echo ' +./include +./lib/*.o +./lib/gcc/*/libgcc.a +./lib/libatomic.so* +./lib/libc.so +./lib/libdl.a +./lib/ld-* +./lib/libgcc_s.* +./lib/libm.a +./lib/libpthread.a +./lib/libresolv.a +./lib/librt.a +./usr +*.ld.bin +' >include.txt +tar cf - -C $full_root --hard-dereference . | tar xf - -C $sysroot --wildcards --wildcards-match-slash -T include.txt +rm include.txt +cd $sysroot/*-openwrt-linux-musl/bin +mv .ld.bin ld diff --git a/src/get-sysroot.sh b/src/get-sysroot.sh new file mode 100644 index 0000000000..1970e3d415 --- /dev/null +++ b/src/get-sysroot.sh @@ -0,0 +1,21 @@ +get_sysroot() { + if [ "$OPENWRT_FLAGS" ]; then + eval "$OPENWRT_FLAGS" + echo "out/sysroot-build/openwrt/$release/$arch" + return + fi + eval "$EXTRA_FLAGS" + if [ ! "$target_sysroot" ]; then + local sysroot_type + case "$target_cpu" in + x64) sysroot_type=amd64;; + x86) sysroot_type=i386;; + arm64) sysroot_type=arm64;; + arm) sysroot_type=arm;; + mipsel) sysroot_type=mips;; + esac + if [ "$sysroot_type" ]; then + echo "out/sysroot-build/sid/sid_${sysroot_type}_staging" + fi + fi +} diff --git a/tests/basic.sh b/tests/basic.sh index f27c51ea1e..a7306c6f0a 100755 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -2,12 +2,15 @@ [ "$1" ] || exit 1 naive="$1" -eval "$EXTRA_FLAGS" if [ "$(uname)" = Linux ]; then + . src/get-sysroot.sh + sysroot=$(get_sysroot) + eval "$EXTRA_FLAGS" case "$target_cpu" in - arm64) naive="qemu-aarch64 -L src/build/linux/debian_sid_arm64-sysroot $naive";; - arm) naive="qemu-arm -L src/build/linux/debian_sid_arm-sysroot $naive";; - x86) naive="qemu-i386 -L src/build/linux/debian_sid_i386-sysroot $naive";; + arm64) naive="qemu-aarch64 -L src/$sysroot $naive";; + arm) naive="qemu-arm -L src/$sysroot $naive";; + x86) naive="qemu-i386 -L src/$sysroot $naive";; + mipsel) naive="qemu-mipsel -L src/$sysroot $naive";; esac fi