From: Michael Jeanson Date: Fri, 8 Oct 2021 17:57:43 +0000 (-0400) Subject: jjb: Add binutils-gdb base jobs X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=91ba8aa1f65cc73d217686217f6ab5817d209808;p=lttng-ci.git jjb: Add binutils-gdb base jobs Signed-off-by: Michael Jeanson --- diff --git a/automation/ansible/node_amd64.yml b/automation/ansible/node_amd64.yml index 56d3ffe..f7ec70b 100644 --- a/automation/ansible/node_amd64.yml +++ b/automation/ansible/node_amd64.yml @@ -4,6 +4,7 @@ - cross-compilers - compilers - babeltrace + - binutils-gdb - liburcu - lttng-ust - lttng-tools diff --git a/automation/ansible/roles/binutils-gdb/tasks/main.yml b/automation/ansible/roles/binutils-gdb/tasks/main.yml new file mode 100644 index 0000000..733840c --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/tasks/main.yml @@ -0,0 +1,22 @@ +--- +# Include variables and define needed variables. +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}.yml" + +- name: Define binutils_gdb_packages. + set_fact: + binutils_gdb_packages: "{{ __binutils_gdb_packages | list }}" + when: binutils_gdb_packages is not defined + +# Setup/install tasks. +- include: setup-RedHat.yml + when: ansible_os_family == 'RedHat' + +- include: setup-Debian.yml + when: ansible_os_family == 'Debian' + +- include: setup-Alpine.yml + when: ansible_os_family == 'Alpine' + +- include: setup-Suse.yml + when: ansible_os_family == 'Suse' diff --git a/automation/ansible/roles/binutils-gdb/tasks/setup-Alpine.yml b/automation/ansible/roles/binutils-gdb/tasks/setup-Alpine.yml new file mode 100644 index 0000000..76c7249 --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/tasks/setup-Alpine.yml @@ -0,0 +1,6 @@ +--- +- name: Update apk cache. + apk: update_cache=yes + +- name: Ensure binutils_gdb build dependencies are installed. + apk: "name={{ binutils_gdb_packages }} state=present" diff --git a/automation/ansible/roles/binutils-gdb/tasks/setup-Debian.yml b/automation/ansible/roles/binutils-gdb/tasks/setup-Debian.yml new file mode 100644 index 0000000..d2531c1 --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/tasks/setup-Debian.yml @@ -0,0 +1,6 @@ +--- +- name: Update apt cache. + apt: update_cache=yes cache_valid_time=86400 + +- name: Ensure binutils_gdb build dependencies are installed. + apt: "name={{ binutils_gdb_packages }} state=present" diff --git a/automation/ansible/roles/binutils-gdb/tasks/setup-RedHat.yml b/automation/ansible/roles/binutils-gdb/tasks/setup-RedHat.yml new file mode 100644 index 0000000..8c900db --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/tasks/setup-RedHat.yml @@ -0,0 +1,5 @@ +--- +- name: Ensure binutils_gdb build dependencies are installed. + dnf: + name: "{{ binutils_gdb_packages }}" + state: installed diff --git a/automation/ansible/roles/binutils-gdb/tasks/setup-Suse.yml b/automation/ansible/roles/binutils-gdb/tasks/setup-Suse.yml new file mode 100644 index 0000000..de6c78b --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/tasks/setup-Suse.yml @@ -0,0 +1,3 @@ +--- +- name: Ensure binutils_gdb build dependencies are installed. + zypper: "name={{ binutils_gdb_packages }} state=installed update_cache=yes" diff --git a/automation/ansible/roles/binutils-gdb/vars/Alpine.yml b/automation/ansible/roles/binutils-gdb/vars/Alpine.yml new file mode 100644 index 0000000..ec18d42 --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/vars/Alpine.yml @@ -0,0 +1,3 @@ +--- +__binutils_gdb_packages: + - libgmp-dev diff --git a/automation/ansible/roles/binutils-gdb/vars/Debian.yml b/automation/ansible/roles/binutils-gdb/vars/Debian.yml new file mode 100644 index 0000000..f98aa45 --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/vars/Debian.yml @@ -0,0 +1,6 @@ +--- +__binutils_gdb_packages: + - libgmp-dev + - guile-2.2-dev + - dejagnu + - gnat diff --git a/automation/ansible/roles/binutils-gdb/vars/RedHat.yml b/automation/ansible/roles/binutils-gdb/vars/RedHat.yml new file mode 100644 index 0000000..d4e53ab --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/vars/RedHat.yml @@ -0,0 +1,3 @@ +--- +__binutils_gdb_packages: + - gmp-devel diff --git a/automation/ansible/roles/binutils-gdb/vars/Suse.yml b/automation/ansible/roles/binutils-gdb/vars/Suse.yml new file mode 100644 index 0000000..d4e53ab --- /dev/null +++ b/automation/ansible/roles/binutils-gdb/vars/Suse.yml @@ -0,0 +1,3 @@ +--- +__binutils_gdb_packages: + - gmp-devel diff --git a/jobs/binutils-gdb.yaml b/jobs/binutils-gdb.yaml new file mode 100644 index 0000000..2b3f10d --- /dev/null +++ b/jobs/binutils-gdb.yaml @@ -0,0 +1,131 @@ +- defaults: + name: binutils-gdb + description: | + GDB TODO + +

