Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Tuxbuild #243

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ language: cpp
jobs:
include:
# linux
- name: "ARCH=arm32_v5 LD=ld.lld"
env: ARCH=arm32_v5 LD=ld.lld-11
- name: "ARCH=arm32_v6"
env: ARCH=arm32_v6
- name: "ARCH=arm32_v7 LD=ld.lld"
env: ARCH=arm32_v7 LD=ld.lld-11
- name: "ARCH=arm64 LD=ld.lld"
env: ARCH=arm64 LD=ld.lld-11
- name: "ARCH=mips"
env: ARCH=mips
- name: "ARCH=mipsel"
env: ARCH=mipsel
- name: "ARCH=ppc32"
env: ARCH=ppc32
- name: "ARCH=ppc64"
env: ARCH=ppc64
- name: "ARCH=ppc64le LD=ld.lld"
env: ARCH=ppc64le LD=ld.lld-11
- name: "ARCH=s390 BOOT=0"
env: ARCH=s390
- name: "ARCH=x86_64 LD=ld.lld"
env: ARCH=x86_64 LD=ld.lld-11
#- name: "ARCH=arm32_v5 LD=ld.lld"
#env: ARCH=arm32_v5 LD=ld.lld-11
#- name: "ARCH=arm32_v6"
#env: ARCH=arm32_v6
#- name: "ARCH=arm32_v7 LD=ld.lld"
#env: ARCH=arm32_v7 LD=ld.lld-11
#- name: "ARCH=arm64 LD=ld.lld"
#env: ARCH=arm64 LD=ld.lld-11
#- name: "ARCH=mips"
#env: ARCH=mips
#- name: "ARCH=mipsel"
#env: ARCH=mipsel
#- name: "ARCH=ppc32"
#env: ARCH=ppc32
#- name: "ARCH=ppc64"
#env: ARCH=ppc64
#- name: "ARCH=ppc64le LD=ld.lld"
#env: ARCH=ppc64le LD=ld.lld-11
#- name: "ARCH=s390 BOOT=0"
#env: ARCH=s390
#- name: "ARCH=x86_64 LD=ld.lld"
#env: ARCH=x86_64 LD=ld.lld-11
# linux (cron only)
#
# linux-next (cron only)
Expand Down Expand Up @@ -183,6 +183,15 @@ jobs:
- name: "ARCH=x86_64 LLVM_VERSION=10"
env: ARCH=x86_64 LLVM_VERSION=10
if: type = cron
- name: "ARCH=arm32_v7 LLVM_VERSION=9 TUX_BUILD=1"
env: ARCH=arm32_v7 LLVM_VERSION=9 TUX_BUILD=1
#if: type = cron
- name: "ARCH=arm64 LLVM_VERSION=9 TUX_BUILD=1"
env: ARCH=arm64 LLVM_VERSION=9 TUX_BUILD=1
#if: type = cron
- name: "ARCH=x86_64 LLVM_VERSION=9 TUX_BUILD=1"
env: ARCH=x86_64 LLVM_VERSION=9 TUX_BUILD=1
#if: type = cron
compiler: gcc
os: linux
cache:
Expand All @@ -196,6 +205,8 @@ script:
--env ARCH=${ARCH} \
--env LD=${LD} \
--env REPO=${REPO} \
--env TUX_BUILD=${TUX_BUILD} \
--env LLVM_VERSION=${LLVM_VERSION:-11} \
--rm \
--workdir /travis \
--volume ${TRAVIS_BUILD_DIR}:/travis \
Expand Down
63 changes: 60 additions & 3 deletions driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu
setup_variables() {
while [[ ${#} -ge 1 ]]; do
case ${1} in
"AR="*|"ARCH="*|"CC="*|"LD="*|"NM"=*|"OBJDUMP"=*|"OBJSIZE"=*|"REPO="*) export "${1?}" ;;
"AR="*|"ARCH="*|"CC="*|"LD="*|"NM"=*|"OBJDUMP"=*|"OBJSIZE"=*|"REPO="*|"TUX_BUILD="*) export "${1?}" ;;
"-c"|"--clean") cleanup=true ;;
"-j"|"--jobs") shift; jobs=$1 ;;
"-j"*) jobs=${1/-j} ;;
Expand Down Expand Up @@ -195,12 +195,20 @@ gen_bin_list() {

check_dependencies() {
# Check for existence of needed binaries
command -v nproc
command -v "${CROSS_COMPILE:-}"as
${using_qemu:=true} && command -v ${qemu}
command -v timeout
command -v unbuffer

if [[ -n "${TUX_BUILD:=}" ]]; then
command -v python3
command -v tuxbuild
command -v wget
return 0
fi

command -v nproc
command -v "${CROSS_COMPILE:-}"as

oldest_llvm_version=7
latest_llvm_version=$(curl -LSs https://raw.githubusercontent.com/llvm/llvm-project/master/llvm/CMakeLists.txt | grep -s -F "set(LLVM_VERSION_MAJOR" | cut -d ' ' -f 4 | sed 's/)//')

Expand Down Expand Up @@ -306,6 +314,50 @@ mako_reactor() {
"${@}"
}

build_via_tuxbuild() {
echo "tuxbuild"
# https://gitlab.com/Linaro/tuxbuild/-/issues/55
if [[ ${ARCH} == "x86_64" ]]; then
tux_arch=x86
else
tux_arch=${ARCH}
fi
# https://gitlab.com/Linaro/tuxbuild/-/issues/53
if [[ ${ARCH} == "arm64" ]]; then
tux_image=Image
else
tux_image=${image_name}
fi
# Example command:
# $ tuxbuild build \
# --git-repo https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git \
# --git-ref master --target-arch x86 --kconfig defconfig
# --toolchain clang-9
# Example artifacts to play with:
# https://builds.tuxbuild.com/k4gifttltEVagDHstq0NoA/ x86 811
# https://builds.tuxbuild.com/neNnj76CSx8sDEbwlUHGbA/ arm64 31:06
# https://builds.tuxbuild.com/9ieKegqDeZBTCMaG3et7ig/ arm64
# https://builds.tuxbuild.com/rPqYnwW4B8xhi8i6atmcpg/ arm
cmd="tuxbuild build --git-repo ${url} --git-ref ${branch:=master} --target-arch ${tux_arch} --kconfig ${config} --toolchain clang-${LLVM_VERSION}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an array:

cmd=( tuxbuild build --git-repo ${url} --git-ref ${branch:=master} --target-arch ${tux_arch} --kconfig ${config} --toolchain clang-${LLVM_VERSION} )

...

build_url=$(timeout 50m "${cmd[@]}" | ...)

echo "${cmd}"

# https://gitlab.com/Linaro/tuxbuild/-/issues/56
start=$(date +%s)
build_url=$(timeout 50m ${cmd} | grep -o https://builds.tuxbuild.com/.\* | head -n1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fairly certain Travis will timeout here because there will not be any output for ten minutes. I am not sure how to get around that, we'll have to brain storm (or maybe reach out to Travis support and see if there is any way for that restriction to be waved).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I contacted Travis CI support, they told me there is no way to change the 10-minute silence timeout. The easiest way to get around that restriction is to just print something every 10 minutes.

end=$(date +%s)
runtime=$((${end}-${start}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be runtime=$((end - start))

echo "tuxbuild took ${runtime} seconds: ${build_url}"

rm -f build.log
wget "${build_url}build.log" -O build.log
cat build.log

#kernel_image=${tree}/arch/${ARCH}/boot/${image_name}
mkdir -p ${tree}/arch/${ARCH}/boot
rm -f "${tree}/arch/${ARCH}/boot/${image_name}"
wget "${build_url}${tux_image}" -O "${tree}/arch/${ARCH}/boot/${image_name}"
}

apply_patches() {
patches_folder=$1
if [[ -d ${patches_folder} ]]; then
Expand All @@ -316,6 +368,11 @@ apply_patches() {
}

build_linux() {
if [[ -n ${TUX_BUILD} ]]; then
build_via_tuxbuild
return 0
fi

# Wrap CC in ccache if it is available (it's not strictly required)
CC="$(command -v ccache) ${CC}"
[[ ${LD} =~ lld ]] && HOSTLD=${LD}
Expand Down
3 changes: 3 additions & 0 deletions usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Environment variables:
If no OBJSIZE value is specified, the script will attempt to set OBJSIZE
to llvm-size-10 llvm-size-9, llvm-size-8, llvm-size-7, llvm-size, then
${CROSS_COMPILE}size if they are found in PATH.
TUX_BUILD:
If set, will use the tuxbuild client to trigger a remote build on
tuxbuild. https://gitlab.com/Linaro/tuxbuild


Optional parameters:
Expand Down