Forcing a specific architecture for (non-core) bottles

Hi,

I’m about to add this to HHVM’s tap:

 # 1. it looks like Apple have ended software support for everything older
 #    than sandybridge
 # 2. -march=sandybridge is a 10x speedup over -march=core2 (penryn)
 class << Hardware::CPU
   def optimization_flags
     OPTIMIZATION_FLAGS.merge({sandybridge: "-march=sandybridge"})
   end
 end
 def ARGV.bottle_arch
   :sandybridge
 end

Two questions:

  • is there a nicer way to do this?
  • is my understanding of Apple’s support correct?

Root cause is that we have some handwritten assembly that requires SSE 4.2 and CRC instructions with a C fallback.

I’ll be looking into moving this into run-time CPU identification, but that’s not always practical, and isn’t a safe change to make quickly.

Also, this is a regression in our packages; I’ve not been able to spend the time to do a full investigation, but it looks like maybe homebrew switched from -march=core2 -msse4 to just -march=core2; assuming the goal is to run on anything that supported MacOS releases runs on, that (Penryn) makes sense - but if the idea is to run on ‘supported’ hardware, then sandybridge seems like it might be a better goal for brew to use as a default, if I’m reading https://support.apple.com/en-us/HT201624 + the corresponding intel generations correctly

If you’re building your own bottles, the documentation suggests that passing the --build-bottle --bottle-arch=... options should do the trick.

Should we change Hardware.oldest_cpu to something newer? I’ve opened an issue to discuss this question: https://github.com/Homebrew/brew/issues/5425

  • afaict Hardware::CPU.optimization-flags still needs monkey-patching for --bottle-arch to work
  • given the software is basically unusuable without it, I’d much rather put something in the recipe

That said, for stuff to do on the CLI, HOMEBREW_OPTFLAGS can be used to force it

Hi there, sorry for replying to such an old thread (is that frowned upon here)? But I was doing the exact same thing and ran into this issue still. The latest I could get Homebrew to recognize was Nehalem with a non-modified brew. Is this being working upon, are there difficulties against doing it, or is it an okay thing for someone to start working on a pr for?