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

Apple M1 Clang targeting x86 #6915

Open
thoward27 opened this issue Dec 18, 2023 · 0 comments
Open

Apple M1 Clang targeting x86 #6915

thoward27 opened this issue Dec 18, 2023 · 0 comments

Comments

@thoward27
Copy link

thoward27 commented Dec 18, 2023

Describe the problem

I originally thought this issue had something to do with poetry, you can view all of my previous discussions from this thread: pypa/build#710

When running inspec tests, clang targets x86 on my M1 mac. This is breaking building python wheels during inspec tests.

Here's the output of clang --version running natively on my system:

/bin/zsh --login -c 'clang --version'
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

But, with an inspec test written as

describe bash ("/bin/zsh --login -c 'clang --version'") do
    its('stdout') { should match /clang version 6.0.0/ }
end

I get this output

  Bash command /bin/zsh --login -c 'clang --version'
     ×  stdout is expected to match /arm64-apple-darwin21.5.0/
     expected "Apple clang version 13.1.6 (clang-1316.0.21.2.5)\nTarget: x86_64-apple-darwin21.5.0\nThread model: posix\nInstalledDir: /Library/Developer/CommandLineTools/usr/bin\n" to match /arm64-apple-darwin21.5.0/
     Diff:
     @@ -1,4 +1,7 @@
     -/arm64-apple-darwin21.5.0/
     +Apple clang version 13.1.6 (clang-1316.0.21.2.5)
     +Target: x86_64-apple-darwin21.5.0
     +Thread model: posix
     +InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I am invoking the test with

inspec exec ./test --chef-license=accept --no-distinct-exit --input user_home=/Users/tom local_user=tom

Additionally, when testing the output of arch on my system, I see this natively

$ arch
arm64

But through inspec, I see

  Bash command /bin/zsh --login -c 'arch'
     ×  stdout is expected to match /arm64/
     expected "i386" to match /arm64/
     Diff:
     @@ -1 +1 @@
     -/arm64/
     +"i386"

I find it very interesting that inspec is running as i386, I would have expected x86 in this output.

Finally, if I try to run inspec with a specific arch via arch -arch arm64e, I get the following failure

$ arch -arch arm64e inspec exec ./test --chef-license=accept --no-distinct-exit --input user_home=/Users/tom local_user=tom
arch: posix_spawnp: inspec: Bad CPU type in executable

Possible Solution

I can get clang to output the correct target if I change the arch within the test itself, via

describe bash ("/bin/zsh --login -c 'arch -arch arm64e clang --version'") do
    its('stdout') { should match /arm64-apple-darwin21.5.0/ }
end

But I view this as less favorable than inspec running all tests in the correct architecture.

The impact of this is that when python attempts to build wheels for my system during inspec tests, the wheels are not importable on my machine. Since those wheels get put into a cache with systems like poetry, it can leave my system in a broken state until I destroy the cache and rebuild the wheel natively.

Can anyone help me make heads or tails of why this would be happening?

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

No branches or pull requests

1 participant