Add OpenWrt mipsel_24kc build

This commit is contained in:
klzgrad 2019-11-28 23:47:32 +08:00
parent c054bf656a
commit 2c78ab9dac
7 changed files with 110 additions and 25 deletions

View File

@ -7,6 +7,7 @@ matrix:
- name: "linux-x64" - name: "linux-x64"
os: linux os: linux
dist: bionic dist: bionic
env: EXTRA_FLAGS='target_cpu="x64"'
- name: "linux-x86" - name: "linux-x86"
os: linux os: linux
dist: bionic dist: bionic
@ -19,6 +20,10 @@ matrix:
os: linux os: linux
dist: bionic dist: bionic
env: EXTRA_FLAGS='target_cpu="arm"' 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" - name: "osx"
os: osx os: osx
osx_image: xcode10.2 osx_image: xcode10.2
@ -33,7 +38,10 @@ addons:
packages: packages:
- ninja - ninja
- ccache - ccache
cache: ccache cache:
directories:
- $HOME/.ccache
- src/out/sysroot-build/openwrt
script: script:
- ./tools/import-upstream.sh - ./tools/import-upstream.sh
- ( cd src; ./get-clang.sh ) - ( cd src; ./get-clang.sh )

View File

@ -34,6 +34,7 @@ fi
flags="$flags"' flags="$flags"'
is_clang=true is_clang=true
linux_use_bundled_binutils=false linux_use_bundled_binutils=false
use_sysroot=false
fatal_linker_warnings=false fatal_linker_warnings=false
treat_warnings_as_errors=false treat_warnings_as_errors=false
@ -62,6 +63,12 @@ if [ "$(uname)" = Linux ]; then
ozone_auto_platforms=false ozone_auto_platforms=false
ozone_platform="headless" ozone_platform="headless"
ozone_platform_headless=true' ozone_platform_headless=true'
. ./get-sysroot.sh
sysroot=$(get_sysroot)
if [ "$sysroot" ]; then
flags="$flags
target_sysroot=\"//$sysroot\""
fi
fi fi
rm -rf "./$out" rm -rf "./$out"

View File

@ -45,16 +45,23 @@ DEBIAN_PACKAGES_ARM64='
libitm1 libitm1
libubsan0 libubsan0
' '
DEBIAN_PACKAGES_MIPS64EL='
'
# Disables libdbus workarounds # Disables libdbus workarounds
ln -sf /bin/true strip ln -sf /bin/true strip
ln -sf /bin/true arm-linux-gnueabihf-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" export PATH="$PWD:$PATH"
cp() { cp() {
[ "${1##*/}" = libdbus-1-3-symbols ] && return [ "${1##*/}" = libdbus-1-3-symbols ] && return
/bin/cp "$@" /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" . "${SCRIPT_DIR}/sysroot-creator.sh"

View File

@ -7,30 +7,22 @@ case "$ARCH" in
MSYS*) ARCH=Windows;; MSYS*) ARCH=Windows;;
esac esac
eval "$EXTRA_FLAGS"
build_sysroot() { build_sysroot() {
local lower="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
./build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh "BuildSysroot$1" ./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 if [ "$ARCH" = Linux ]; then
build_sysroot Amd64 if [ "$OPENWRT_FLAGS" ]; then
case "$target_cpu" in ./get-openwrt.sh
arm64) else
build_sysroot ARM64 eval "$EXTRA_FLAGS"
;; case "$target_cpu" in
arm) x64) build_sysroot Amd64;;
build_sysroot I386 x86) build_sysroot I386;;
build_sysroot ARM arm64) build_sysroot ARM64;;
;; arm) build_sysroot ARM;;
x86) esac
build_sysroot I386 fi
;;
esac
fi fi
# Clang # Clang

47
src/get-openwrt.sh Executable file
View File

@ -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

21
src/get-sysroot.sh Normal file
View File

@ -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
}

View File

@ -2,12 +2,15 @@
[ "$1" ] || exit 1 [ "$1" ] || exit 1
naive="$1" naive="$1"
eval "$EXTRA_FLAGS"
if [ "$(uname)" = Linux ]; then if [ "$(uname)" = Linux ]; then
. src/get-sysroot.sh
sysroot=$(get_sysroot)
eval "$EXTRA_FLAGS"
case "$target_cpu" in case "$target_cpu" in
arm64) naive="qemu-aarch64 -L src/build/linux/debian_sid_arm64-sysroot $naive";; arm64) naive="qemu-aarch64 -L src/$sysroot $naive";;
arm) naive="qemu-arm -L src/build/linux/debian_sid_arm-sysroot $naive";; arm) naive="qemu-arm -L src/$sysroot $naive";;
x86) naive="qemu-i386 -L src/build/linux/debian_sid_i386-sysroot $naive";; x86) naive="qemu-i386 -L src/$sysroot $naive";;
mipsel) naive="qemu-mipsel -L src/$sysroot $naive";;
esac esac
fi fi