Skip to content

Commit 5f909e8

Browse files
committed
work around pkgload shims
1 parent 110d217 commit 5f909e8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

R/hooks.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# NOTE: we intentionally do _not_ load tbbmalloc_proxy as its intended
33
# use is to replace the default allocator, something that is dangerous
44
# to do by default (and especially should only be done via e.g. LD_PRELOAD)
5+
.dllInfo <- NULL
56
.tbbDllInfo <- NULL
67
.tbbMallocDllInfo <- NULL
78

@@ -26,15 +27,22 @@ loadTbbLibrary <- function(name) {
2627
.tbbDllInfo <<- loadTbbLibrary("tbb")
2728
.tbbMallocDllInfo <<- loadTbbLibrary("tbbmalloc")
2829

29-
# load RcppParallel library
30-
library.dynam("RcppParallel", pkgname, libname)
30+
# load RcppParallel library if available
31+
# (work around https://github.com/r-lib/devtools/issues/2343)
32+
if (!file.exists(file.path(libname, pkgname, "lib")))
33+
return()
34+
35+
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
3136

3237
}
3338

3439
.onUnload <- function(libpath) {
3540

3641
# unload the package library
37-
library.dynam.unload("RcppParallel", libpath)
42+
if (!is.null(.dllInfo)) {
43+
library.dynam.unload("RcppParallel", libpath)
44+
.dllInfo <<- NULL
45+
}
3846

3947
# unload tbb_malloc if we loaded it
4048
if (!is.null(.tbbMallocDllInfo)) {

0 commit comments

Comments
 (0)