Skip to content

Commit

Permalink
Bump LLD to get dsymutil and use it for pkgimgs (#48628)
Browse files Browse the repository at this point in the history
* Run dsymutil on pkgimgs for apple platforms +
LLD bump to get dsymutil from the jll

(cherry picked from commit d8c2250)
  • Loading branch information
gbaraldi authored and KristofferC committed Feb 21, 2023
1 parent 10342e2 commit 6ded08d
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 119 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ endif
# Install `lld` into libexec/
$(INSTALL_M) $(build_depsbindir)/lld$(EXE) $(DESTDIR)$(libexecdir)/

# Install `dsymutil` into libexec/
$(INSTALL_M) $(build_depsbindir)/dsymutil$(EXE) $(DESTDIR)$(libexecdir)/

# Copy public headers
cp -R -L $(build_includedir)/julia/* $(DESTDIR)$(includedir)/julia
# Copy system image
Expand Down
22 changes: 22 additions & 0 deletions base/linking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const PATH_list = String[]
const LIBPATH_list = String[]
const lld_path = Ref{String}()
const lld_exe = Sys.iswindows() ? "lld.exe" : "lld"
const dsymutil_path = Ref{String}()
const dsymutil_exe = Sys.iswindows() ? "dsymutil.exe" : "dsymutil"

if Sys.iswindows()
const LIBPATH_env = "PATH"
Expand Down Expand Up @@ -60,12 +62,27 @@ function __init_lld_path()
return
end

function __init_dsymutil_path()
#Same as with lld but for dsymutil
for bundled_dsymutil_path in (joinpath(Sys.BINDIR, Base.LIBEXECDIR, dsymutil_exe),
joinpath(Sys.BINDIR, "..", "tools", dsymutil_exe),
joinpath(Sys.BINDIR, dsymutil_exe))
if isfile(bundled_dsymutil_path)
dsymutil_path[] = abspath(bundled_dsymutil_path)
return
end
end
dsymutil_path[] = something(Sys.which(dsymutil_exe), dsymutil_exe)
return
end

const VERBOSE = Ref{Bool}(false)

function __init__()
VERBOSE[] = parse(Bool, get(ENV, "JULIA_VERBOSE_LINKING", "false"))

__init_lld_path()
__init_dsymutil_path()
PATH[] = dirname(lld_path[])
if Sys.iswindows()
# On windows, the dynamic libraries (.dll) are in Sys.BINDIR ("usr\\bin")
Expand All @@ -82,6 +99,11 @@ function lld(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
return Cmd(Cmd([lld_path[]]); env)
end

function dsymutil(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
env = adjust_ENV!(copy(ENV), PATH[], LIBPATH[], adjust_PATH, adjust_LIBPATH)
return Cmd(Cmd([dsymutil_path[]]); env)
end

function ld()
default_args = ``
@static if Sys.iswindows()
Expand Down
6 changes: 6 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,9 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
rm(evicted_cachefile; force=true)
try
rm(ocachefile_from_cachefile(evicted_cachefile); force=true)
@static if Sys.isapple()
rm(ocachefile_from_cachefile(evicted_cachefile) * ".dSYM"; force=true, recursive=true)
end
catch
end
end
Expand Down Expand Up @@ -2230,6 +2233,9 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in
cachefile = cachefile_from_ocachefile(ocachefile)
rename(tmppath_so, ocachefile::String; force=true)
end
@static if Sys.isapple()
run(`$(Linking.dsymutil()) $ocachefile`, Base.DevNull(), Base.DevNull(), Base.DevNull())
end
end
# this is atomic according to POSIX (not Win32):
rename(tmppath, cachefile; force=true)
Expand Down
Loading

0 comments on commit 6ded08d

Please sign in to comment.