Skip to content

Commit

Permalink
Only relaunch scancode when not in emulation mode aboutcode-org#2835
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MarcelBochtler committed Jul 9, 2022
1 parent a61fe17 commit 6a01546
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scancode
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a01546

Please sign in to comment.