diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 17334a3a24..e2ce2e6262 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -91,10 +91,11 @@ module Superenv # g - Enable "-stdlib=libc++" for clang. # h - Enable "-stdlib=libstdc++" for clang. # K - Don't strip -arch , -m32, or -m64 + # d - Don't strip -march=. Use only in formulae that + # have runtime detection of CPU features. # w - Pass -no_weak_imports to the linker # # These flags will also be present: - # s - apply fix for sed's Unicode support # a - apply fix for apr-1-config path end alias generic_setup_build_environment setup_build_environment @@ -314,6 +315,11 @@ module Superenv append_to_cccfg "K" end + sig { void } + def runtime_cpu_detection + append_to_cccfg "d" + end + sig { void } def cxx11 append_to_cccfg "x" diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc index b1cc61e274..fbe556f8b0 100755 --- a/Library/Homebrew/shims/super/cc +++ b/Library/Homebrew/shims/super/cc @@ -173,10 +173,12 @@ class Cmd case arg when /^-g\d?$/, /^-gstabs\d+/, "-gstabs+", /^-ggdb\d?/, - /^-march=.+/, /^-mtune=.+/, /^-mcpu=.+/, - /^-O[0-9zs]?$/, "-fast", "-no-cpp-precomp", - "-pedantic", "-pedantic-errors", "-Wno-long-double", + /^-mtune=.+/, /^-mcpu=.+/, /^-O[0-9zs]?$/, + "-fast", "-no-cpp-precomp", "-pedantic", + "-pedantic-errors", "-Wno-long-double", "-Wno-unused-but-set-variable" + when /^-march=.+/ + args << arg if runtime_cpu_detection? when "-fopenmp", "-lgomp", "-mno-fused-madd", "-fforce-addr", "-fno-defer-pop", "-mno-dynamic-no-pic", "-fearly-inlining", /^-f(?:no-)?inline-functions-called-once/, /^-finline-limit/, /^-f(?:no-)?check-new/, "-fno-delete-null-pointer-checks", @@ -283,7 +285,7 @@ class Cmd args << "-pipe" args << "-w" unless configure? args << "-#{ENV["HOMEBREW_OPTIMIZATION_LEVEL"]}" - args.concat(optflags) + args.concat(optflags) unless runtime_cpu_detection? args.concat(archflags) args << "-std=#{@arg0}" if /c[89]9/.match?(@arg0) args @@ -385,6 +387,10 @@ class Cmd config.include?("K") end + def runtime_cpu_detection? + config.include?("d") + end + def no_weak_imports? config.include?("w") end