Skip to content

Commit f7878f0

Browse files
authored
Merge pull request #265 from sbfnk/fix-libunwind
libunwind workaround
2 parents c8f042d + 8f5ca48 commit f7878f0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

R/util.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
get_os <- function(){
22
sysinf <- Sys.info()
33
if (!is.null(sysinf)) {
4-
os <- sysinf['sysname']
4+
os <- sysinf[['sysname']]
55
if (os == 'Darwin')
66
os <- "osx"
77
} else {## mystery machine

R/zzz.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ julia_setup <- function(JULIA_HOME = NULL, verbose = TRUE,
128128
on.exit(setwd(cur_dir))
129129
}
130130

131+
# workaround for Ubuntu libunwind issue (see https://github.com/JuliaInterop/JuliaCall/issues/238)
132+
# Preload Julia's own libunwind before initialising.
133+
if (identical(get_os(), "linux")) {
134+
julia_lib_dir <- dirname(.julia$dll_file)
135+
libunwind_paths <- Sys.glob(file.path(julia_lib_dir, "julia", "libunwind.so*"))
136+
if (length(libunwind_paths) > 0) {
137+
if (verbose) message("Loading Julia libunwind from: ", libunwind_paths[1])
138+
tryCatch({
139+
dyn.load(libunwind_paths[1], local = FALSE, now = TRUE)
140+
}, error = function(e) {
141+
if (verbose) warning("Failed to load libunwind: ", e$message)
142+
})
143+
} else {
144+
if (verbose) warning("Julia libunwind not found in ", file.path(julia_lib_dir, "julia"))
145+
}
146+
}
147+
131148
## seems okay to try to load libjulia earlier, except on osx
132149
if (!identical(get_os(), "osx")) {
133150
try(dyn.load(.julia$dll_file))

0 commit comments

Comments
 (0)