Merge pull request #721 from MikeMcQuaid/no_weak_imports

Set -no_weak_imports linker flag for Xcode 8
This commit is contained in:
Mike McQuaid 2016-08-17 12:22:28 +01:00 committed by GitHub
commit 6878577d12
6 changed files with 28 additions and 0 deletions

View File

@ -329,3 +329,5 @@ module SharedEnvExtension
version && Version.create(version) >= Version.create("4.8")
end
end
require "extend/os/extend/ENV/shared"

View File

@ -0,0 +1,5 @@
require "extend/ENV/shared"
if OS.mac?
require "extend/os/mac/extend/ENV/shared"
end

View File

@ -0,0 +1,6 @@
module SharedEnvExtension
def no_weak_imports?
return false unless compiler == :clang
MacOS::Xcode.version >= "8.0" || MacOS::CLT.version >= "8.0"
end
end

View File

@ -28,6 +28,11 @@ module Stdenv
# depend on it already being installed to build itself.
ld64 if Formula["ld64"].installed?
end
# Xcode 8 should be told to fail to link against weak links
# Issue from Apple engineer:
# https://github.com/Homebrew/homebrew-core/issues/3727
append "LDFLAGS", "-Wl,-no_weak_imports" if no_weak_imports?
end
def homebrew_extra_pkg_config_paths

View File

@ -81,6 +81,10 @@ module Superenv
s << "s" if MacOS.version >= :mountain_lion
# Fix issue with >= 10.8 apr-1-config having broken paths
s << "a" if MacOS.version >= :mountain_lion
# Xcode 8 should be told to fail to link against weak links
# Issue from Apple engineer:
# https://github.com/Homebrew/homebrew-core/issues/3727
s << "w" if no_weak_imports?
s
end

View File

@ -258,8 +258,10 @@ class Cmd
case mode
when :ld
args << "-headerpad_max_install_names"
args << "-no_weak_imports" if no_weak_imports?
when :ccld, :cxxld
args << "-Wl,-headerpad_max_install_names"
args << "-Wl,-no_weak_imports" if no_weak_imports?
end
args
end
@ -305,6 +307,10 @@ class Cmd
config.include?("K")
end
def no_weak_imports?
config.include?("w")
end
def canonical_path(path)
path = Pathname.new(path)
path = path.realpath if path.exist?