X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=scripts%2Fbinutils-gdb%2Fbuild.sh;h=3d7c561a477f60e75105289a7c2f9ca803a8fe5a;hb=52be573959303e1d3ca63565eecdba39adb7635c;hp=55475308ee664bca5a41695e3342f581ed2f6738;hpb=8306891807c88241b56543a38dd074ba6f7eeaa2;p=lttng-ci.git diff --git a/scripts/binutils-gdb/build.sh b/scripts/binutils-gdb/build.sh index 5547530..3d7c561 100755 --- a/scripts/binutils-gdb/build.sh +++ b/scripts/binutils-gdb/build.sh @@ -17,6 +17,44 @@ set -exu +mktemp_compat() { + case "$platform" in + macos*) + # On MacOSX, mktemp doesn't respect TMPDIR in the same way as many + # other systems. Use the final positional argument to force the + # tempfile or tempdir to be created inside $TMPDIR, which must + # already exist. + if [ -n "${TMPDIR}" ] ; then + mktemp "${@}" "${TMPDIR}/tmp.XXXXXXXXXX" + else + mktemp "${@}" + fi + ;; + *) + mktemp "${@}" + ;; + esac +} + +print_header() { + set +x + + local message=" $1 " + local message_len + local padding_len + + message_len="${#message}" + padding_len=$(( (80 - (message_len)) / 2 )) + + printf '\n'; printf -- '#%.0s' {1..80}; printf '\n' + printf -- '-%.0s' {1..80}; printf '\n' + printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n' + printf -- '-%.0s' {1..80}; printf '\n' + printf -- '#%.0s' {1..80}; printf '\n\n' + + set -x +} + failed_configure() { # Assume we are in the configured build directory echo "#################### BEGIN config.log ####################" @@ -38,6 +76,8 @@ from xml.etree.ElementTree import ElementTree, Element, SubElement line_re = re.compile( r"^(PASS|XPASS|FAIL|XFAIL|KFAIL|DUPLICATE|UNTESTED|UNSUPPORTED|UNRESOLVED): (.*?\.exp): (.*)" ) +running_re = re.compile(r"^Running .*/(gdb\.[^/]+/.*\.exp)") +error_re = re.compile(r"^ERROR: (.*)") pass_count = 0 fail_count = 0 @@ -65,7 +105,29 @@ testsuite = SubElement( ) SubElement(testsuite, "properties") +cur_test = None + for line in sys.stdin: + m = running_re.match(line) + if m: + cur_test = m.group(1) + continue + + m = error_re.match(line) + if m: + test = cur_test if cur_test else "" + msg = m.group(1) + print("ERROR: {} - {}".format(test, msg), file=sys.stderr) + error_count += 1 + + testcase_name = test + testcase = SubElement( + testsuite, + "testcase", + {"name": testcase_name, "classname": "classname", "time": "0"}, + ) + SubElement(testcase, "error", {"type": "ERROR"}) + m = line_re.match(line) if not m: continue @@ -96,7 +158,7 @@ for line in sys.stdin: else: assert False -testsuite.attrib["tests"] = str(pass_count + fail_count + skip_count) +testsuite.attrib["tests"] = str(pass_count + fail_count + skip_count + error_count) testsuite.attrib["failures"] = str(fail_count) testsuite.attrib["skipped"] = str(skip_count) testsuite.attrib["errors"] = str(error_count) @@ -126,27 +188,58 @@ SRCDIR="$WORKSPACE/src/binutils-gdb" TMPDIR="$WORKSPACE/tmp" PREFIX="/build" +function use_ccache() +{ + case "$platform" in + macos-*) + return 1 + ;; + *) + return 0 + ;; + esac +} + # 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 CFLAGS="-O2 -g -fsanitize=address" +export CXXFLAGS="-O2 -g -fsanitize=address -D_GLIBCXX_DEBUG=1" export LDFLAGS="-fsanitize=address" -export CC="ccache cc" -export CXX="ccache c++" +export CC="cc" +export CXX="c++" + +if use_ccache; then + CC="ccache $CC" + CXX="ccache $CXX" +fi + +# To make GDB find libcc1.so +export LD_LIBRARY_PATH="/usr/lib/gcc/x86_64-linux-gnu/11:${LD_LIBRARY_PATH:-}" # Set platform variables +export TAR=tar +export MAKE=make + case "$platform" in +macos-*) + export NPROC="getconf _NPROCESSORS_ONLN" + export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" + export CPPFLAGS="-I/opt/local/include" + export LDFLAGS="-L/opt/local/lib" + export PYTHON="python3.9" + export PYTHON_CONFIG="python3.9-config" + ;; *) - export MAKE=make - export TAR=tar export NPROC=nproc ;; esac # Print build env details +print_header "Build environment details" +print_hardware || true print_os || true print_tooling || true @@ -154,6 +247,10 @@ if use_ccache; then ccache -c fi +# This job has been seen generating cores in /tmp, filling and and causing +# problems. Remove any leftover core from a previous job. +rm /tmp/core.* || true + # Enter the source directory cd "$SRCDIR" @@ -186,6 +283,12 @@ case "$conf" in ;; esac +case "$platform" in +macos-*) + CONF_OPTS+=("--disable-werror") + ;; +esac + # Build type # oot : out-of-tree build # dist : build via make dist @@ -199,7 +302,7 @@ case "$build" in echo "Out of tree build" # Create and enter a temporary build directory - builddir=$(mktemp -d) + builddir=$(mktemp_compat -d) cd "$builddir" "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure @@ -209,10 +312,17 @@ esac # We are now inside a configured build directory # BUILD! -$MAKE -j "$($NPROC)" V=1 MAKEINFO=/bin/true +$MAKE -j "$($NPROC)" V=1 MAKEINFO=true # Install in the workspace -$MAKE install DESTDIR="$WORKSPACE" +$MAKE install DESTDIR="$WORKSPACE" MAKEINFO=true + +case "$platform" in +macos-*) + # Stop there, don't run tests on macOS. + exit 0 + ;; +esac case "$target_board" in unix | native-gdbserver | native-extended-gdbserver) @@ -227,7 +337,10 @@ esac # Run tests, don't fail now, we know that "make check" is going to fail, # since some tests don't pass. -$MAKE -C gdb --keep-going check -j "$($NPROC)" RUNTESTFLAGS="$RUNTESTFLAGS" FORCE_PARALLEL="1" || true +$MAKE -C gdb/testsuite site.exp +# shellcheck disable=SC2016 +echo 'set gdb_test_timeout [expr 5 * $timeout]' >> gdb/testsuite/site.exp +$MAKE -C gdb --keep-going check RUNTESTFLAGS="$RUNTESTFLAGS" || true # Copy the dejagnu test results for archiving before cleaning the build dir mkdir "${WORKSPACE}/results" @@ -872,12 +985,12 @@ known_failures_file="known-failures-${target_board}" known_failures_re_file="known-failures-re-${target_board}" grep --invert-match --fixed-strings --file="$known_failures_file" "${WORKSPACE}/results/gdb.sum" | \ grep --invert-match --extended-regexp --file="$known_failures_re_file" > "${WORKSPACE}/results/gdb.filtered.sum" -grep --extended-regexp --regexp="^(FAIL|XPASS|UNRESOLVED|DUPLICATE):" "${WORKSPACE}/results/gdb.filtered.sum" > "${WORKSPACE}/results/gdb.fail.sum" || true +grep --extended-regexp --regexp="^(FAIL|XPASS|UNRESOLVED|DUPLICATE|ERROR):" "${WORKSPACE}/results/gdb.filtered.sum" > "${WORKSPACE}/results/gdb.fail.sum" || true # For informational purposes: check if some known failure lines did not appear # in the gdb.sum. echo "Known failures that don't appear in gdb.sum:" -while read line; do +while read -r line; do if ! grep --silent --fixed-strings "$line" "${WORKSPACE}/results/gdb.sum"; then echo "$line" fi