summaryrefslogtreecommitdiff
path: root/.ci
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2021-07-16 08:29:08 -0400
committerAnthony Green <green@moxielogic.com>2021-07-16 08:29:08 -0400
commitd1eef904766dbd647de6c240a57dbc98d46e33dd (patch)
tree3fcf7268fb4536fed516bc82d30730ef7ba41328 /.ci
parentf9ea41683444ebe11cfa45b05223899764df28fb (diff)
downloadlibffi-d1eef904766dbd647de6c240a57dbc98d46e33dd.tar.gz
Migrate from travis-ci to github actions.
Diffstat (limited to '.ci')
-rwxr-xr-x.ci/ar-lib270
-rw-r--r--.ci/bfin-sim.exp58
-rwxr-xr-x.ci/build-cross-in-container.sh18
-rwxr-xr-x.ci/build-in-container.sh10
-rwxr-xr-x.ci/build.sh143
-rwxr-xr-x.ci/compile351
-rwxr-xr-x.ci/install.sh72
-rw-r--r--.ci/m32r-sim.exp58
-rw-r--r--.ci/moxie-sim.exp60
-rwxr-xr-x.ci/msvs-detect1103
-rw-r--r--.ci/or1k-sim.exp58
-rw-r--r--.ci/powerpc-eabisim.exp58
-rw-r--r--.ci/site.exp29
-rw-r--r--.ci/wine-sim.exp55
14 files changed, 2343 insertions, 0 deletions
diff --git a/.ci/ar-lib b/.ci/ar-lib
new file mode 100755
index 0000000..0baa4f6
--- /dev/null
+++ b/.ci/ar-lib
@@ -0,0 +1,270 @@
+#! /bin/sh
+# Wrapper for Microsoft lib.exe
+
+me=ar-lib
+scriptversion=2012-03-01.08; # UTC
+
+# Copyright (C) 2010-2018 Free Software Foundation, Inc.
+# Written by Peter Rosin <peda@lysator.liu.se>.
+#
+# 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 2, 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 <https://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+
+# func_error message
+func_error ()
+{
+ echo "$me: $1" 1>&2
+ exit 1
+}
+
+file_conv=
+
+# func_file_conv build_file
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts.
+func_file_conv ()
+{
+ file=$1
+ case $file in
+ / | /[!/]*) # absolute file, and not a UNC file
+ if test -z "$file_conv"; then
+ # lazily determine how to convert abs files
+ case `uname -s` in
+ MINGW*)
+ file_conv=mingw
+ ;;
+ CYGWIN*)
+ file_conv=cygwin
+ ;;
+ *)
+ file_conv=wine
+ ;;
+ esac
+ fi
+ case $file_conv in
+ mingw)
+ file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+ ;;
+ cygwin)
+ file=`cygpath -m "$file" || echo "$file"`
+ ;;
+ wine)
+ file=`winepath -w "$file" || echo "$file"`
+ ;;
+ esac
+ ;;
+ esac
+}
+
+# func_at_file at_file operation archive
+# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
+# for each of them.
+# When interpreting the content of the @FILE, do NOT use func_file_conv,
+# since the user would need to supply preconverted file names to
+# binutils ar, at least for MinGW.
+func_at_file ()
+{
+ operation=$2
+ archive=$3
+ at_file_contents=`cat "$1"`
+ eval set x "$at_file_contents"
+ shift
+
+ for member
+ do
+ $AR -NOLOGO $operation:"$member" "$archive" || exit $?
+ done
+}
+
+case $1 in
+ '')
+ func_error "no command. Try '$0 --help' for more information."
+ ;;
+ -h | --h*)
+ cat <<EOF
+Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
+
+Members may be specified in a file named with @FILE.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "$me, version $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test $# -lt 3; then
+ func_error "you must specify a program, an action and an archive"
+fi
+
+AR=$1
+shift
+while :
+do
+ if test $# -lt 2; then
+ func_error "you must specify a program, an action and an archive"
+ fi
+ case $1 in
+ -lib | -LIB \
+ | -ltcg | -LTCG \
+ | -machine* | -MACHINE* \
+ | -subsystem* | -SUBSYSTEM* \
+ | -verbose | -VERBOSE \
+ | -wx* | -WX* )
+ AR="$AR $1"
+ shift
+ ;;
+ *)
+ action=$1
+ shift
+ break
+ ;;
+ esac
+done
+orig_archive=$1
+shift
+func_file_conv "$orig_archive"
+archive=$file
+
+# strip leading dash in $action
+action=${action#-}
+
+delete=
+extract=
+list=
+quick=
+replace=
+index=
+create=
+
+while test -n "$action"
+do
+ case $action in
+ d*) delete=yes ;;
+ x*) extract=yes ;;
+ t*) list=yes ;;
+ q*) quick=yes ;;
+ r*) replace=yes ;;
+ s*) index=yes ;;
+ S*) ;; # the index is always updated implicitly
+ c*) create=yes ;;
+ u*) ;; # TODO: don't ignore the update modifier
+ v*) ;; # TODO: don't ignore the verbose modifier
+ *)
+ func_error "unknown action specified"
+ ;;
+ esac
+ action=${action#?}
+done
+
+case $delete$extract$list$quick$replace,$index in
+ yes,* | ,yes)
+ ;;
+ yesyes*)
+ func_error "more than one action specified"
+ ;;
+ *)
+ func_error "no action specified"
+ ;;
+esac
+
+if test -n "$delete"; then
+ if test ! -f "$orig_archive"; then
+ func_error "archive not found"
+ fi
+ for member
+ do
+ case $1 in
+ @*)
+ func_at_file "${1#@}" -REMOVE "$archive"
+ ;;
+ *)
+ func_file_conv "$1"
+ $AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
+ ;;
+ esac
+ done
+
+elif test -n "$extract"; then
+ if test ! -f "$orig_archive"; then
+ func_error "archive not found"
+ fi
+ if test $# -gt 0; then
+ for member
+ do
+ case $1 in
+ @*)
+ func_at_file "${1#@}" -EXTRACT "$archive"
+ ;;
+ *)
+ func_file_conv "$1"
+ $AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
+ ;;
+ esac
+ done
+ else
+ $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
+ do
+ $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
+ done
+ fi
+
+elif test -n "$quick$replace"; then
+ if test ! -f "$orig_archive"; then
+ if test -z "$create"; then
+ echo "$me: creating $orig_archive"
+ fi
+ orig_archive=
+ else
+ orig_archive=$archive
+ fi
+
+ for member
+ do
+ case $1 in
+ @*)
+ func_file_conv "${1#@}"
+ set x "$@" "@$file"
+ ;;
+ *)
+ func_file_conv "$1"
+ set x "$@" "$file"
+ ;;
+ esac
+ shift
+ shift
+ done
+
+ if test -n "$orig_archive"; then
+ $AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
+ else
+ $AR -NOLOGO -OUT:"$archive" "$@" || exit $?
+ fi
+
+elif test -n "$list"; then
+ if test ! -f "$orig_archive"; then
+ func_error "archive not found"
+ fi
+ $AR -NOLOGO -LIST "$archive" || exit $?
+fi
diff --git a/.ci/bfin-sim.exp b/.ci/bfin-sim.exp
new file mode 100644
index 0000000..b36d9f0
--- /dev/null
+++ b/.ci/bfin-sim.exp
@@ -0,0 +1,58 @@
+# Copyright (C) 2010, 2019 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu 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 2 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA.
+
+# This is a list of toolchains that are supported on this board.
+set_board_info target_install {bfin-elf}
+
+# Load the generic configuration for this board. This will define a basic set
+# of routines needed by the tool to communicate with the board.
+load_generic_config "sim"
+
+# basic-sim.exp is a basic description for the standard Cygnus simulator.
+load_base_board_description "basic-sim"
+
+# "bfin" is the name of the sim subdir in devo/sim.
+setup_sim bfin
+
+# No multilib options needed by default.
+process_multilib_options ""
+
+# We only support newlib on this target. We assume that all multilib
+# options have been specified before we get here.
+
+set_board_info compiler "[find_gcc]"
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
+
+# Configuration settings for testsuites
+set_board_info noargs 1
+set_board_info gdb,nosignals 1
+set_board_info gdb,noresults 1
+set_board_info gdb,cannot_call_functions 1
+set_board_info gdb,skip_float_tests 1
+set_board_info gdb,can_reverse 1
+set_board_info gdb,use_precord 1
+
+# More time is needed
+set_board_info gcc,timeout 800
+set_board_info gdb,timeout 60
+
+# Used by a few gcc.c-torture testcases to delimit how large the stack can
+# be.
+set_board_info gcc,stack_size 5000
+
diff --git a/.ci/build-cross-in-container.sh b/.ci/build-cross-in-container.sh
new file mode 100755
index 0000000..d2143e3
--- /dev/null
+++ b/.ci/build-cross-in-container.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -x
+
+cd /opt
+
+echo $PATH
+export PATH=/usr/local/bin:$PATH
+echo $PATH
+
+export DEJAGNU=$(pwd)/.ci/site.exp
+echo $DEJAGNU
+ls -l $DEJAGNU
+pwd
+find .
+./configure --host=${HOST} || cat */config.log
+make
+make dist
+BOARDSDIR=$(pwd)/.ci make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true
diff --git a/.ci/build-in-container.sh b/.ci/build-in-container.sh
new file mode 100755
index 0000000..a4124b0
--- /dev/null
+++ b/.ci/build-in-container.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+set -x
+
+export QEMU_LD_PREFIX=/usr/${HOST}
+export DEJAGNU=/opt/.ci/site.exp
+cd /opt
+./configure ${HOST+--host=$HOST --disable-shared}
+make
+make dist
+BOARDSDIR=/opt/.ci make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true
diff --git a/.ci/build.sh b/.ci/build.sh
new file mode 100755
index 0000000..a638977
--- /dev/null
+++ b/.ci/build.sh
@@ -0,0 +1,143 @@
+#!/bin/bash
+
+set -x
+
+# This is a policy bound API key. It can only be used with
+# https://github.com/libffi/rlgl-policy.git.
+RLGL_KEY=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI
+
+if [ -z ${QEMU_CPU+x} ]; then
+ export SET_QEMU_CPU=
+else
+ export SET_QEMU_CPU="-e QEMU_CPU=${QEMU_CPU}"
+fi
+
+export DOCKER=docker
+
+function build_cfarm()
+{
+ curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log
+ echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ echo $(tail build.log | grep '^==LOGFILE==')
+ echo $(tail build.log | grep '^==LOGFILE==' | cut -b13-)
+ echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ curl -u ${CFARM_AUTH} "$(tail build.log | grep '^==LOGFILE==' | cut -b13-)" > libffi.log
+
+ ./rlgl l --key=${RLGL_KEY} https://rl.gl
+ ID=$(./rlgl start)
+ ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git libffi.log
+ exit $?
+}
+
+function build_linux()
+{
+ ./autogen.sh
+ ./configure ${HOST+--host=$HOST} ${CONFIGURE_OPTIONS} || cat */config.log
+ make
+ make dist
+ DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci runtest --version
+ DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci make check RUNTESTFLAGS="-a $RUNTESTFLAGS"
+
+ ./rlgl l --key=${RLGL_KEY} https://rl.gl
+ ID=$(./rlgl start)
+ ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
+ exit $?
+}
+
+function build_foreign_linux()
+{
+ ${DOCKER} run --rm -t -v $(pwd):/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.ci/build-in-container.sh
+
+ ./rlgl l --key=${RLGL_KEY} https://rl.gl
+ ID=$(./rlgl start)
+ ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
+ exit $?
+}
+
+function build_cross_linux()
+{
+ ${DOCKER} run --rm -t -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/cross-ci-build-container:latest bash -c /opt/.ci/build-in-container.sh
+
+ ./rlgl l --key=${RLGL_KEY} https://rl.gl
+ ID=$(./rlgl start)
+ ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
+ exit $?
+}
+
+function build_cross()
+{
+ ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST}
+ ${DOCKER} run --rm -t -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e RUNNER_WORKSPACE=/opt -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.ci/build-cross-in-container.sh
+
+ ./rlgl l --key=${RLGL_KEY} https://rl.gl
+ ID=$(./rlgl start)
+ ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log
+ exit $?
+}
+
+function build_ios()
+{
+ which python
+# export PYTHON_BIN=/usr/local/bin/python
+ ./generate-darwin-source-and-headers.py --only-ios
+ xcodebuild -showsdks
+ xcodebuild -project libffi.xcodeproj -target "libffi-iOS" -configuration Release -sdk iphoneos11.4
+ exit $?
+}
+
+function build_macosx()
+{
+ which python
+# export PYTHON_BIN=/usr/local/bin/python
+ ./generate-darwin-source-and-headers.py --only-osx
+ xcodebuild -showsdks
+ xcodebuild -project libffi.xcodeproj -target "libffi-Mac" -configuration Release -sdk macosx10.13
+ echo "Finished build"
+ exit $?
+}
+
+case "$HOST" in
+ arm-apple-darwin*)
+ ./autogen.sh
+ build_ios
+ ;;
+ x86_64-apple-darwin*)
+ ./autogen.sh
+ build_macosx
+ ;;
+ arm32v7-linux-gnu)
+ ./autogen.sh
+ build_foreign_linux arm quay.io/moxielogic/arm32v7-ci-build-container:latest
+ ;;
+ mips64el-linux-gnu | sparc64-linux-gnu)
+ build_cfarm
+ ;;
+ bfin-elf )
+ ./autogen.sh
+ GCC_OPTIONS=-msim build_cross
+ ;;
+ m32r-elf )
+ ./autogen.sh
+ build_cross
+ ;;
+ or1k-elf )
+ ./autogen.sh
+ build_cross
+ ;;
+ powerpc-eabisim )
+ ./autogen.sh
+ build_cross
+ ;;
+ m68k-linux-gnu )
+ ./autogen.sh
+ GCC_OPTIONS=-mcpu=547x build_cross_linux
+ ;;
+ alpha-linux-gnu | sh4-linux-gnu )
+ ./autogen.sh
+ build_cross_linux
+ ;;
+ *)
+ ./autogen.sh
+ build_linux
+ ;;
+esac
diff --git a/.ci/compile b/.ci/compile
new file mode 100755
index 0000000..655932a
--- /dev/null
+++ b/.ci/compile
@@ -0,0 +1,351 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2018-03-27.18; # UTC
+
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# 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 2, 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 <https://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" "" $nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+ file=$1
+ case $file in
+ / | /[!/]*) # absolute file, and not a UNC file
+ if test -z "$file_conv"; then
+ # lazily determine how to convert abs files
+ case `uname -s` in
+ MINGW*)
+ file_conv=mingw
+ ;;
+ CYGWIN*)
+ file_conv=cygwin
+ ;;
+ *)
+ file_conv=wine
+ ;;
+ esac
+ fi
+ case $file_conv/,$2, in
+ *,$file_conv,*)
+ ;;
+ mingw/*)
+ file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+ ;;
+ cygwin/*)
+ file=`cygpath -m "$file" || echo "$file"`
+ ;;
+ wine/*)
+ file=`winepath -w "$file" || echo "$file"`
+ ;;
+ esac
+ ;;
+ esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+ func_file_conv "$1"
+ if test -z "$lib_path"; then
+ lib_path=$file
+ else
+ lib_path="$lib_path;$file"
+ fi
+ linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+ lib=$1
+ found=no
+ save_IFS=$IFS
+ IFS=';'
+ for dir in $lib_path $LIB
+ do
+ IFS=$save_IFS
+ if $shared && test -f "$dir/$lib.dll.lib"; then
+ found=yes
+ lib=$dir/$lib.dll.lib
+ break
+ fi
+ if test -f "$dir/$lib.lib"; then
+ found=yes
+ lib=$dir/$lib.lib
+ break
+ fi
+ if test -f "$dir/lib$lib.a"; then
+ found=yes
+ lib=$dir/lib$lib.a
+ break
+ fi
+ done
+ IFS=$save_IFS
+
+ if test "$found" != yes; then
+ lib=$lib.lib
+ fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+ # Assume a capable shell
+ lib_path=
+ shared=:
+ linker_opts=
+ for arg
+ do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as 'compile cc -o foo foo.c'.
+ eat=1
+ case $2 in
+ *.o | *.[oO][bB][jJ])
+ func_file_conv "$2"
+ set x "$@" -Fo"$file"
+ shift
+ ;;
+ *)
+ func_file_conv "$2"
+ set x "$@" -Fe"$file"
+ shift
+ ;;
+ esac
+ ;;
+ -I)
+ eat=1
+ func_file_conv "$2" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
+ -I*)
+ func_file_conv "${1#-I}" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
+ -l)
+ eat=1
+ func_cl_dashl "$2"
+ set x "$@" "$lib"
+ shift
+ ;;
+ -l*)
+ func_cl_dashl "${1#-l}"
+ set x "$@" "$lib"
+ shift
+ ;;
+ -L)
+ eat=1
+ func_cl_dashL "$2"
+ ;;
+ -L*)
+ func_cl_dashL "${1#-L}"
+ ;;
+ -static)
+ shared=false
+ ;;
+ -warn)
+ eat=1
+ ;;
+ -Wl,*)
+ arg=${1#-Wl,}
+ save_ifs="$IFS"; IFS=','
+ for flag in $arg; do
+ IFS="$save_ifs"
+ linker_opts="$linker_opts $flag"
+ done
+ IFS="$save_ifs"
+ ;;
+ -Xlinker)
+ eat=1
+ linker_opts="$linker_opts $2"
+ ;;
+ -*)
+ set x "$@" "$1"
+ shift
+ ;;
+ *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+ func_file_conv "$1"
+ set x "$@" -Tp"$file"
+ shift
+ ;;
+ *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+ func_file_conv "$1" mingw
+ set x "$@" "$file"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+ done
+ if test -n "$linker_opts"; then
+ linker_opts="-link$linker_opts"
+ fi
+ exec "$@" $linker_opts
+ exit 1
+}
+
+eat=
+
+case $1 in
+ '')
+ echo "$0: No command. Try '$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+ cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
+ func_cl_wrapper "$@" # Doesn't return...
+ ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as 'compile cc -o foo foo.c'.
+ # So we strip '-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no '-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # '.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file. Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/.ci/install.sh b/.ci/install.sh
new file mode 100755
index 0000000..d3fa0e9
--- /dev/null
+++ b/.ci/install.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+set -x
+
+if [[ $RUNNER_OS != 'Linux' ]]; then
+ brew update --verbose
+ # brew update > brew-update.log 2>&1
+ # fix an issue with libtool on travis by reinstalling it
+ brew uninstall libtool;
+ brew install libtool dejagnu;
+
+ # Download and extract the rlgl client
+ wget -qO - https://rl.gl/cli/rlgl-darwin-amd64.tgz | \
+ tar --strip-components=2 -xvzf - ./rlgl/rlgl;
+
+else
+ # Download and extract the rlgl client
+ case $HOST in
+ aarch64-linux-gnu)
+ wget -qO - https://rl.gl/cli/rlgl-linux-arm.tgz | \
+ tar --strip-components=2 -xvzf - ./rlgl/rlgl;
+ ;;
+ ppc64le-linux-gnu)
+ wget -qO - https://rl.gl/cli/rlgl-linux-ppc64le.tgz | \
+ tar --strip-components=2 -xvzf - ./rlgl/rlgl;
+ ;;
+ s390x-linux-gnu)
+ wget -qO - https://rl.gl/cli/rlgl-linux-s390x.tgz | \
+ tar --strip-components=2 -xvzf - ./rlgl/rlgl;
+ ;;
+ *)
+ wget -qO - https://rl.gl/cli/rlgl-linux-amd64.tgz | \
+ tar --strip-components=2 -xvzf - ./rlgl/rlgl;
+ ;;
+ esac
+
+ sudo apt-get clean # clear the cache
+ sudo apt-get update
+ case $HOST in
+ mips64el-linux-gnu | sparc64-linux-gnu)
+ ;;
+ alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu)
+ sudo apt-get install qemu-user-static
+ ;;
+ hppa-linux-gnu )
+ sudo apt-get install -y qemu-user-static g++-5-hppa-linux-gnu
+ ;;
+ i386-pc-linux-gnu)
+ sudo apt-get install gcc-multilib g++-multilib;
+ ;;
+ moxie-elf)
+ echo 'deb [trusted=yes] https://repos.moxielogic.org:7114/MoxieLogic moxiedev main' | sudo tee -a /etc/apt/sources.list
+ sudo apt-get clean # clear the cache
+ sudo apt-get update ## -qq
+ sudo apt-get update
+ sudo apt-get install -y --allow-unauthenticated moxielogic-moxie-elf-gcc moxielogic-moxie-elf-gcc-c++ moxielogic-moxie-elf-gcc-libstdc++ moxielogic-moxie-elf-gdb-sim texinfo sharutils texlive dejagnu
+ ;;
+ x86_64-w64-mingw32)
+ sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 wine;
+ ;;
+ i686-w32-mingw32)
+ sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 wine;
+ ;;
+ esac
+ case $HOST in
+ arm32v7-linux-gnu)
+ # don't install host tools
+ ;;
+ *)
+ sudo apt-get install dejagnu texinfo sharutils
+ ;;
+ esac
+fi
diff --git a/.ci/m32r-sim.exp b/.ci/m32r-sim.exp
new file mode 100644
index 0000000..c18123f
--- /dev/null
+++ b/.ci/m32r-sim.exp
@@ -0,0 +1,58 @@
+# Copyright (C) 2010, 2019 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu 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 2 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA.
+
+# This is a list of toolchains that are supported on this board.
+set_board_info target_install {m32r-elf}
+
+# Load the generic configuration for this board. This will define a basic set
+# of routines needed by the tool to communicate with the board.
+load_generic_config "sim"
+
+# basic-sim.exp is a basic description for the standard Cygnus simulator.
+load_base_board_description "basic-sim"
+
+# "m32r" is the name of the sim subdir in devo/sim.
+setup_sim m32r
+
+# No multilib options needed by default.
+process_multilib_options ""
+
+# We only support newlib on this target. We assume that all multilib
+# options have been specified before we get here.
+
+set_board_info compiler "[find_gcc]"
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
+
+# Configuration settings for testsuites
+set_board_info noargs 1
+set_board_info gdb,nosignals 1
+set_board_info gdb,noresults 1
+set_board_info gdb,cannot_call_functions 1
+set_board_info gdb,skip_float_tests 1
+set_board_info gdb,can_reverse 1
+set_board_info gdb,use_precord 1
+
+# More time is needed
+set_board_info gcc,timeout 800
+set_board_info gdb,timeout 60
+
+# Used by a few gcc.c-torture testcases to delimit how large the stack can
+# be.
+set_board_info gcc,stack_size 5000
+
diff --git a/.ci/moxie-sim.exp b/.ci/moxie-sim.exp
new file mode 100644
index 0000000..32979ea
--- /dev/null
+++ b/.ci/moxie-sim.exp
@@ -0,0 +1,60 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu 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 2 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA.
+
+# This is a list of toolchains that are supported on this board.
+set_board_info target_install {moxie-elf}
+
+# Load the generic configuration for this board. This will define a basic set
+# of routines needed by the tool to communicate with the board.
+load_generic_config "sim"
+
+# basic-sim.exp is a basic description for the standard Cygnus simulator.
+load_base_board_description "basic-sim"
+
+# "moxie" is the name of the sim subdir in devo/sim.
+setup_sim moxie
+
+# No multilib options needed by default.
+process_multilib_options ""
+
+# We only support newlib on this target. We assume that all multilib
+# options have been specified before we get here.
+
+set_board_info compiler "[find_gcc]"
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
+# No linker script needed.
+set_board_info ldscript "-Tsim.ld"
+
+# Configuration settings for testsuites
+set_board_info noargs 1
+set_board_info gdb,nosignals 1
+set_board_info gdb,noresults 1
+set_board_info gdb,cannot_call_functions 1
+set_board_info gdb,skip_float_tests 1
+set_board_info gdb,can_reverse 1
+set_board_info gdb,use_precord 1
+
+# More time is needed
+set_board_info gcc,timeout 800
+set_board_info gdb,timeout 60
+
+# Used by a few gcc.c-torture testcases to delimit how large the stack can
+# be.
+set_board_info gcc,stack_size 5000
+
diff --git a/.ci/msvs-detect b/.ci/msvs-detect
new file mode 100755
index 0000000..601575c
--- /dev/null
+++ b/.ci/msvs-detect
@@ -0,0 +1,1103 @@
+#!/usr/bin/env bash
+# ################################################################################################ #
+# MetaStack Solutions Ltd. #
+# ################################################################################################ #
+# Microsoft C Compiler Environment Detection Script #
+# ################################################################################################ #
+# Copyright (c) 2016, 2017, 2018, 2019, 2020 MetaStack Solutions Ltd. #
+# ################################################################################################ #
+# Author: David Allsopp #
+# 16-Feb-2016 #
+# ################################################################################################ #
+# Redistribution and use in source and binary forms, with or without modification, are permitted #
+# provided that the following two conditions are met: #
+# 1. Redistributions of source code must retain the above copyright notice, this list of #
+# conditions and the following disclaimer. #
+# 2. Neither the name of MetaStack Solutions Ltd. nor the names of its contributors may be #
+# used to endorse or promote products derived from this software without specific prior #
+# written permission. #
+# #
+# This software is provided by the Copyright Holder 'as is' and any express or implied warranties #
+# including, but not limited to, the implied warranties of merchantability and fitness for a #
+# particular purpose are disclaimed. In no event shall the Copyright Holder be liable for any #
+# direct, indirect, incidental, special, exemplary, or consequential damages (including, but not #
+# limited to, procurement of substitute goods or services; loss of use, data, or profits; or #
+# business interruption) however caused and on any theory of liability, whether in contract, #
+# strict liability, or tort (including negligence or otherwise) arising in any way out of the use #
+# of this software, even if advised of the possibility of such damage. #
+# ################################################################################################ #
+
+VERSION=0.4.1
+
+# debug [level=2] message
+debug ()
+{
+ if [[ -z ${2+x} ]] ; then
+ DEBUG_LEVEL=2
+ else
+ DEBUG_LEVEL=$1
+ shift
+ fi
+
+ if [[ $DEBUG -ge $DEBUG_LEVEL ]] ; then
+ echo "$1">&2
+ fi
+}
+
+# warning message
+warning ()
+{
+ if [[ $DEBUG -gt 0 ]] ; then
+ echo "Warning: $1">&2
+ fi
+}
+
+# reg_string key value
+# Retrieves a REG_SZ value from the registry (redirected on WOW64)
+reg_string ()
+{
+ reg query "$1" /v "$2" 2>/dev/null | tr -d '\r' | sed -ne "s/ *$2 *REG_SZ *//p"
+}
+
+# reg64_string key value
+# As reg_string, but without WOW64 redirection (i.e. guaranteed access to 64-bit registry)
+reg64_string ()
+{
+ $REG64 query "$1" /v "$2" 2>/dev/null | tr -d '\r' | sed -ne "s/ *$2 *REG_SZ *//p"
+}
+
+# find_in list file
+# Increments $RET if file does not exist in any of the directories in the *-separated list
+find_in ()
+{
+ debug 4 "Looking for $2 in $1"
+ if [[ -z $1 ]] ; then
+ STATUS=1
+ else
+ IFS=*
+ STATUS=1
+ for f in $1; do
+ if [[ -e "$f/$2" ]] ; then
+ STATUS=0
+ break
+ fi
+ done
+ unset IFS
+ fi
+ if [[ $STATUS -eq 1 ]] ; then
+ debug 4 "$2 not found"
+ fi
+ ((RET+=STATUS))
+}
+
+# check_environment PATH INC LIB name arch
+# By checking for the presence of various files, verifies that PATH, INC and LIB provide a complete
+# compiler and indicates this in its return status. RET is assumed to be zero on entry. $ASSEMBLER
+# will contain the name of assembler for this compiler series (ml.exe or ml64.exe).
+# The following files are checked:
+# cl.exe PATH Microsoft C compiler
+# kernel32.lib LIB Implies Windows SDK present
+# link.exe PATH Microsoft Linker
+# ml[64].exe PATH Microsoft Assembler (ml.exe or ml64.exe)
+# msvcrt.lib LIB Implies C Runtime Libraries present
+# mt.exe PATH Microsoft Manifest Tool
+# oldnames.lib LIB Implies C Runtime Libraries present
+# rc.exe PATH Microsoft Resource Compiler (implies tools present)
+# stdlib.h INC Implies Microsoft C Runtime Libraries present
+# windows.h INC Implies Windows SDK present
+# oldnames.lib is included, because certain SDKs and older versions don't correctly install the
+# entire runtime if only some options (e.g. Dynamic Runtime and not Static) are selected.
+check_environment ()
+{
+ debug 4 "Checking $4 ($5)"
+ for tool in cl rc link ; do
+ find_in "$1" $tool.exe
+ done
+
+ if [[ $RET -gt 0 ]] ; then
+ warning "Microsoft C Compiler tools not all found - $4 ($5) excluded"
+ return 1
+ fi
+
+ RET=0
+ find_in "$2" windows.h
+ find_in "$3" kernel32.lib
+ if [[ $RET -gt 0 ]] ; then
+ warning "Windows SDK not all found - $4 ($5) excluded"
+ return 1
+ fi
+
+ RET=0
+ find_in "$2" stdlib.h
+ find_in "$3" msvcrt.lib
+ find_in "$3" oldnames.lib
+ if [[ $RET -gt 0 ]] ; then
+ warning "Microsoft C runtime library not all found - $4 ($5) excluded"
+ return 1
+ fi
+
+ ASSEMBLER=ml${5#x}
+ ASSEMBLER=${ASSEMBLER%86}.exe
+ if [[ $ML_REQUIRED -eq 1 ]] ; then
+ RET=0
+ find_in "$1" $ASSEMBLER
+ if [[ $RET -gt 0 ]] ; then
+ warning "Microsoft Assembler ($ASSEMBLER) not found - $4 ($5)"
+ return 1
+ fi
+ fi
+
+ if [[ $MT_REQUIRED -eq 1 ]] ; then
+ RET=0
+ find_in "$1" mt.exe
+ if [[ $RET -gt 0 ]] ; then
+ warning "Microsoft Manifest Tool not found - $4 ($5)"
+ return 1
+ fi
+ fi
+
+ return 0
+}
+
+# output VAR value arch
+# Outputs a command for setting VAR to value based on $OUTPUT. If $ENV_ARCH is arch, then an empty
+# value (i.e. no change) is output.
+output ()
+{
+ if [[ $3 = $ENV_ARCH ]] ; then
+ VALUE=
+ else
+ VALUE=$2
+ fi
+ case "$OUTPUT" in
+ 0)
+ echo "$1='${VALUE//\'/\'\"\'\"\'}'";;
+ 1)
+ VALUE=${VALUE//#/\\\#}
+ echo "$1=${VALUE//\$/\$\$}";;
+ esac
+}
+
+# DEBUG Debugging level
+# MODE Operation mode
+# 0 - Normal
+# 1 - --all
+# 2 - --help
+# 3 - --version
+# OUTPUT --output option
+# 0 - =shell
+# 1 - =make
+# MT_REQUIRED --with-mt
+# ML_REQUIRED --with-assembler
+# TARGET_ARCH Normalised --arch (x86, x64 or blank for both)
+# LEFT_ARCH \ If $TARGET_ARCH is blank, these will be x86 and x64 respectively, otherwise they
+# RIGHT_ARCH / equal $TARGET_ARCH
+# SCAN_ENV Controls from parsing whether the environment should be queried for a compiler
+DEBUG=0
+MODE=0
+OUTPUT=0
+MT_REQUIRED=0
+ML_REQUIRED=0
+TARGET_ARCH=
+SCAN_ENV=0
+
+# Various PATH messing around means it's sensible to know where tools are now
+WHICH=$(which which)
+
+if [[ $(uname --operating-system 2>/dev/null) = "Msys" ]] ; then
+ # Prevent MSYS from translating command line switches to paths
+ SWITCH_PREFIX='//'
+else
+ SWITCH_PREFIX='/'
+fi
+
+# Parse command-line. At the moment, the short option which usefully combines with anything is -d,
+# so for the time being, combining short options is not permitted, as the loop becomes even less
+# clear with getopts. GNU getopt isn't installed by default on Cygwin...
+if [[ $@ != "" ]] ; then
+ while true ; do
+ case "$1" in
+ # Mode settings ($MODE)
+ -a|--all)
+ MODE=1
+ shift 1;;
+ -h|--help)
+ MODE=2
+ shift;;
+ -v|--version)
+ MODE=3
+ shift;;
+
+ # Simple flags ($MT_REQUIRED and $ML_REQUIRED)
+ --with-mt)
+ MT_REQUIRED=1
+ shift;;
+ --with-assembler)
+ ML_REQUIRED=1
+ shift;;
+
+ # -o, --output ($OUTPUT)
+ -o|--output)
+ case "$2" in
+ shell)
+ ;;
+ make)
+ OUTPUT=1;;
+ *)
+ echo "$0: unrecognised option for $1: '$2'">&2
+ exit 2;;
+ esac
+ shift 2;;
+ -oshell|--output=shell)
+ shift;;
+ -omake|--output=make)
+ OUTPUT=1
+ shift;;
+ -o*)
+ echo "$0: unrecognised option for -o: '${1#-o}'">&2
+ exit 2;;
+ --output=*)
+ echo "$0: unrecognised option for --output: '${1#--output=}'">&2
+ exit 2;;
+
+ # -x, --arch ($TARGET_ARCH)
+ -x|--arch)
+ case "$2" in
+ 86|x86)
+ TARGET_ARCH=x86;;
+ 64|x64)
+ TARGET_ARCH=x64;;
+ *)
+ echo "$0: unrecognised option for $1: '$2'">&2
+ exit 2
+ esac
+ shift 2;;
+ -x86|-xx86|--arch=x86|--arch=86)
+ TARGET_ARCH=x86
+ shift;;
+ -x64|-xx64|--arch=x64|--arch=64)
+ TARGET_ARCH=x64
+ shift;;
+ -x*)
+ echo "$0: unrecognised option for -x: '${1#-x}'">&2
+ exit 2;;
+ --arch=*)
+ echo "$0: unrecognised option for --arch: '${1#--arch}'">&2
+ exit 2;;
+
+ # -d, --debug ($DEBUG)
+ -d*)
+ DEBUG=${1#-d}
+ if [[ -z $DEBUG ]] ; then
+ DEBUG=1
+ fi
+ shift;;
+ --debug=*)
+ DEBUG=${1#*=}
+ shift;;
+ --debug)
+ DEBUG=1
+ shift;;
+
+ # End of option marker
+ --)
+ shift
+ break;;
+
+ # Invalid options
+ --*)
+ echo "$0: unrecognised option: '${1%%=*}'">&2
+ exit 2;;
+ -*)
+ echo "$0: unrecognised option: '${1:1:1}'">&2
+ exit 2;;
+
+ # MSVS_PREFERENCE (without end-of-option marker)
+ *)
+ break;;
+ esac
+ done
+
+ if [[ -n ${1+x} ]] ; then
+ if [[ $MODE -eq 1 ]] ; then
+ echo "$0: cannot specify MSVS_PREFERENCE and --all">&2
+ exit 2
+ else
+ MSVS_PREFERENCE="$@"
+ fi
+ fi
+fi
+
+# Options sanitising
+if [[ $MODE -eq 1 ]] ; then
+ if [[ -n $TARGET_ARCH ]] ; then
+ echo "$0: --all and --arch are mutually exclusive">&2
+ exit 2
+ fi
+ MSVS_PREFERENCE=
+ SCAN_ENV=1
+elif [[ -z ${MSVS_PREFERENCE+x} ]] ; then
+ MSVS_PREFERENCE='@;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0'
+fi
+
+MSVS_PREFERENCE=${MSVS_PREFERENCE//;/ }
+
+if [[ -z $TARGET_ARCH ]] ; then
+ LEFT_ARCH=x86
+ RIGHT_ARCH=x64
+else
+ LEFT_ARCH=$TARGET_ARCH
+ RIGHT_ARCH=$TARGET_ARCH
+fi
+
+# Command line parsing complete (MSVS_PREFERENCE pending)
+
+NAME="Microsoft C Compiler Environment Detection Script"
+case $MODE in
+ 2)
+ echo "$NAME"
+ echo "Queries the environment and registry to locate Visual Studio / Windows SDK"
+ echo "installations and uses their initialisation scripts (SetEnv.cmd, vcvarsall.bat,"
+ echo "etc.) to determine INCLUDE, LIB and PATH alterations."
+ echo
+ echo "Usage:"
+ echo " $0 [OPTIONS] [--] [MSVS_PREFERENCE]"
+ echo
+ echo "Options:"
+ echo " -a, --all Display all available compiler packages"
+ echo " -x, --arch=ARCH Only consider packages for ARCH (x86 or x64). Default is"
+ echo " to return packages containing both architectures"
+ echo " -d, --debug[=LEVEL] Set debug messages level"
+ echo " -h, --help Display this help screen"
+ echo " -o, --output=OUTPUT Set final output. Default is shell. Valid values:"
+ echo " shell - shell assignments, for use with eval"
+ echo " make - make assignments, for inclusion in a Makefile"
+ echo " -v, --version Display the version"
+ echo " --with-mt Only consider packages including the Manifest Tool"
+ echo " --with-assembler Only consider packages including an assembler"
+ echo
+ echo "If MSVS_PREFERENCE is not given, then the environment variable MSVS_PREFERENCE"
+ echo "is read. MSVS_PREFERENCE is a semicolon separated list of preferred versions."
+ echo "Three kinds of version notation are supported:"
+ echo " 1. @ - which refers to the C compiler found in PATH (if it can be identified)"
+ echo " (this allows the C compiler corresponding to the opposite architecture to"
+ echo " be selected, if possible)."
+ echo " 2. mm.n - which refers to a Visual Studio version (e.g. 14.0, 7.1) but which"
+ echo " also allows an SDK to provide the compiler (e.g. Windows SDK 7.1 provides"
+ echo " 10.0). Visual Studio packages are always preferred ahead of SDKs."
+ echo " 3. SPEC - an actual package specification. Visual Studio packages are VSmm.n"
+ echo " (e.g. VS14.0, VS7.1) and SDK packages are SDKm.n (e.g. SDK7.1)."
+ echo " Any Visual Studio 2017 update can be selected with VS15.*"
+ echo "The default behaviour is to match the environment compiler followed by the most"
+ echo "recent version of the compiler."
+ exit 0;;
+ 3)
+ echo "$NAME"
+ echo "Version $VERSION"
+ exit 0;;
+esac
+
+# Known compiler packages. Visual Studio .NET 2002 onwards. Detection is in place for Visual Studio
+# 2005 Express, but because it doesn't include a Windows SDK, it can only ever be detected if the
+# script has been launched from within a Platform SDK command prompt (this provides the Windows
+# Headers and Libraries which allows this script to detect the rest).
+# Each element is either a Visual Studio or SDK package and the value is the syntax for a bash
+# associative array to be eval'd. Each of these contains the following properties:
+# NAME - the friendly name of the package
+# ENV - (VS only) the version-specific portion of the VSCOMNTOOLS environment variable
+# VERSION - (VS only) version number of the package
+# ARCH - Lists the architectures available in this version
+# ARCH_SWITCHES - The script is assumed to accept x86 and x64 to indicate architecture. This key
+# contains another eval'd associative array allowing alternate values to be given
+# SETENV_RELEASE - (SDK only) script switch necessary to select release than debugging versions
+# EXPRESS - (VS only) the prefix to the registry key to detect the Express edition
+# EXPRESS_ARCH - (VS only) overrides ARCH if Express edition is detected
+# EXPRESS_ARCH_SWITCHES - (VS only) overrides ARCH_SWITCHES if Express edition is detected
+# VC_VER - (SDK only) specifies the version of the C Compilers included in the SDK (SDK
+# equivalent of the VERSION key)
+# REG_KEY - (SDK only) registry key to open to identify this package installation
+# REG_VALUE - (SDK only) registry value to query to identify this package installation
+# VSWHERE - (VS 2017+) is 1 if the compiler can only be detected using vswhere
+# For a while, Windows SDKs followed a standard pattern which is stored in the SDK element and
+# copied to the appropriate version. SDKs after 7.1 do not include compilers, and so are not
+# captured (as of Visual Studio 2015, the Windows SDK is official part of Visual Studio).
+declare -A COMPILERS
+SDK52_KEY='HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3'
+COMPILERS=(
+ ["VS7.0"]='(
+ ["NAME"]="Visual Studio .NET 2002"
+ ["ENV"]=""
+ ["VERSION"]="7.0"
+ ["ARCH"]="x86")'
+ ["VS7.1"]='(
+ ["NAME"]="Visual Studio .NET 2003"
+ ["ENV"]="71"
+ ["VERSION"]="7.1"
+ ["ARCH"]="x86")'
+ ["VS8.0"]='(
+ ["NAME"]="Visual Studio 2005"
+ ["ENV"]="80"
+ ["VERSION"]="8.0"
+ ["EXPRESS"]="VC"
+ ["ARCH"]="x86 x64"
+ ["EXPRESS_ARCH"]="x86")'
+ ["VS9.0"]='(
+ ["NAME"]="Visual Studio 2008"
+ ["ENV"]="90"
+ ["VERSION"]="9.0"
+ ["EXPRESS"]="VC"
+ ["ARCH"]="x86 x64"
+ ["EXPRESS_ARCH"]="x86")'
+ ["VS10.0"]='(
+ ["NAME"]="Visual Studio 2010"
+ ["ENV"]="100"
+ ["VERSION"]="10.0"
+ ["EXPRESS"]="VC"
+ ["ARCH"]="x86 x64"
+ ["EXPRESS_ARCH"]="x86")'
+ ["VS11.0"]='(
+ ["NAME"]="Visual Studio 2012"
+ ["ENV"]="110"
+ ["VERSION"]="11.0"
+ ["EXPRESS"]="WD"
+ ["ARCH"]="x86 x64"
+ ["EXPRESS_ARCH_SWITCHES"]="([\"x64\"]=\"x86_amd64\")")'
+ ["VS12.0"]='(
+ ["NAME"]="Visual Studio 2013"
+ ["ENV"]="120"
+ ["VERSION"]="12.0"
+ ["EXPRESS"]="WD"
+ ["ARCH"]="x86 x64"
+ ["EXPRESS_ARCH_SWITCHES"]="([\"x64\"]=\"x86_amd64\")")'
+ ["VS14.0"]='(
+ ["NAME"]="Visual Studio 2015"
+ ["ENV"]="140"
+ ["VERSION"]="14.0"
+ ["ARCH"]="x86 x64")'
+ ["VS15.*"]='(
+ ["NAME"]="Visual Studio 2017"
+ ["VSWHERE"]="1")'
+ ["VS16.*"]='(
+ ["NAME"]="Visual Studio 2019"
+ ["VSWHERE"]="1")'
+ ["SDK5.2"]='(
+ ["NAME"]="Windows Server 2003 SP1 SDK"
+ ["VC_VER"]="8.0"
+ ["REG_KEY"]="$SDK52_KEY"
+ ["REG_VALUE"]="Install Dir"
+ ["SETENV_RELEASE"]="/RETAIL"
+ ["ARCH"]="x64"
+ ["ARCH_SWITCHES"]="([\"x64\"]=\"/X64\")")'
+ ["SDK"]='(
+ ["NAME"]="Generalised Windows SDK"
+ ["SETENV_RELEASE"]="/Release"
+ ["ARCH"]="x86 x64"
+ ["ARCH_SWITCHES"]="([\"x86\"]=\"/x86\" [\"x64\"]=\"/x64\")")'
+ ["SDK6.1"]='(
+ ["NAME"]="Windows Server 2008 with .NET 3.5 SDK"
+ ["VC_VER"]="9.0")'
+ ["SDK7.0"]='(
+ ["NAME"]="Windows 7 with .NET 3.5 SP1 SDK"
+ ["VC_VER"]="9.0")'
+ ["SDK7.1"]='(
+ ["NAME"]="Windows 7 with .NET 4 SDK"
+ ["VC_VER"]="10.0")'
+)
+
+# FOUND is ultimately an associative array containing installed compiler packages. It's
+# hijacked here as part of MSVS_PREFERENCE validation.
+# Ultimately, it contains a copy of the value from COMPILERS with the following extra keys:
+# IS_EXPRESS - (VS only) indicates whether the Express edition was located
+# SETENV - (SDK only) the full location of the SetEnv.cmd script
+# ASSEMBLER - the name of the assembler (ml or ml64)
+# MSVS_PATH \
+# MSVS_INC > prefix values for PATH, INCLUDE and LIB determined by running the scripts.
+# MSVS_LIB /
+declare -A FOUND
+
+# Check that MSVS_PREFERENCE is valid and contains no repetitions.
+for v in $MSVS_PREFERENCE ; do
+ if [[ -n ${FOUND[$v]+x} ]] ; then
+ echo "$0: corrupt MSVS_PREFERENCE: repeated '$v'">&2
+ exit 2
+ fi
+ if [[ $v != "@" ]] ; then
+ if [[ -z ${COMPILERS[$v]+x} && -z ${COMPILERS["VS$v"]+x} && -z ${COMPILERS[${v%.*}.*]+x} ]] ; then
+ echo "$0: corrupt MSVS_PREFERENCE: unknown compiler '$v'">&2
+ exit 2
+ fi
+ else
+ SCAN_ENV=1
+ fi
+ FOUND["$v"]=""
+done
+
+# Reset FOUND for later use.
+FOUND=()
+
+# Scan the environment for a C compiler, and check that it's valid. Throughout the rest of the
+# script, it is assumed that if ENV_ARCH is set then there is a valid environment compiler.
+if [[ $SCAN_ENV -eq 1 ]] ; then
+ if "$WHICH" cl >/dev/null 2>&1 ; then
+ # Determine its architecture from the Microsoft Logo line.
+ ENV_ARCH=$(cl 2>&1 | head -1 | tr -d '\r')
+ case "${ENV_ARCH#* for }" in
+ x64|AMD64)
+ ENV_ARCH=x64;;
+ 80x86|x86)
+ ENV_ARCH=x86;;
+ *)
+ echo "Unable to identify C compiler architecture from '${ENV_ARCH#* for }'">&2
+ echo "Environment C compiler discarded">&2
+ unset ENV_ARCH;;
+ esac
+
+ # Environment variable names are a bit of a nightmare on Windows - they are actually case
+ # sensitive (at the kernel level) but not at the user level! To compound the misery is that SDKs
+ # use Include and Lib where vcvars32 tends to use INCLUDE and LIB. Windows versions also contain
+ # a mix of Path and PATH, but fortunately Cygwin normalises that to PATH for us! For this
+ # reason, use env to determine the actual case of the LIB and INCLUDE variables.
+ if [[ -n ${ENV_ARCH+x} ]] ; then
+ RET=0
+ ENV_INC=$(env | sed -ne 's/^\(INCLUDE\)=.*/\1/pi')
+ ENV_LIB=$(env | sed -ne 's/^\(LIB\)=.*/\1/pi')
+ if [[ -z $ENV_INC || -z $ENV_LIB ]] ; then
+ warning "Microsoft C Compiler Include and/or Lib not set - Environment C compiler ($ENV_ARCH) excluded"
+ unset ENV_ARCH
+ else
+ if check_environment "${PATH//:/*}" \
+ "${!ENV_INC//;/*}" \
+ "${!ENV_LIB//;/*}" \
+ "Environment C compiler" \
+ "$ENV_ARCH" ; then
+ ENV_CL=$("$WHICH" cl)
+ ENV_cl=${ENV_CL,,}
+ ENV_cl=${ENV_cl/bin\/*_/bin\/}
+ debug "Environment appears to include a compiler at $ENV_CL"
+ if [[ -n $TARGET_ARCH && $TARGET_ARCH != $ENV_ARCH ]] ; then
+ debug "But architecture doesn't match required value"
+ unset ENV_ARCH
+ fi
+ else
+ unset ENV_ARCH
+ fi
+ fi
+ fi
+ fi
+fi
+
+# Even if launched from a 64-bit Command Prompt, Cygwin is usually 32-bit and so the scripts
+# executed will inherit that fact. This is a problem when querying the registry, but fortunately
+# WOW64 provides a mechanism to break out of the 32-bit environment by mapping $WINDIR/sysnative to
+# the real 64-bit programs.
+# Thus:
+# MS_ROOT is the 32-bit Microsoft Registry key (all Visual Studio keys are located there)
+# REG64 is the processor native version of the reg utility (allowing 64-bit keys to be read for
+# the SDKs)
+if [[ -n ${PROCESSOR_ARCHITEW6432+x} ]] ; then
+ debug "WOW64 detected"
+ MS_ROOT='HKLM\SOFTWARE\Microsoft'
+ REG64=$WINDIR/sysnative/reg
+else
+ MS_ROOT='HKLM\SOFTWARE\Wow6432Node\Microsoft'
+ REG64=reg
+fi
+
+# COMPILER contains each eval'd element from COMPILERS
+declare -A COMPILER
+
+# Scan the registry for compiler package (vswhere is later)
+for i in "${!COMPILERS[@]}" ; do
+ eval COMPILER=${COMPILERS[$i]}
+
+ if [[ -n ${COMPILER["ENV"]+x} ]] ; then
+ # Visual Studio package - test for its environment variable
+ ENV=VS${COMPILER["ENV"]}COMNTOOLS
+ if [[ -n ${!ENV+x} ]] ; then
+ debug "$ENV is a candidate"
+ TEST_PATH=${!ENV%\"}
+ TEST_PATH=$(cygpath -u -f - <<< ${TEST_PATH#\"})
+ if [[ -e $TEST_PATH/vsvars32.bat ]] ; then
+ debug "Directory pointed to by $ENV contains vsvars32.bat"
+ EXPRESS=0
+ # Check for the primary Visual Studio registry value indicating installation
+ INSTALL_DIR=$(reg_string "$MS_ROOT\\VisualStudio\\${COMPILER["VERSION"]}" InstallDir)
+ if [[ -z $INSTALL_DIR ]] ; then
+ if [[ -n ${COMPILER["EXPRESS"]+x} ]] ; then
+ TEST_KEY="$MS_ROOT\\${COMPILER["EXPRESS"]}Express\\${COMPILER["VERSION"]}"
+ INSTALL_DIR=$(reg_string "$TEST_KEY" InstallDir)
+ # Exception for Visual Studio 2005 Express, which doesn't set the registry correctly, so
+ # set INSTALL_DIR to a fake value to pass the next test.
+ if [[ ${COMPILER["VERSION"]} = "8.0" ]] ; then
+ INSTALL_DIR=$(cygpath -w "$TEST_PATH")
+ EXPRESS=1
+ else
+ if [[ -z $INSTALL_DIR ]] ; then
+ warning "vsvars32.bat found, but registry value not located (Exp or Pro)"
+ else
+ EXPRESS=1
+ fi
+ fi
+ else
+ warning "vsvars32.bat found, but registry value not located"
+ fi
+ fi
+
+ if [[ -n $INSTALL_DIR ]] ; then
+ if [[ ${TEST_PATH%/} = $(cygpath -u "$INSTALL_DIR\\..\\Tools") ]] ; then
+ RESULT=${COMPILERS[$i]%)}
+ DISPLAY=${COMPILER["NAME"]}
+ if [[ $EXPRESS -eq 1 ]] ; then
+ DISPLAY="$DISPLAY Express"
+ fi
+ FOUND+=(["$i"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"IS_EXPRESS\"]=\"$EXPRESS\")")
+ debug "${COMPILER["NAME"]} accepted for further detection"
+ else
+ warning "$ENV doesn't agree with registry"
+ fi
+ else
+ warning "vsvars32.bat found, but registry settings not found"
+ fi
+ else
+ warning "$ENV set, but vsvars32.bat not found"
+ fi
+ fi
+ elif [[ -n ${COMPILER["REG_KEY"]+x} ]] ; then
+ # SDK with explicit registry detection value
+ INSTALL_DIR=$(reg64_string "${COMPILER["REG_KEY"]}" "${COMPILER["REG_VALUE"]}")
+ if [[ -n $INSTALL_DIR ]] ; then
+ TEST_PATH=$(cygpath -u "$INSTALL_DIR")
+ if [[ -e $TEST_PATH/SetEnv.cmd ]] ; then
+ RESULT=${COMPILERS[$i]%)}
+ FOUND+=(["$i"]="$RESULT [\"DISPLAY\"]=\"${COMPILER["NAME"]}\" [\"SETENV\"]=\"$INSTALL_DIR\\SetEnv.cmd\")")
+ debug "${COMPILER["NAME"]} accepted for further detection"
+ else
+ warning "Registry set for Windows Server 2003 SDK, but SetEnv.cmd not found"
+ fi
+ fi
+ fi
+done
+
+# Now enumerate installed SDKs for v6.0+
+SDK_ROOT='HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows'
+for i in $(reg query "$SDK_ROOT" 2>/dev/null | tr -d '\r' | sed -ne '/Windows\\v/s/.*\\//p') ; do
+ debug "Analysing SDK key $SDK_ROOT\\$i"
+ INSTALL_DIR=$(reg_string "$SDK_ROOT\\$i" InstallationFolder)
+ if [[ -n $INSTALL_DIR ]] ; then
+ TEST_PATH=$(cygpath -u "$INSTALL_DIR")
+ if [[ -e $TEST_PATH/Bin/SetEnv.cmd ]] ; then
+ if [[ -z ${COMPILERS["SDK${i#v}"]+x} ]] ; then
+ warning "SDK $i is not known to this script - assuming compatibility"
+ DISPLAY="Windows SDK $i"
+ else
+ eval COMPILER=${COMPILERS["SDK${i#v}"]}
+ DISPLAY=${COMPILER['NAME']}
+ fi
+ RESULT=${COMPILERS['SDK']%)}
+ FOUND+=(["SDK${i/v/}"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"SETENV\"]=\"$INSTALL_DIR\\Bin\\SetEnv.cmd\")")
+ else
+ if [[ -n ${COMPILERS["SDK${i#v}"]+x} ]] ; then
+ warning "Registry set for Windows SDK $i, but SetEnv.cmd not found"
+ fi
+ fi
+ else
+ warning "Registry key for Windows SDK $i doesn't contain expected InstallationFolder value"
+ fi
+done
+
+# Now enumerate Visual Studio 2017+ instances
+VSWHERE=$(dirname $(realpath $0))/vswhere.exe
+if [[ ! -x $VSWHERE ]] ; then
+ VSWHERE="$(printenv 'ProgramFiles(x86)')\\Microsoft Visual Studio\\Installer\\vswhere.exe"
+ VSWHERE=$(echo $VSWHERE| cygpath -f -)
+fi
+if [[ -x $VSWHERE ]] ; then
+ debug "$VSWHERE found"
+ while IFS= read -r line; do
+ case ${line%: *} in
+ instanceId)
+ INSTANCE=${line#*: };;
+ installationPath)
+ INSTANCE_PATH=${line#*: };;
+ installationVersion)
+ INSTANCE_VER=${line#*: }
+ INSTANCE_VER=${INSTANCE_VER%.*}
+ INSTANCE_VER=${INSTANCE_VER%.*};;
+ displayName)
+ INSTANCE_NAME=${line#*: }
+ debug "Looking at $INSTANCE in $INSTANCE_PATH ($INSTANCE_VER $INSTANCE_NAME)"
+ if [[ -e "$(echo $INSTANCE_PATH| cygpath -f -)/VC/Auxiliary/Build/vcvarsall.bat" ]] ; then
+ debug "vcvarsall.bat found"
+ FOUND+=(["VS$INSTANCE_VER"]="([\"DISPLAY\"]=\"$INSTANCE_NAME\" [\"ARCH\"]=\"x86 x64\" [\"SETENV\"]=\"$INSTANCE_PATH\\VC\\Auxiliary\\Build\\vcvarsall.bat\" [\"SETENV_RELEASE\"]=\"\")")
+ else
+ warning "vcvarsall.bat not found for $INSTANCE"
+ fi;;
+ esac
+ done < <("$VSWHERE" -all -nologo | tr -d '\r')
+fi
+
+if [[ $DEBUG -gt 1 ]] ; then
+ for i in "${!FOUND[@]}" ; do
+ echo "Inspect $i">&2
+ done
+fi
+
+# Basic scanning is complete, now interrogate the packages which seem to be installed and ensure
+# that they pass the check_environment tests.
+
+# CANDIDATES is a hash table of the keys of FOUND. The result of the next piece of processing is to
+# derive two arrays PREFERENCE and TEST. TEST will contain a list of the keys of FOUND in the order
+# in which they should be evaluated. PREFERENCE contains a parsed version of MSVS_PREFERENCE but
+# filtered on the basis of the compiler packages already identified. The current "hoped for"
+# preference is stored in $pref (the index into PREFERENCE) and $PREF (which is
+# ${PREFERENCE[$pref]}). These two arrays together allow testing to complete quickly if the desired
+# version is found (note that often this won't be possible as the @ environment option requires all
+# packages to be tested in order to be sure that the environment compiler is not ambiguous).
+declare -A CANDIDATES
+for i in "${!FOUND[@]}" ; do
+ CANDIDATES[$i]="";
+done
+
+# For --all, act as though MSVS_PREFERENCE were "@" because this causes all packages to be tested.
+if [[ $MODE -eq 1 ]] ; then
+ PREFER_ENV=1
+ PREFERENCE=("@")
+else
+ PREFER_ENV=0
+ PREFERENCE=()
+fi
+
+TEST=()
+for i in $MSVS_PREFERENCE ; do
+ if [[ $i = "@" ]] ; then
+ if [[ -n ${ENV_ARCH+x} ]] ; then
+ PREFERENCE+=("@")
+ PREFER_ENV=1
+ else
+ debug "Preference @ ignored since no environment compiler selected"
+ fi
+ else
+ if [[ -n ${COMPILERS[$i]+x} || -n ${COMPILERS[${i%.*}.*]+x} ]] ; then
+ if [[ -n ${CANDIDATES[$i]+x} ]] ; then
+ unset CANDIDATES[$i]
+ TEST+=($i)
+ PREFERENCE+=($i)
+ elif [[ ${i#*.} = "*" ]] ; then
+ INSTANCES=
+ for j in "${!CANDIDATES[@]}" ; do
+ if [[ "${j%.*}.*" = $i ]] ; then
+ unset CANDIDATES[$j]
+ INSTANCES="$INSTANCES $j"
+ fi
+ done
+ INSTANCES="$(sort -r <<< "${INSTANCES// /$'\n'}")"
+ eval TEST+=($INSTANCES)
+ eval PREFERENCE+=($INSTANCES)
+ fi
+ else
+ if [[ -n ${CANDIDATES["VS$i"]+x} ]] ; then
+ unset CANDIDATES["VS$i"]
+ TEST+=("VS$i")
+ PREFERENCE+=("VS$i")
+ fi
+ SDKS=
+ for j in "${!COMPILERS[@]}" ; do
+ eval COMPILER=${COMPILERS[$j]}
+ if [[ -n ${COMPILER["VC_VER"]+x} ]] ; then
+ if [[ $i = ${COMPILER["VC_VER"]} && -n ${CANDIDATES[$j]+x} ]] ; then
+ unset CANDIDATES[$j]
+ SDKS="$j $SDKS"
+ fi
+ fi
+ done
+ SDKS=${SDKS% }
+ SDKS="$(sort -r <<< "${SDKS// /$'\n'}")"
+ SDKS=${SDKS//$'\n'/ }
+ eval TEST+=($SDKS)
+ eval PREFERENCE+=($SDKS)
+ fi
+ fi
+done
+
+# If MSVS_PREFERENCE includes @, add any remaining items from CANDIDATES to TEST, otherwise remove
+# them from FOUND so that they don't accidentally get reported on later.
+for i in "${!CANDIDATES[@]}" ; do
+ if [[ $PREFER_ENV -eq 1 ]] ; then
+ TEST+=($i)
+ else
+ unset FOUND[$i]
+ fi
+done
+
+# Initialise pref and PREF to ${PREFERENCE[0]}
+pref=0
+PREF=${PREFERENCE[0]}
+
+if [[ $DEBUG -gt 1 ]] ; then
+ for i in "${!TEST[@]}" ; do
+ echo "Test ${TEST[$i]}">&2
+ done
+fi
+
+
+# Now run each compiler's environment script and then test whether it is suitable. During this loop,
+# attempt to identify the environment C compiler (if one was found). The environment C compiler is
+# strongly identified if the full location of cl matches the one in PATH and both LIB and INCLUDE
+# contain the strings returned by the script in an otherwise empty environment (if one or both of
+# the LIB and INCLUDE variables do not contain the string returned, then the compiler is weakly
+# identified). If the environment compiler is strongly identified by more than one package, then it
+# is not identified at all; if it is strongly identified by no packages but weakly identified by
+# exactly 1, then we grudgingly accept that that's probably the one.
+ENV_COMPILER=
+WEAK_ENV=
+
+# ARCHINFO contains the appropriate ARCH_SWITCHES associative array for each compiler.
+declare -A ARCHINFO
+
+for i in "${TEST[@]}" ; do
+ CURRENT=${FOUND[$i]}
+ eval COMPILER=$CURRENT
+ # At the end of this process, the keys of FOUND will be augmented with the architecture found in
+ # each case (so if "VS14.0" was in FOUND from the scan and both the x86 and x64 compilers are
+ # valid, then at the end of this loop FOUND will contain "VS14.0-x86" and "VS14.0-x64").
+ unset FOUND[$i]
+
+ if [[ ${COMPILER["IS_EXPRESS"]}0 -gt 0 && -n ${COMPILER["EXPRESS_ARCH_SWITCHES"]+x} ]] ; then
+ eval ARCHINFO=${COMPILER["EXPRESS_ARCH_SWITCHES"]}
+ elif [[ -n ${COMPILER["ARCH_SWITCHES"]+x} ]] ; then
+ eval ARCHINFO=${COMPILER["ARCH_SWITCHES"]}
+ else
+ ARCHINFO=()
+ fi
+
+ # Determine the script to be executed and any non-architecture specific switches needed.
+ # $ENV is will contain the value of the environment variable for the compiler (empty for an SDK)
+ # which is required for Visual Studio 7.x shim later.
+ if [[ -n ${COMPILER["ENV"]+x} ]] ; then
+ ENV=VS${COMPILER["ENV"]}COMNTOOLS
+ ENV=${!ENV%\"}
+ ENV=${ENV#\"}
+ if [[ ${COMPILER["ENV"]}0 -ge 800 ]] ; then
+ SCRIPT="$(cygpath -d -f - <<< $ENV)\\..\\..\\VC\\vcvarsall.bat"
+ SCRIPT_SWITCHES=
+ else
+ SCRIPT="$(cygpath -d -f - <<< $ENV)\\vsvars32.bat"
+ SCRIPT_SWITCHES=
+ fi
+ else
+ ENV=
+ SCRIPT=${COMPILER["SETENV"]}
+ SCRIPT_SWITCHES=${COMPILER["SETENV_RELEASE"]}
+ fi
+ # For reasons of escaping, the script is executed using its basename so the directory needs
+ # prepending to PATH.
+ DIR=$(dirname "$SCRIPT" | cygpath -u -f -)
+
+ if [[ ${COMPILER["IS_EXPRESS"]} -gt 0 && -n ${COMPILER["EXPRESS_ARCH"]+x} ]] ; then
+ ARCHS=${COMPILER["EXPRESS_ARCH"]}
+ else
+ ARCHS=${COMPILER["ARCH"]}
+ fi
+
+ for arch in $ARCHS ; do
+ # Determine the command line switch for this architecture
+ if [[ -n ${ARCHINFO[$arch]+x} ]] ; then
+ ARCH_SWITCHES=${ARCHINFO[$arch]}
+ else
+ ARCH_SWITCHES=$arch
+ fi
+
+ # Run the script in order to determine changes made to PATH, INCLUDE and LIB. These scripts
+ # always prepend changes to the environment variables.
+ MSVS_PATH=
+ MSVS_LIB=
+ MSVS_INC=
+
+ COMMAND='%EXEC_SCRIPT% && echo XMARKER && echo !PATH! && echo !LIB! && echo !INCLUDE!'
+
+ # Note that EXEC_SCRIPT must have ARCH_SWITCHES first for older Platform SDKs (newer ones parse
+ # arguments properly)
+ if [[ $DEBUG -gt 3 ]] ; then
+ printf "Scanning %s... " "$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES">&2
+ fi
+ num=0
+ while IFS= read -r line; do
+ case $num in
+ 0)
+ MSVS_PATH=${line%% };;
+ 1)
+ MSVS_LIB=${line%% };;
+ 2)
+ MSVS_INC=${line%% };;
+ esac
+ ((num++))
+ done < <(INCLUDE='' LIB='' PATH="?msvs-detect?:$DIR:$PATH" ORIGINALPATH='' \
+ EXEC_SCRIPT="$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES" \
+ $(cygpath "$COMSPEC") ${SWITCH_PREFIX}v:on ${SWITCH_PREFIX}c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3)
+ if [[ $DEBUG -gt 3 ]] ; then
+ echo done>&2
+ fi
+
+ if [[ -n $MSVS_PATH ]] ; then
+ # Translate MSVS_PATH back to Cygwin notation (/cygdrive, etc. and colon-separated)
+ MSVS_PATH=$(cygpath "$MSVS_PATH" -p)
+ # Remove any trailing / from elements of MSVS_PATH
+ MSVS_PATH=$(echo "$MSVS_PATH" | sed -e 's|\([^:]\)/\+\(:\|$\)|\1\2|g;s/?msvs-detect?.*//')
+ # Guarantee that MSVS_PATH ends with a single :
+ MSVS_PATH="${MSVS_PATH%%:}:"
+ fi
+ # Ensure that both variables end with a semi-colon (it doesn't matter if for some erroneous
+ # reason they have come back blank, because check_environment will shortly fail)
+ MSVS_LIB="${MSVS_LIB%%;};"
+ MSVS_INC="${MSVS_INC%%;};"
+
+ # Visual Studio .NET 2002 and 2003 do not include mt in PATH, for not entirely clear reasons.
+ # This shim detects that scenario and adds the winnt folder to MSVS_PATH.
+ RET=0
+ if [[ ${i/.*/} = "VS7" ]] ; then
+ find_in "${MSVS_PATH//:/*}" mt.exe
+ if [[ $RET -eq 1 ]] ; then
+ MSVS_PATH="$MSVS_PATH$(cygpath -u -f - <<< $ENV\\Bin\\winnt):"
+ RET=0
+ fi
+ fi
+
+ # Ensure that these derived values give a valid compiler.
+ if check_environment "${MSVS_PATH//:/*}" "${MSVS_INC//;/*}" "${MSVS_LIB//;/*}" "$i" $arch ; then
+ # Put the package back into FOUND, but augmented with the architecture name and with the
+ # derived values.
+ FOUND["$i-$arch"]="${CURRENT%)} [\"MSVS_PATH\"]=\"$MSVS_PATH\" \
+ [\"MSVS_INC\"]=\"$MSVS_INC\" \
+ [\"MSVS_LIB\"]=\"$MSVS_LIB\" \
+ [\"ASSEMBLER\"]=\"$ASSEMBLER\")" #"# fixes vim syn match error
+
+ # Check to see if this is a match for the environment C compiler.
+ if [[ -n ${ENV_ARCH+x} ]] ; then
+ TEST_cl=$(PATH="$MSVS_PATH:$PATH" "$WHICH" cl)
+ TEST_cl=${TEST_cl,,}
+ TEST_cl=${TEST_cl/bin\/*_/bin\/}
+ if [[ $TEST_cl = $ENV_cl ]] ; then
+ if [[ ${!ENV_INC/"$MSVS_INC"/} != "${!ENV_INC}" && \
+ ${!ENV_LIB/"$MSVS_LIB"/} != "${!ENV_LIB}" ]] ; then
+ debug "$i-$arch is a strong candidate for the Environment C compiler"
+ if [[ -n ${ENV_COMPILER+x} ]] ; then
+ if [[ -z ${ENV_COMPILER} ]] ; then
+ ENV_COMPILER=$i-$arch
+ unset WEAK_ENV
+ else
+ # More than one strong candidate - no fall back available
+ unset ENV_COMPILER
+ unset WEAK_ENV
+ fi
+ fi
+ else
+ debug "$i-$arch is a weak candidate for the Environment C compiler"
+ if [[ -n ${WEAK_ENV+x} ]] ; then
+ if [[ -z ${WEAK_ENV} ]] ; then
+ WEAK_ENV=$i-$arch
+ else
+ # More than one weak candidate - no fall back available
+ unset WEAK_ENV
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ done
+
+ # Does this package match the current preference? Note that PREFERENCE and TEST are constructed in
+ # a cunning (and hopefully not too "You are not expected to understand this" way) such that $PREF
+ # will always equal $i, unless $PREF = "@".
+ if [[ $PREF = $i ]] ; then
+ # In which case, check that the architecture(s)s were found
+ if [[ -n ${FOUND["$i-$LEFT_ARCH"]+x} && -n ${FOUND["$i-$RIGHT_ARCH"]+x} ]] ; then
+ debug "Solved TARGET_ARCH=$TARGET_ARCH with $i"
+ SOLUTION=$i
+ break
+ fi
+ fi
+
+ if [[ $PREF != "@" ]] ; then
+ ((pref++))
+ PREF=${PREFERENCE[$pref]}
+ fi
+done
+
+# If we got this far, then either we failed to find a compiler at all, or we were looking for the
+# environment compiler (or --all was specified).
+
+# Adopt a weak match for the environment compiler, if that's the best we can do.
+if [[ -n ${ENV_COMPILER+x} && -z ${ENV_COMPILER} && -n ${WEAK_ENV} ]] ; then
+ warning "Assuming Environment C compiler is $WEAK_ENV"
+ ENV_COMPILER=$WEAK_ENV
+fi
+
+declare -A FLIP
+FLIP=(["x86"]="x64" ["x64"]="x86")
+
+if [[ $MODE -eq 0 ]] ; then
+ if [[ $PREF = "@" && -n ${ENV_COMPILER} ]] ; then
+ SOLUTION=${ENV_COMPILER%-$ENV_ARCH}
+ # If --arch wasn't specified, then ensure that the other architecture was also found. If --arch
+ # was specified, then validate that the compiler was valid. This should always happen, unless
+ # something went wrong running the script to get MSVS_PATH, MSVS_LIB and MSVS_INC.
+ if [[ -n ${FOUND["$SOLUTION-${FLIP[$ENV_ARCH]}"]+x} ||
+ -n ${FOUND["$SOLUTION-$TARGET_ARCH"]+x} ]] ; then
+ debug "Solved with $SOLUTION"
+ else
+ unset SOLUTION
+ unset ENV_ARCH
+ fi
+ fi
+
+ if [[ -z ${SOLUTION+x} ]] ; then
+ ((pref++))
+ debug "Search remaining: ${PREFERENCE[*]}"
+ TEST_ARCH=$TARGET_ARCH
+ for i in "${PREFERENCE[@]:$pref}" ; do
+ if [[ -n ${FOUND["$i-$LEFT_ARCH"]+x} && -n ${FOUND["$i-$RIGHT_ARCH"]+x} ]] ; then
+ debug "Solved TARGET_ARCH='$TARGET_ARCH' with $i"
+ SOLUTION=$i
+ break
+ fi
+ done
+ fi
+fi
+
+debug "Solution: $SOLUTION"
+
+if [[ -n ${ENV_COMPILER} && $MODE -eq 1 ]] ; then
+ echo "Identified Environment C compiler as $ENV_COMPILER"
+fi
+
+if [[ $MODE -eq 1 ]] ; then
+ echo "Installed and usable packages:"
+ for i in "${!FOUND[@]}" ; do
+ echo " $i"
+ done | sort
+ exit 0
+fi
+
+if [[ -n $SOLUTION ]] ; then
+ eval COMPILER=${FOUND[$SOLUTION-$LEFT_ARCH]}
+ output MSVS_NAME "${COMPILER["DISPLAY"]}" $LEFT_ARCH
+ output MSVS_PATH "${COMPILER["MSVS_PATH"]}" $LEFT_ARCH
+ output MSVS_INC "${COMPILER["MSVS_INC"]}" $LEFT_ARCH
+ output MSVS_LIB "${COMPILER["MSVS_LIB"]}" $LEFT_ARCH
+ if [[ $ML_REQUIRED -eq 1 ]] ; then
+ output MSVS_ML "${COMPILER["ASSEMBLER"]%.exe}" always
+ fi
+ if [[ -z $TARGET_ARCH ]] ; then
+ eval COMPILER=${FOUND[$SOLUTION-$RIGHT_ARCH]}
+ output MSVS64_PATH "${COMPILER["MSVS_PATH"]}" $RIGHT_ARCH
+ output MSVS64_INC "${COMPILER["MSVS_INC"]}" $RIGHT_ARCH
+ output MSVS64_LIB "${COMPILER["MSVS_LIB"]}" $RIGHT_ARCH
+ if [[ $ML_REQUIRED -eq 1 ]] ; then
+ output MSVS64_ML "${COMPILER["ASSEMBLER"]%.exe}" always
+ fi
+ fi
+ exit 0
+else
+ exit 1
+fi
diff --git a/.ci/or1k-sim.exp b/.ci/or1k-sim.exp
new file mode 100644
index 0000000..3920413
--- /dev/null
+++ b/.ci/or1k-sim.exp
@@ -0,0 +1,58 @@
+# Copyright (C) 2010, 2019 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu 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 2 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA.
+
+# This is a list of toolchains that are supported on this board.
+set_board_info target_install {or1k-elf}
+
+# Load the generic configuration for this board. This will define a basic set
+# of routines needed by the tool to communicate with the board.
+load_generic_config "sim"
+
+# basic-sim.exp is a basic description for the standard Cygnus simulator.
+load_base_board_description "basic-sim"
+
+# "or1k" is the name of the sim subdir in devo/sim.
+setup_sim or1k
+
+# No multilib options needed by default.
+process_multilib_options ""
+
+# We only support newlib on this target. We assume that all multilib
+# options have been specified before we get here.
+
+set_board_info compiler "[find_gcc]"
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
+
+# Configuration settings for testsuites
+set_board_info noargs 1
+set_board_info gdb,nosignals 1
+set_board_info gdb,noresults 1
+set_board_info gdb,cannot_call_functions 1
+set_board_info gdb,skip_float_tests 1
+set_board_info gdb,can_reverse 1
+set_board_info gdb,use_precord 1
+
+# More time is needed
+set_board_info gcc,timeout 800
+set_board_info gdb,timeout 60
+
+# Used by a few gcc.c-torture testcases to delimit how large the stack can
+# be.
+set_board_info gcc,stack_size 5000
+
diff --git a/.ci/powerpc-eabisim.exp b/.ci/powerpc-eabisim.exp
new file mode 100644
index 0000000..285fd4f
--- /dev/null
+++ b/.ci/powerpc-eabisim.exp
@@ -0,0 +1,58 @@
+# Copyright (C) 2010, 2019 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu 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 2 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA.
+
+# This is a list of toolchains that are supported on this board.
+set_board_info target_install {powerpc-eabisim}
+
+# Load the generic configuration for this board. This will define a basic set
+# of routines needed by the tool to communicate with the board.
+load_generic_config "sim"
+
+# basic-sim.exp is a basic description for the standard Cygnus simulator.
+load_base_board_description "basic-sim"
+
+# "powerpc" is the name of the sim subdir in devo/sim.
+setup_sim powerpc
+
+# No multilib options needed by default.
+process_multilib_options ""
+
+# We only support newlib on this target. We assume that all multilib
+# options have been specified before we get here.
+
+set_board_info compiler "[find_gcc]"
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
+
+# Configuration settings for testsuites
+set_board_info noargs 1
+set_board_info gdb,nosignals 1
+set_board_info gdb,noresults 1
+set_board_info gdb,cannot_call_functions 1
+set_board_info gdb,skip_float_tests 1
+set_board_info gdb,can_reverse 1
+set_board_info gdb,use_precord 1
+
+# More time is needed
+set_board_info gcc,timeout 800
+set_board_info gdb,timeout 60
+
+# Used by a few gcc.c-torture testcases to delimit how large the stack can
+# be.
+set_board_info gcc,stack_size 5000
+
diff --git a/.ci/site.exp b/.ci/site.exp
new file mode 100644
index 0000000..96c013e
--- /dev/null
+++ b/.ci/site.exp
@@ -0,0 +1,29 @@
+# Copyright (C) 2008, 2010, 2018, 2019, 2021 Anthony Green
+
+# Make sure we look in the right place for the board description files.
+if ![info exists boards_dir] {
+ set boards_dir {}
+}
+
+lappend boards_dir $::env(BOARDSDIR)
+
+verbose "Global Config File: target_triplet is $target_triplet" 2
+global target_list
+
+case "$target_triplet" in {
+ { "bfin-elf" } {
+ set target_list "bfin-sim"
+ }
+ { "m32r-elf" } {
+ set target_list "m32r-sim"
+ }
+ { "moxie-elf" } {
+ set target_list "moxie-sim"
+ }
+ { "or1k-elf" } {
+ set target_list "or1k-sim"
+ }
+ { "powerpc-eabisim" } {
+ set target_list "powerpc-eabisim"
+ }
+}
diff --git a/.ci/wine-sim.exp b/.ci/wine-sim.exp
new file mode 100644
index 0000000..1ad6038
--- /dev/null
+++ b/.ci/wine-sim.exp
@@ -0,0 +1,55 @@
+# Copyright (C) 2010, 2019 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu 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 2 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu 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 DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA.
+
+# This is a list of toolchains that are supported on this board.
+set_board_info target_install {i686-w64-mingw32}
+
+# Load the generic configuration for this board. This will define a basic set
+# of routines needed by the tool to communicate with the board.
+load_generic_config "sim"
+
+set_board_info sim "wineconsole --backend=curses"
+set_board_info is_simulator 1
+
+# No multilib options needed by default.
+process_multilib_options ""
+
+# We only support newlib on this target. We assume that all multilib
+# options have been specified before we get here.
+
+set_board_info compiler "[find_gcc]"
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]"
+
+# Configuration settings for testsuites
+set_board_info noargs 1
+set_board_info gdb,nosignals 1
+set_board_info gdb,noresults 1
+set_board_info gdb,cannot_call_functions 1
+set_board_info gdb,skip_float_tests 1
+set_board_info gdb,can_reverse 1
+set_board_info gdb,use_precord 1
+
+# More time is needed
+set_board_info gcc,timeout 800
+set_board_info gdb,timeout 60
+
+# Used by a few gcc.c-torture testcases to delimit how large the stack can
+# be.
+set_board_info gcc,stack_size 5000
+