From 6a0154643c08009451c8de4bdce5b9907e1700fb Mon Sep 17 00:00:00 2001 From: Marcel Bochtler Date: Sat, 9 Jul 2022 18:21:19 +0200 Subject: [PATCH] Only relaunch scancode when not in emulation mode #2835 Running `uname -m` on Apple silicon machines always results in `arm64`, regardless if Bash is running in Rosetta 2 emulation or natively. Check if scancode and configure is running in emulation mode (see [1]), before relaunching it, to avoid an infinite loop. [1]: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment Signed-off-by: Marcel Bochtler --- configure | 2 +- scancode | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index fb24a432ab5..4535740352f 100755 --- a/configure +++ b/configure @@ -119,7 +119,7 @@ CFG_ROOT_DIR="$( cd "$( dirname "${CFG_BIN}" )" && pwd )" CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin # force relaunching under X86-64 architecture on macOS M1/ARM -if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' ]]; then +if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' && $(sysctl -in sysctl.proc_translated) == 0 ]]; then arch -x86_64 /bin/bash -c "$CFG_ROOT_DIR/configure $@" exit $? fi diff --git a/scancode b/scancode index 3547d0fadd0..9053027a0bb 100755 --- a/scancode +++ b/scancode @@ -121,7 +121,7 @@ SCANCODE_BIN="$( realpath "${BASH_SOURCE[0]}" )" SCANCODE_ROOT_DIR="$( cd "$( dirname "${SCANCODE_BIN}" )" && pwd )" # force relaunching under X86-64 architecture on macOS M1/ARM -if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' ]]; then +if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' && $(sysctl -in sysctl.proc_translated) == 0 ]]; then arch -x86_64 /bin/bash -c "$SCANCODE_ROOT_DIR/$COMMAND_TO_RUN $@" exit $? fi