Skip to content

Commit

Permalink
Pass -headerpad_max_install_names to macOS linker
Browse files Browse the repository at this point in the history
This fixes an issue with `install_name_tool` not being able to fix rpath of some
ICU libraries for macOS, see
JuliaPackaging/Yggdrasil#1668 and
JuliaPackaging/Yggdrasil#1650 (comment)
for reference.
  • Loading branch information
giordano committed Sep 12, 2020
1 parent c78208e commit 7c20fac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Platforms.jl
Expand Up @@ -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")]
Expand Down
9 changes: 7 additions & 2 deletions src/Runner.jl
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 7c20fac

Please sign in to comment.