Message ID | 20200810130618.16066-7-r.bolshakov@yadro.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add support for generic ELF cross-compiler | expand |
On 10/08/2020 15.06, Roman Bolshakov wrote: > macOS is shipped with an old non-enhanced version of getopt and it > doesn't support options used by run_tests.sh. Proper version of getopt > is available from homebrew but it has to be added to PATH before invoking > run_tests.sh. It's not convenient because it has to be done in each > shell instance and there could be many if a multiplexor is used. > > The change provides a way to override getopt and halts ./configure if > enhanced getopt can't be found. > > Cc: Cameron Esfahani <dirty@apple.com> > Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> > --- > configure | 13 +++++++++++++ > run_tests.sh | 2 +- > 2 files changed, 14 insertions(+), 1 deletion(-) Is this still required with a newer version of bash? The one that ships with macOS is just too old... I assume that getopt is a builtin function in newer versions of the bash? Last time we discussed, we agreed that Bash v4.2 would be a reasonable minimum for the kvm-unit-tests: https://www.spinics.net/lists/kvm/msg222139.html Thus if the user installed bash from homebrew on macos, we should be fine? Could you maybe replace this patch with a check for a minimum version of bash instead? Thomas
On Fri, Aug 28, 2020 at 07:55:53AM +0200, Thomas Huth wrote: > On 10/08/2020 15.06, Roman Bolshakov wrote: > > macOS is shipped with an old non-enhanced version of getopt and it > > doesn't support options used by run_tests.sh. Proper version of getopt > > is available from homebrew but it has to be added to PATH before invoking > > run_tests.sh. It's not convenient because it has to be done in each > > shell instance and there could be many if a multiplexor is used. > > > > The change provides a way to override getopt and halts ./configure if > > enhanced getopt can't be found. > > > > Cc: Cameron Esfahani <dirty@apple.com> > > Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> > > --- > > configure | 13 +++++++++++++ > > run_tests.sh | 2 +- > > 2 files changed, 14 insertions(+), 1 deletion(-) > > Is this still required with a newer version of bash? The one that ships > with macOS is just too old... > > I assume that getopt is a builtin function in newer versions of the bash? > Except it has `s` at the end. There's a getopts built-in in bash. I'll try to replace external getopt with getopts. > Last time we discussed, we agreed that Bash v4.2 would be a reasonable > minimum for the kvm-unit-tests: > > https://www.spinics.net/lists/kvm/msg222139.html > > Thus if the user installed bash from homebrew on macos, we should be fine? > > Could you maybe replace this patch with a check for a minimum version of > bash instead? > No problem, if getopts works. Thanks, Roman
On 28/08/2020 09.12, Roman Bolshakov wrote: > On Fri, Aug 28, 2020 at 07:55:53AM +0200, Thomas Huth wrote: >> On 10/08/2020 15.06, Roman Bolshakov wrote: >>> macOS is shipped with an old non-enhanced version of getopt and it >>> doesn't support options used by run_tests.sh. Proper version of getopt >>> is available from homebrew but it has to be added to PATH before invoking >>> run_tests.sh. It's not convenient because it has to be done in each >>> shell instance and there could be many if a multiplexor is used. >>> >>> The change provides a way to override getopt and halts ./configure if >>> enhanced getopt can't be found. >>> >>> Cc: Cameron Esfahani <dirty@apple.com> >>> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> >>> --- >>> configure | 13 +++++++++++++ >>> run_tests.sh | 2 +- >>> 2 files changed, 14 insertions(+), 1 deletion(-) >> >> Is this still required with a newer version of bash? The one that ships >> with macOS is just too old... >> >> I assume that getopt is a builtin function in newer versions of the bash? >> > > Except it has `s` at the end. There's a getopts built-in in bash. > I'll try to replace external getopt with getopts. Ouch, ok, I wasn't aware of the difference between getopt and getopts. I guess your patch here is ok in that case. Or maybe we should simply revert d4d34e6484825ee5734b042c215c06 ("run_tests: fix command line options handling") and state in the docs that options have to be given before the tests on the command line... Thomas
diff --git a/configure b/configure index f9d030f..556ff13 100755 --- a/configure +++ b/configure @@ -8,6 +8,7 @@ objcopy=objcopy objdump=objdump ar=ar addr2line=addr2line +getopt=getopt arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` host=$arch cross_prefix= @@ -31,6 +32,7 @@ usage() { --cross-prefix=PREFIX cross compiler prefix --cc=CC c compiler to use ($cc) --ld=LD ld linker to use ($ld) + --getopt=GETOPT enhanced getopt to use ($getopt) --prefix=PREFIX where to install things ($prefix) --endian=ENDIAN endianness to compile for (little or big, ppc64 only) --[enable|disable]-pretty-print-stacks @@ -76,6 +78,9 @@ while [[ "$1" = -* ]]; do --ld) ld="$arg" ;; + --getopt) + getopt="$arg" + ;; --enable-pretty-print-stacks) pretty_print_stacks=yes ;; @@ -156,6 +161,13 @@ EOF u32_long=$("$cross_prefix$cc" -E lib-test.c | grep -v '^#' | grep -q long && echo yes) rm -f lib-test.c +# require enhanced getopt +$getopt -T > /dev/null +if [ $? -ne 4 ]; then + echo "Enchanced getopt is not available" + exit 1 +fi + # Are we in a separate build tree? If so, link the Makefile # and shared stuff so that 'make' and run_tests.sh work. if test ! -e Makefile; then @@ -198,6 +210,7 @@ OBJCOPY=$cross_prefix$objcopy OBJDUMP=$cross_prefix$objdump AR=$cross_prefix$ar ADDR2LINE=$cross_prefix$addr2line +GETOPT=$getopt TEST_DIR=$testdir FIRMWARE=$firmware ENDIAN=$endian diff --git a/run_tests.sh b/run_tests.sh index 01e36dc..c4f436b 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -35,7 +35,7 @@ RUNTIME_arch_run="./$TEST_DIR/run" source scripts/runtime.bash only_tests="" -args=`getopt -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*` +args=`$GETOPT -u -o ag:htj:v -l all,group:,help,tap13,parallel:,verbose -- $*` [ $? -ne 0 ] && exit 2; set -- $args; while [ $# -gt 0 ]; do
macOS is shipped with an old non-enhanced version of getopt and it doesn't support options used by run_tests.sh. Proper version of getopt is available from homebrew but it has to be added to PATH before invoking run_tests.sh. It's not convenient because it has to be done in each shell instance and there could be many if a multiplexor is used. The change provides a way to override getopt and halts ./configure if enhanced getopt can't be found. Cc: Cameron Esfahani <dirty@apple.com> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> --- configure | 13 +++++++++++++ run_tests.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-)