Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

superenv: disable ConstraintEliminationPass on Xcode 16 #18620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Library/Homebrew/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
# o - Pass `-oso_prefix` to `ld` whenever it is invoked
# c - Pass `-ld_classic` to `ld` whenever it is invoked
# with `-dead_strip_dylibs`
# E - Pass `-mllvm -enable-constraint-elimination=0` to clang.
#
# These flags will also be present:
# a - apply fix for apr-1-config path
Expand Down
12 changes: 12 additions & 0 deletions Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,16 @@ def no_fixup_chains_support?
# https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2
OS::Mac::DevelopmentTools.ld64_version >= 711
end

# ConstraintEliminiationPass can silently miscompile some formulae.
# https://github.com/Homebrew/homebrew-core/issues/195325
sig { returns(T::Boolean) }
def disable_contraint_elimination?
return false if compiler != :clang

return false if !MacOS::Xcode.version.null? && MacOS::Xcode.version.major != 16
return false if !MacOS::CLT.version.null? && MacOS::CLT.version.major != 16

true
end
end
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/os/mac/extend/ENV/std.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@ def no_weak_imports
def no_fixup_chains
append "LDFLAGS", "-Wl,-no_fixup_chains" if no_fixup_chains_support?
end

def disable_constraint_elimination_if_needed
append_to_cflags "-mllvm -enable-constraint-elimination=0" if disable_contraint_elimination?
end
end
7 changes: 7 additions & 0 deletions Library/Homebrew/extend/os/mac/extend/ENV/super.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_a
if OS::Mac::DevelopmentTools.ld64_version >= "1015.7" && OS::Mac::DevelopmentTools.ld64_version <= "1022.1"
append_to_cccfg "c"
end

# https://github.com/Homebrew/homebrew-core/issues/195325
disable_constraint_elimination_if_needed
end

def no_weak_imports
Expand All @@ -168,4 +171,8 @@ def no_weak_imports
def no_fixup_chains
append_to_cccfg "f" if no_fixup_chains_support?
end

def disable_constraint_elimination_if_needed
append_to_cccfg "E" if disable_contraint_elimination?
end
end
5 changes: 5 additions & 0 deletions Library/Homebrew/shims/super/cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class Cmd
args.concat(archflags)
args << "-std=#{@arg0}" if /c[89]9/.match?(@arg0)
args << "-g" if debug_symbols?
args += ["-mllvm", "-enable-constraint-elimination=0"] if disable_contraint_elimination?
args
end

Expand Down Expand Up @@ -435,6 +436,10 @@ class Cmd
.flat_map { |arg| arg.delete_prefix("-Wl,").split(",") }
end

def disable_contraint_elimination?
config.include?("E")
end

def no_fixup_chains?
return false unless config.include?("f")
return false unless calls_ld?
Expand Down
Loading