From e893f16727d167390dacd9b2ed5eb6d5df103d70 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sun, 9 May 2021 10:44:05 +0100 Subject: [PATCH] extend/ENV/super: allow bottles with custom architectures Currently, Homebrew recognises only the architectures listed in `hardware.rb`. [1] Attempting to pass an unrecognised architecture to `--bottle-arch` while building a bottle returns an error. Let's change that by passing unrecognised bottle arches to the compiler instead of immediately failing with a `CannotInstallFormulaError`. Partially resolves #5815. [1] https://github.com/Homebrew/brew/blob/64b6846d6078525b8569834718f7b093a7dd05e1/Library/Homebrew/hardware.rb#L28-L42 --- Library/Homebrew/extend/ENV/super.rb | 3 +++ Library/Homebrew/formula_installer.rb | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 08d71f4185..439321ed93 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -261,6 +261,9 @@ module Superenv sig { returns(String) } def determine_optflags Hardware::CPU.optimization_flags.fetch(effective_arch) + rescue KeyError + odebug "Building a bottle for custom architecture (#{effective_arch})..." + Hardware::CPU.arch_flag(effective_arch) end sig { returns(String) } diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index a629bbd545..4186efe132 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -395,10 +395,6 @@ class FormulaInstaller return if only_deps? - if build_bottle? && (arch = @bottle_arch) && Hardware::CPU.optimization_flags.exclude?(arch.to_sym) - raise CannotInstallFormulaError, "Unrecognized architecture for --bottle-arch: #{arch}" - end - formula.deprecated_flags.each do |deprecated_option| old_flag = deprecated_option.old_flag new_flag = deprecated_option.current_flag