aboutsummaryrefslogtreecommitdiff
path: root/lkft-linux-clang.yaml
blob: 6f947f06efa58559b54af4e48671b77efa6bb5c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
- job:
    name: lkft-linux-clang
    project-type: matrix
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 60
            num-to-keep: 300
            artifact-num-to-keep: 1
    parameters:
        - string:
            name: KERNEL_GITREF
            default: 'torvalds/master'
        - matrix-combinations:
            name: MATRIX_COMBINATIONS
    disabled: false
    node: master
    display-name: 'LKFT Linux Kernel built with Clang'
    concurrent: true
    axes:
        - axis:
            type: user-defined
            name: ARCH
            values:
                - 'arm64'
                - 'x86_64'
        - axis:
            type: user-defined
            name: CLANG_TOOLCHAIN
            values:
                - 'clang-r328903'
                - 'clang-master'
        - axis:
            type: slave
            name: label
            values:
                - docker-stretch-amd64
    execution-strategy:
        sequential: false
    wrappers:
        - timestamps
        - timeout:
            timeout: 180
    builders:
        - shell: |
            #!/bin/bash -ex

            sudo apt-get update
            sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y libssl-dev

            # Keep an updated mirror of Linux in permanent storage
            cd $HOME/srv
            if [ ! -d linux.git ]; then
              mkdir linux.git
              cd linux.git
              git init --bare
              git remote add torvalds https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
              git remote add linux-stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
              cd ..
            fi

            cd linux.git
            git remote update

            # Download Clang and GCC toolchains to cross-compile
            cd ${WORKSPACE}
            mkdir ${CLANG_TOOLCHAIN}
            if [ "${CLANG_TOOLCHAIN}" = "clang-master" ]; then
              wget -q http://snapshots.linaro.org/android/android-clang-toolchain/latest/clang-master.tar.xz
              tar Jxf clang-master.tar.xz
            else
              wget -q "https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/master/${CLANG_TOOLCHAIN}.tar.gz"
              tar zxf "${CLANG_TOOLCHAIN}.tar.gz" -C "${CLANG_TOOLCHAIN}/"
            fi
            git clone --depth=1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9


            export PATH=${PWD}/${CLANG_TOOLCHAIN}/bin:${PWD}/aarch64-linux-android-4.9/bin:${PATH}

            # Set up Linux Git repositories
            # "torvalds" is Linus' kernel, mainline
            # "linux-stable" is GKH repository for stable kernels
            cd ${WORKSPACE}
            git clone \
              -o torvalds \
              --reference ${HOME}/srv/linux.git \
              https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git \
              linux
            cd linux
            git remote add linux-stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
            git fetch linux-stable

            # If triggered with a GIT_COMMIT, check it out;
            # else, check out the Git reference.
            if [ -n "${GIT_COMMIT}" ]; then
              GIT_REFERENCE=${GIT_COMMIT}
            else
              GIT_REFERENCE=${KERNEL_GITREF}
            fi
            git checkout ${GIT_REFERENCE}

            case "${ARCH}" in
              arm64)
                CLANG_TRIPLE=aarch64-linux-gnu-
                CROSS_COMPILE=aarch64-linux-android-
                ;;
              x86_64)
                CLANG_TRIPLE=
                CROSS_COMPILE=
                ;;
              *)
                echo "Unsupported ARCH: ${ARCH}"
                exit 1
                ;;
            esac
            export ARCH
            export CLANG_TRIPLE
            export CROSS_COMPILE

            make CC=clang HOSTCC=clang defconfig
            make CC=clang HOSTCC=clang -j$(nproc)
    publishers:
        - email-ext:
            recipients: 'daniel.diaz@linaro.org, dan.rue@linaro.org'
            matrix-trigger: only-configurations
            subject: '[CI] Linux/Clang failed: ${KERNEL_GITREF}: ${KERNEL_DESCRIBE}'
            body: |
                Build URL: ${PROJECT_URL}${BUILD_NUMBER}/
                Build log: ${PROJECT_URL}${BUILD_NUMBER}/console
                Git repo/branch: ${KERNEL_GITREF}
                Git commit: ${GIT_COMMIT}
                Clang toolchain: ${CLANG_TOOLCHAIN}
                Kernel version (from make): ${MAKE_KERNELVERSION}
                Kernel version (from Git): ${KERNEL_DESCRIBE}

                Errors:
                ${BUILD_LOG_REGEX, regex=".*: error: .*", linesBefore=0, linesAfter=2, showTruncatedLines=false}