Skip to content

Commit f6064ea

Browse files
authored
Support extractcode on Apple ARM chip nexB#2835
This commit carries over a patch applied to the scancode and configure scripts to ensure that extractcode can work correctly in X86 emulated mode on Apple ARM silicon, * Only relaunch extractcode when not in emulation mode Running `uname -m` on Apple silicon machines always results in `arm64`, regardless if Bash is running in Rosetta 2 emulation or natively. Check if extractcode is running in emulation mode (see [1]), before relaunching it, to avoid an infinite loop. *Pass all parameters to the relaunched shell Calling `bash -c` with `$@` results in only the first parameter being passed to the subshell. Use `$*` to ensure all parameters are correctly passed to the Rosetta 2 emulated subshell. [1]: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment Reported-by: Marcel Bochtler <git@bochtler.io> Authored-by: Marcel Bochtler <git@bochtler.io> Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 58b8a89 commit f6064ea

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

extractcode

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ 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
125-
arch -x86_64 /bin/bash -c "$SCANCODE_ROOT_DIR/$COMMAND_TO_RUN $@"
124+
if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' && $(sysctl -in sysctl.proc_translated) == 0 ]]; then
125+
arch -x86_64 /bin/bash -c "$SCANCODE_ROOT_DIR/$COMMAND_TO_RUN $*"
126126
exit $?
127127
fi
128128

0 commit comments

Comments
 (0)