Skip to content

Commit 6a01546

Browse files
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 <git@bochtler.io>
1 parent a61fe17 commit 6a01546

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ CFG_ROOT_DIR="$( cd "$( dirname "${CFG_BIN}" )" && pwd )"
119119
CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin
120120

121121
# force relaunching under X86-64 architecture on macOS M1/ARM
122-
if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' ]]; then
122+
if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' && $(sysctl -in sysctl.proc_translated) == 0 ]]; then
123123
arch -x86_64 /bin/bash -c "$CFG_ROOT_DIR/configure $@"
124124
exit $?
125125
fi

scancode

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ SCANCODE_BIN="$( realpath "${BASH_SOURCE[0]}" )"
121121
SCANCODE_ROOT_DIR="$( cd "$( dirname "${SCANCODE_BIN}" )" && pwd )"
122122

123123
# force relaunching under X86-64 architecture on macOS M1/ARM
124-
if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' ]]; then
124+
if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' && $(sysctl -in sysctl.proc_translated) == 0 ]]; then
125125
arch -x86_64 /bin/bash -c "$SCANCODE_ROOT_DIR/$COMMAND_TO_RUN $@"
126126
exit $?
127127
fi

0 commit comments

Comments
 (0)