aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2016-08-17 12:22:28 +0100
committerGitHub2016-08-17 12:22:28 +0100
commit6878577d129833b59f82c4872b49e97ba5cec499 (patch)
tree648c8479832ec3694e7fbec6c9ed455a0b1a31c2
parentcf71e30180d44219836ef129d5e5f00325210dfb (diff)
parent560918356738ee71aa7e7110d0e8aa6c8b3dbe4f (diff)
downloadbrew-6878577d129833b59f82c4872b49e97ba5cec499.tar.bz2
Merge pull request #721 from MikeMcQuaid/no_weak_imports
Set -no_weak_imports linker flag for Xcode 8
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb2
-rw-r--r--Library/Homebrew/extend/os/extend/ENV/shared.rb5
-rw-r--r--Library/Homebrew/extend/os/mac/extend/ENV/shared.rb6
-rw-r--r--Library/Homebrew/extend/os/mac/extend/ENV/std.rb5
-rw-r--r--Library/Homebrew/extend/os/mac/extend/ENV/super.rb4
-rwxr-xr-xLibrary/Homebrew/shims/super/cc6
6 files changed, 28 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index 3566a5c50..c253942ac 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -329,3 +329,5 @@ module SharedEnvExtension
version && Version.create(version) >= Version.create("4.8")
end
end
+
+require "extend/os/extend/ENV/shared"
diff --git a/Library/Homebrew/extend/os/extend/ENV/shared.rb b/Library/Homebrew/extend/os/extend/ENV/shared.rb
new file mode 100644
index 000000000..676159b37
--- /dev/null
+++ b/Library/Homebrew/extend/os/extend/ENV/shared.rb
@@ -0,0 +1,5 @@
+require "extend/ENV/shared"
+
+if OS.mac?
+ require "extend/os/mac/extend/ENV/shared"
+end
diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb b/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
new file mode 100644
index 000000000..a33747203
--- /dev/null
+++ b/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
@@ -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
diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb
index 817b4a0ff..d9cabc50e 100644
--- a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb
@@ -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
diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb
index 1976f5312..e482020e8 100644
--- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -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
diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc
index a016af777..10b39bde2 100755
--- a/Library/Homebrew/shims/super/cc
+++ b/Library/Homebrew/shims/super/cc
@@ -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?