Skip to content

Commit a9b3d6a

Browse files
committed
expose RTLD_LAZY
1 parent 3949e5a commit a9b3d6a

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/ffi-napi/open.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function load(path, option = {}){
3434
const options = {
3535
ignoreLoadingFail: asBoolean(option.ignoreLoadingFail) ?? false,
3636
ignoreMissingSymbol: asBoolean(option.ignoreMissingSymbol) ?? false,
37+
lazy: asBoolean(option.lazy) ?? false,
3738
abi: conventions.includes(option.abi) ? option.abi : "default_abi"
3839
};
3940

@@ -45,7 +46,7 @@ function load(path, option = {}){
4546
if (path.indexOf(ext) === -1) path += ext;
4647
const [ dylib, err ] = attempt(ffi.DynamicLibrary, [
4748
path,
48-
ffi.DynamicLibrary.FLAGS.RTLD_NOW,
49+
options.lazy ? ffi.DynamicLibrary.FLAGS.RTLD_LAZY : ffi.DynamicLibrary.FLAGS.RTLD_NOW,
4950
ffi["FFI_" + options.abi.toUpperCase()]
5051
]);
5152

lib/koffi/open.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function load(path, option = {}){
3131
const options = {
3232
ignoreLoadingFail: asBoolean(option.ignoreLoadingFail) ?? false,
3333
ignoreMissingSymbol: asBoolean(option.ignoreMissingSymbol) ?? false,
34+
lazy: asBoolean(option.lazy) ?? false,
3435
abi: conventions.includes(option.abi) ? option.abi : "func"
3536
};
3637

@@ -40,7 +41,7 @@ function load(path, option = {}){
4041
}[platform] ?? ".so";
4142

4243
if (path.indexOf(ext) === -1) path += ext;
43-
const [dylib, err] = attemptify(koffi.load)(path, { lazy: false });
44+
const [dylib, err] = attemptify(koffi.load)(path, { lazy: options.lazy });
4445

4546
if(err && !options.ignoreLoadingFail){
4647
throw new Failure(err.message, {

0 commit comments

Comments
 (0)