Job is managed by Jenkins Job Builder.

+ + project-type: freestyle + + wrappers: + - ansicolor + - timeout: + timeout: 20 + fail: true + type: no-activity + - timestamps + - workspace-cleanup: + clean-if: + - failure: false + + scm: + - git: + url: git://git-mirror.internal.efficios.com/git/binutils-gdb.git + branches: + - origin/{version} + basedir: src/binutils-gdb + skip-tag: true + + triggers: + - pollscm: + cron: "@hourly" + + properties: + - inject: + properties-content: | + PROJECT_NAME=gdb + - build-discarder: + num-to-keep: 10 + + +## Templates ## +- job-template: + name: binutils-gdb_{version}_build + defaults: binutils-gdb + + project-type: matrix + node: 'master' # Applies only to matrix flyweight task + axes: + - axis: + type: slave + name: arch + values: '{obj:arch}' + + builders: + - shell: + !include-raw-escape: + - scripts/common/print.sh + - scripts/binutils-gdb/build.sh + + publishers: + - archive: + artifacts: 'build/**,results/**' + allow-empty: false + - junit: + results: 'results/*.xml' + +- job-template: + name: dev_gerrit_binutils-gdb_build + defaults: binutils-gdb + concurrent: true + + scm: + - git: + url: https://review.lttng.org/binutils-gdb + refspec: 'refs/changes/*:refs/changes/*' + branches: + - '$GERRIT_REFSPEC' + basedir: src/binutils-gdb + skip-tag: true + + triggers: + - gerrit: + trigger-on: + - comment-added-event: + approval-category: 'CI-Build' + approval-value: 1 + projects: + - project-compare-type: 'PLAIN' + project-pattern: 'binutils-gdb' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**' + + node: 'amd64' + + builders: + - shell: + !include-raw-escape: + - scripts/common/print.sh + - scripts/binutils-gdb/build.sh + + properties: + - build-discarder: + days-to-keep: 1 + + +## Views ## +- view-template: + name: 'GDB' + view-type: list + regex: 'binutils-gdb[-_].*' + + +## Projects ## +- project: + name: binutils-gdb + version: + - master + jobs: + - 'binutils-gdb_{version}_build': + arch: !!python/tuple [amd64] + +- project: + name: gerrit-gdb + jobs: + - 'dev_gerrit_binutils-gdb_build' + +- project: + name: gdb-views + views: + - GDB diff --git a/scripts/binutils-gdb/build.sh b/scripts/binutils-gdb/build.sh new file mode 100755 index 0000000..c6a4937 --- /dev/null +++ b/scripts/binutils-gdb/build.sh @@ -0,0 +1,235 @@ +#!/bin/bash +# +# Copyright (C) 2021 Michael Jeanson +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -exu + +failed_configure() { + # Assume we are in the configured build directory + echo "#################### BEGIN config.log ####################" + cat config.log + echo "#################### END config.log ####################" + exit 1 +} + +sum2junit() { + local infile="$1" + local outfile="$2" + + local tool + local skipped + local passes + local failures + local total + local s2jtmpfile + + local result + local name + local message + + set +x + + tool=$(grep "tests ===" "$infile" | tr -s ' ' | cut -d ' ' -f 2) + + # Get the counts for tests that didn't work properly + skipped=$(grep -E -c '^UNRESOLVED|^UNTESTED|^UNSUPPORTED' "$infile" || true) + if test x"${skipped}" = x; then + skipped=0 + fi + + # The total of successful results are PASS and XFAIL + passes=$(grep -E -c '^PASS|XFAIL' "$infile" || true) + if test x"${passes}" = x; then + passes=0 + fi + + # The total of failed results are FAIL and XPASS + failures=$(grep -E -c '^FAIL|XPASS' "$infile" || true) + if test x"${failures}" = x; then + failures=0 + fi + + # Calculate the total number of test cases + total=$((passes + failures)) + total=$((total + skipped)) + + cat < "$outfile" + + + + + +EOF + + s2jtmpfile="$(mktemp)" + grep -E 'PASS|XPASS|FAIL|UNTESTED|UNSUPPORTED|UNRESOLVED' "$infile" > "$s2jtmpfile" || true + + while read -r line + do + echo -n "." + result=$(echo "$line" | cut -d ' ' -f 1 | tr -d ':') + name=$(echo "$line" | cut -d ' ' -f 2 | tr -d '\"><;:\[\]^\\&?@') + message=$(echo "$line" | cut -d ' ' -f 3-50 | tr -d '\"><;:\[\]^\\&?@') + + echo " " >> "$outfile" + case "${result}" in + PASS|XFAIL|KFAIL) + # No message for successful tests in junit + ;; + UNSUPPORTED|UNTESTED) + if test x"${message}" != x; then + echo -n " " >> "$outfile" + else + echo -n " " >> "$outfile" + fi + ;; + XPASS|UNRESOLVED|DUPLICATE) + echo -n " " >> "$outfile" + ;; + *) + echo -n " " >> "$outfile" + esac + + echo " " >> "$outfile" + done < "$s2jtmpfile" + + rm -f "$s2jtmpfile" + + # Write the closing tag for the test results + echo "" >> "$outfile" + echo "" >> "$outfile" + + set -x +} + +# Required variables +WORKSPACE=${WORKSPACE:-} + +arch=${arch:-} +conf=${conf:-} +build=${build:-} +cc=${cc:-} + + +SRCDIR="$WORKSPACE/src/binutils-gdb" +TMPDIR="$WORKSPACE/tmp" +PREFIX="/build" + +# Create tmp directory +rm -rf "$TMPDIR" +mkdir -p "$TMPDIR" + +export TMPDIR +export CFLAGS="-O2 -fsanitize=address" +export CXXFLAGS="-O2 -fsanitize=address -D_GLIBCXX_DEBUG=1" +export LDFLAGS="-fsanitize=address" + +# Set platform variables +case "$arch" in +*) + export MAKE=make + export TAR=tar + export NPROC=nproc + ;; +esac + +# Print build env details +print_os || true +print_tooling || true + +# Enter the source directory +cd "$SRCDIR" + +# Run bootstrap in the source directory prior to configure +#./bootstrap + +# Get source version from configure script +#eval "$(grep '^PACKAGE_VERSION=' ./configure)" +#PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/} + +# Set configure options and environment variables for each build +# configuration. +CONF_OPTS=("--prefix=$PREFIX") + +case "$conf" in +*) + echo "Standard configuration" + + # Use system tools + CONF_OPTS+=("--disable-binutils" "--disable-ld" "--disable-gold" "--disable-gas" "--disable-sim" "--disable-gprof") + + # Use system libs + CONF_OPTS+=("--with-system-readline" "--with-system-zlib") + + # Enable optional features + CONF_OPTS+=("--enable-targets=all" "--with-expat=yes" "--with-python=python3" "--with-guile=guile-2.2" "--enable-libctf") + + CONF_OPTS+=("--enable-build-warnings" "--enable-gdb-build-warnings" "--enable-unit-tests") + + ;; +esac + +# Build type +# oot : out-of-tree build +# dist : build via make dist +# oot-dist: build via make dist out-of-tree +# * : normal tree build +# +# Make sure to move to the build directory and run configure +# before continuing. +case "$build" in +*) + echo "Out of tree build" + + # Create and enter a temporary build directory + builddir=$(mktemp -d) + cd "$builddir" + + "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure + ;; +esac + +# We are now inside a configured build directory + +# BUILD! +$MAKE -j "$($NPROC)" V=1 MAKEINFO=/bin/true + +# Install in the workspace +$MAKE install DESTDIR="$WORKSPACE" + +# Run tests, don't fail now, we want to run the archiving steps +failed_tests=0 +$MAKE -C gdb --keep-going check -j "$($NPROC)" || failed_tests=1 + +# Copy the dejagnu test results for archiving before cleaning the build dir +mkdir "${WORKSPACE}/results" +cp gdb/testsuite/gdb.sum "${WORKSPACE}/results/" +sum2junit gdb/testsuite/gdb.sum "${WORKSPACE}/results/gdb.xml" + +# Clean the build directory +$MAKE clean + +# Cleanup rpath in executables and shared libraries +#find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \; +#find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; + +# Remove libtool .la files +find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \; + +# Exit with failure if any of the tests failed +exit $failed_tests + +# EOF