From 7c20facc57ae386f516db30863479b5fb26f0579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sat, 12 Sep 2020 13:03:34 +0100 Subject: [PATCH] Pass `-headerpad_max_install_names` to macOS linker This fixes an issue with `install_name_tool` not being able to fix rpath of some ICU libraries for macOS, see https://github.com/JuliaPackaging/Yggdrasil/issues/1668 and https://github.com/JuliaPackaging/Yggdrasil/issues/1650#issuecomment-691369425 for reference. --- src/Platforms.jl | 2 +- src/Runner.jl | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Platforms.jl b/src/Platforms.jl index 76e8ce1c..b9813d76 100644 --- a/src/Platforms.jl +++ b/src/Platforms.jl @@ -20,7 +20,7 @@ Base.show(io::IO, ::AnyPlatform) = print(io, "AnyPlatform()") ## The extended platforms, to represent platforms beyond the standard ones in ## Pkg.BinaryPlatforms. -const ARCHITECTURE_FLAGS = begin +const ARCHITECTURE_FLAGS = let # Better be always explicit about `-march` & `-mtune`: # https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/ march_flags(arch) = ["-m$(f)=$(arch)" for f in ("arch", "tune")] diff --git a/src/Runner.jl b/src/Runner.jl index 34a0f2f5..3eb539e4 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -286,8 +286,11 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin # On macos, we want to use a particular linker with clang. But we want to avoid warnings about unused # flags when just compiling, so we put it into "linker-only flags". - clang_link_flags(p::Platform) = String["-fuse-ld=$(aatriplet(p))"] - clang_link_flags(p::Union{FreeBSD,MacOS}) = ["-L/opt/$(aatriplet(p))/$(aatriplet(p))/lib", "-fuse-ld=$(aatriplet(p))"] + clang_link_flags(p::Platform) = ["-fuse-ld=$(aatriplet(p))"] + clang_link_flags(p::FreeBSD) = ["-L/opt/$(aatriplet(p))/$(aatriplet(p))/lib", "-fuse-ld=$(aatriplet(p))"] + # We need to pass `-headerpad_max_install_names` to the macOS linker because + # we use `install_name_tool` during audit. + clang_link_flags(p::MacOS) = ["-L/opt/$(aatriplet(p))/$(aatriplet(p))/lib", "-fuse-ld=$(aatriplet(p))", "-headerpad_max_install_names"] gcc_link_flags(p::Platform) = String[] function gcc_link_flags(p::Linux) @@ -298,6 +301,8 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin end return String[] end + # Same reason to use `-headerpad_max_install_names` as above. + gcc_link_flags(p::MacOS) = ["-headerpad_max_install_names"] gfortran_link_flags(p::Platform) = gcc_link_flags(p) # C/C++/Fortran