Skip to content

Wrong arch for ffi and nokogiri native extensions on macOS 12 ARM #846

@joshcooper

Description

@joshcooper

Describe the Bug

The nokogiri and ffi gems are shipped in the runtime. When cross-compiling on macOS 12 Intel for ARM, the resulting native extensions have the wrong arch x86_64. They should be arm64. Since ffi is unusable, the facter mountpoints fact is empty.

Expected Behavior

All binaries (including .dylib and .bundle) should be compiled for arm64 and facter mountpoints should be populated.

Steps to Reproduce

# curl -sLO https://downloads.puppet.com/mac/puppet8/12/arm64/puppet-agent-8.6.0-1.osx12.dmg
# hdiutil attach -quiet puppet-agent-8.6.0-1.osx12.dmg 
# installer -pkg /Volumes/puppet-agent-8.6.0-1.osx12/puppet-agent-8.6.0-1-installer.pkg -target /
installer: Package name is puppet-agent
installer: Installing at base path /
installer: The install was successful.
# /opt/puppetlabs/puppet/bin/facter os
{
  architecture => "arm64",
  family => "Darwin",
  hardware => "arm64",
  macosx => {
    build => "21F79",
    product => "macOS",
    version => {
      full => "12.4",
      major => "12",
      minor => "4",
      patch => "0"
    }
  },
  name => "Darwin",
  release => {
    full => "21.5.0",
    major => "21",
    minor => "5"
  }
}
# /opt/puppetlabs/puppet/bin/facter mountpoints -d
[2024-05-07 21:44:13.086863 ] INFO Facter - executed with command line: mountpoints -d 
[2024-05-07 21:44:13.086942 ] DEBUG Facter - Facter version: 4.7.0 
[2024-05-07 21:44:13.091116 ] DEBUG Facter::FactManager - Resolving facts sequentially 
[2024-05-07 21:44:13.091216 ] DEBUG Facter::FactLoader - Loading all internal facts 
[2024-05-07 21:44:13.091665 ] DEBUG Facter::FactLoader - Loading custom facts 
[2024-05-07 21:44:13.092705 ] DEBUG Facter::FactLoader - Loading external facts 
[2024-05-07 21:44:13.094064 ] DEBUG Facter::QueryParser - List of resolvable facts: [#<Facter::SearchedFact:0x000000010535d850 @name="mountpoints", @fact_class=Facts::Macosx::Mountpoints, @user_query="mountpoints", @type=:core, @file=nil>] 
[2024-05-07 21:44:13.102325 ] DEBUG Facter::Resolvers::Macosx::Mountpoints - Could not read mounts: dlopen(/opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) - /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/ffi-1.15.5/lib/ffi_c.bundle 
[2024-05-07 21:44:13.102413 ] DEBUG Facter::FactManager - fact "mountpoints" has resolved to: {} 

The following have the wrong arch:

# find /opt/puppetlabs/puppet/lib -type f -name *.bundle -exec file {} \; | grep -v arm64
/opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/nokogiri-1.14.2/lib/nokogiri/nokogiri.bundle: Mach-O 64-bit bundle x86_64
/opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/ffi-1.15.5/lib/ffi_c.bundle: Mach-O 64-bit bundle x86_64

Environment

  • Version: puppet-agent 8.6.0 only
  • Platform: macOS 12 ARM only

macOS Intel and 13 and 14 ARM are unaffected, because we don't cross compile.

puppet-agent 8.5.0 and 7.30.0 don't have this issue:

# curl -sLO https://downloads.puppet.com/mac/puppet8/12/arm64/puppet-agent-8.5.0-1.osx12.dmg
# hdiutil attach -quiet puppet-agent-8.5.0-1.osx12.dmg 
# find /opt/puppetlabs/puppet/lib -type f -name *.bundle -exec file {} \; | grep -v arm64
# /opt/puppetlabs/puppet/bin/facter mountpoints
{
  / => {
    available => "63.31 GiB",
    available_bytes => 67981316096,
    capacity => "25.08%",

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriagedJira issue has been created for this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions