Skip to content

Commit 1aeb1b0

Browse files
authored
Fix broken debug building (#58088)
In commit f5278d8, a `OncePerProcess` variable `private_shlibdir` was added to improve the library path resolving logic. However it only consindered release building and left debug mode broken. This brings it back. Also during the research of getting the building mode at runtime, I found two small similar functions, and it may be better to combine them.
1 parent a690758 commit 1aeb1b0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

base/libdl.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Libdl
55
Interface to libdl. Provides dynamic linking support.
66
""" Libdl
77

8-
import Base.DL_LOAD_PATH
8+
import Base: DL_LOAD_PATH, isdebugbuild
99

1010
export DL_LOAD_PATH, RTLD_DEEPBIND, RTLD_FIRST, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL,
1111
RTLD_NODELETE, RTLD_NOLOAD, RTLD_NOW, dlclose, dlopen, dlopen_e, dlsym, dlsym_e,
@@ -341,7 +341,8 @@ Base.print(io::IO, llp::LazyLibraryPath) = print(io, string(llp))
341341
# Helper to get `$(private_shlibdir)` at runtime
342342
struct PrivateShlibdirGetter; end
343343
const private_shlibdir = Base.OncePerProcess{String}() do
344-
dirname(dlpath("libjulia-internal"))
344+
libname = ifelse(isdebugbuild(), "libjulia-internal-debug", "libjulia-internal")
345+
dirname(dlpath(libname))
345346
end
346347
Base.string(::PrivateShlibdirGetter) = private_shlibdir()
347348

base/linking.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22
module Linking
33

4+
import Base: isdebugbuild
45
import Base.Libc: Libdl
56

67
# from LLD_jll
@@ -123,7 +124,6 @@ else
123124
"-shared"
124125
end
125126

126-
is_debug() = ccall(:jl_is_debugbuild, Cint, ()) == 1
127127
libdir() = abspath(Sys.BINDIR, Base.LIBDIR)
128128
private_libdir() = abspath(Sys.BINDIR, Base.PRIVATE_LIBDIR)
129129
if Sys.iswindows()
@@ -137,7 +137,7 @@ verbose_linking() = something(Base.get_bool_env("JULIA_VERBOSE_LINKING", false),
137137
function link_image_cmd(path, out)
138138
PRIVATE_LIBDIR = "-L$(private_libdir())"
139139
SHLIBDIR = "-L$(shlibdir())"
140-
LIBS = is_debug() ? ("-ljulia-debug", "-ljulia-internal-debug") :
140+
LIBS = isdebugbuild() ? ("-ljulia-debug", "-ljulia-internal-debug") :
141141
("-ljulia", "-ljulia-internal")
142142
@static if Sys.iswindows()
143143
LIBS = (LIBS..., "-lopenlibm", "-lssp", "-lgcc_s", "-lgcc", "-lmsvcrt")

0 commit comments

Comments
 (0)