Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix relaunching scancode on Apple silicon using Rosetta 2 emulation #2835 #3018

Merged
merged 3 commits into from
Jul 11, 2022

Conversation

MarcelBochtler
Copy link
Contributor

@MarcelBochtler MarcelBochtler commented Jul 9, 2022

Related to #2835.

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁

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>
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.

Signed-off-by: Marcel Bochtler <git@bochtler.io>
@MarcelBochtler MarcelBochtler changed the title Fix relaunching scancode on Apple silicon using Rosetta 2 emulation Fix relaunching scancode on Apple silicon using Rosetta 2 emulation #2835 Jul 9, 2022
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcelBochtler Thank you ++ for testing and fixing this.... you are awesome!

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>
@pombredanne
Copy link
Member

@MarcelBochtler I carried over your patch to the extractcode script too... And I will merge shortly.
Thank you ++ again 🙇

@pombredanne
Copy link
Member

Thanks!
Merging

@pombredanne pombredanne merged commit 8689bc7 into aboutcode-org:develop Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants