From 351f7f82f38037f0fd94d7ebb0ae075c41f2d358 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Thu, 20 Mar 2025 14:20:31 +0800 Subject: [PATCH] shims/super/cc: tweak optimisation flag handling for runtime CPU detection builds Let's reinstate adding our own optimisation flags if the compiler was not invoked with a conflicting optimisation flag. --- Library/Homebrew/shims/super/cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc index 7c1182857b..74c3384406 100755 --- a/Library/Homebrew/shims/super/cc +++ b/Library/Homebrew/shims/super/cc @@ -308,7 +308,10 @@ class Cmd args << "-w" unless configure? args << "-#{ENV["HOMEBREW_OPTIMIZATION_LEVEL"]}" - args.concat(optflags) unless runtime_cpu_detection? + optflags.each do |optflag| + flag = optflag.split("=").first + args << optflag if !runtime_cpu_detection? || @args.none? { |arg| arg.start_with?(flag) } + end args.concat(archflags) args << "-std=#{@arg0}" if /c[89]9/.match?(@arg0) args << "-g" if debug_symbols?