mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
ffi: enable module by default
Enable node:ffi by default in builds with FFI support. Keep --experimental-ffi as a compatibility no-op and --no-experimental-ffi as an opt-out. Loading the module still emits an experimental warning. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/65475 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
7276858621
commit
9f04fcd70d
58 files changed
+50
-134
No files matched your search
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -16,8 +16,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
const bench = common.createBenchmark(main, {
|
||||
signature: ['fast', 'slow'],
|
||||
n: [1e3],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -5,8 +5,6 @@ const ffi = require('node:ffi');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
const { lib, functions } = ffi.dlopen(null, {
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -23,7 +23,7 @@ const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
symbol: ['call_int_callback', 'sum_8_i32'],
|
||||
}, {
|
||||
flags: ['--experimental-ffi', '--no-warnings'],
|
||||
flags: ['--no-warnings'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -6,8 +6,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
@@ -7,8 +7,6 @@ const { libraryPath, ensureFixtureLibrary } = require('./common.js');
|
||||
const bench = common.createBenchmark(main, {
|
||||
size: [64, 1024, 16384],
|
||||
n: [1e6],
|
||||
}, {
|
||||
flags: ['--experimental-ffi'],
|
||||
});
|
||||
|
||||
ensureFixtureLibrary();
|
||||
|
||||
+16
-16
@@ -202,8 +202,8 @@ added: v26.1.0
|
||||
When using the [Permission Model][], the process will not be able to use FFI
|
||||
APIs by default. Attempts to use FFI APIs will throw an `ERR_ACCESS_DENIED`
|
||||
exception unless the user explicitly passes the `--allow-ffi` flag when
|
||||
starting Node.js. The [`node:ffi`][] module also requires the
|
||||
`--experimental-ffi` flag and is only available in builds with FFI support.
|
||||
starting Node.js. The [`node:ffi`][] module is only available in builds with
|
||||
FFI support.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -213,7 +213,7 @@ const lib = new DynamicLibrary(`./mylib.${suffix}`);
|
||||
```
|
||||
|
||||
```console
|
||||
$ node --permission --experimental-ffi index.js
|
||||
$ node --permission index.js
|
||||
Error: Access to this API has been restricted. Use --allow-ffi to manage permissions.
|
||||
at node:internal/main/run_main_module:17:47 {
|
||||
code: 'ERR_ACCESS_DENIED',
|
||||
@@ -1270,18 +1270,6 @@ added:
|
||||
|
||||
Enable exposition of [EventSource Web API][] on the global scope.
|
||||
|
||||
### `--experimental-ffi`
|
||||
|
||||
<!-- YAML
|
||||
added: v26.1.0
|
||||
-->
|
||||
|
||||
> Stability: 1 - Experimental
|
||||
|
||||
Enable the experimental [`node:ffi`][] module.
|
||||
|
||||
This flag is only available in builds with FFI support.
|
||||
|
||||
### `--experimental-import-meta-resolve`
|
||||
|
||||
<!-- YAML
|
||||
@@ -2105,6 +2093,18 @@ changes:
|
||||
|
||||
Disable using [syntax detection][] to determine module type.
|
||||
|
||||
### `--no-experimental-ffi`
|
||||
|
||||
<!-- YAML
|
||||
added: v26.1.0
|
||||
-->
|
||||
|
||||
> Stability: 1 - Experimental
|
||||
|
||||
Disable the experimental [`node:ffi`][] module.
|
||||
|
||||
This flag is only available in builds with FFI support.
|
||||
|
||||
### `--no-experimental-global-navigator`
|
||||
|
||||
<!-- YAML
|
||||
@@ -3904,7 +3904,6 @@ one is included in the list below.
|
||||
* `--experimental-detect-module`
|
||||
* `--experimental-dtls`
|
||||
* `--experimental-eventsource`
|
||||
* `--experimental-ffi`
|
||||
* `--experimental-import-meta-resolve`
|
||||
* `--experimental-import-text`
|
||||
* `--experimental-json-modules`
|
||||
@@ -3952,6 +3951,7 @@ one is included in the list below.
|
||||
* `--no-addons`
|
||||
* `--no-async-context-frame`
|
||||
* `--no-deprecation`
|
||||
* `--no-experimental-ffi`
|
||||
* `--no-experimental-global-navigator`
|
||||
* `--no-experimental-sqlite`
|
||||
* `--no-experimental-strip-types`
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ const ffi = require('node:ffi');
|
||||
```
|
||||
|
||||
This module is only available under the `node:` scheme in builds with FFI
|
||||
support and is gated by the `--experimental-ffi` flag.
|
||||
support. It can be disabled with the `--no-experimental-ffi` flag.
|
||||
|
||||
Building Node.js with `node:ffi` support is available via the bundled `libffi` on
|
||||
platforms where `libffi` provides a compatible static backend, or via a
|
||||
|
||||
@@ -82,8 +82,8 @@ using the [`--allow-child-process`][] and [`--allow-worker`][] respectively.
|
||||
To allow network access, use [`--allow-net`][] and for allowing native addons
|
||||
when using permission model, use the [`--allow-addons`][]
|
||||
flag. For WASI, use the [`--allow-wasi`][] flag. For FFI, use the
|
||||
[`--allow-ffi`][] flag. The [`node:ffi`](ffi.md) module also requires the
|
||||
`--experimental-ffi` flag and is only available in builds with FFI support.
|
||||
[`--allow-ffi`][] flag. The [`node:ffi`](ffi.md) module is only available in
|
||||
builds with FFI support.
|
||||
|
||||
To allow use of OpenSSL STORE loaders, for example to load a private key
|
||||
from a {URL} passed to [`crypto.createPrivateKey()`][], use the
|
||||
|
||||
+9
-9
@@ -122,15 +122,15 @@ directly through the process arguments.
|
||||
When using the Permission Model, the process will not be able to use FFI
|
||||
APIs by default. Attempts to use FFI APIs will throw an \fBERR_ACCESS_DENIED\fR
|
||||
exception unless the user explicitly passes the \fB--allow-ffi\fR flag when
|
||||
starting Node.js. The \fBnode:ffi\fR module also requires the
|
||||
\fB--experimental-ffi\fR flag and is only available in builds with FFI support.
|
||||
starting Node.js. The \fBnode:ffi\fR module is only available in builds with
|
||||
FFI support.
|
||||
Example:
|
||||
.Bd -literal
|
||||
const { DynamicLibrary, suffix } = require('node:ffi');
|
||||
const lib = new DynamicLibrary(`./mylib.${suffix}`);
|
||||
.Ed
|
||||
.Bd -literal
|
||||
$ node --permission --experimental-ffi index.js
|
||||
$ node --permission index.js
|
||||
Error: Access to this API has been restricted. Use --allow-ffi to manage permissions.
|
||||
at node:internal/main/run_main_module:17:47 {
|
||||
code: 'ERR_ACCESS_DENIED',
|
||||
@@ -748,10 +748,6 @@ dtls documentation for details.
|
||||
.It Fl -experimental-eventsource
|
||||
Enable exposition of EventSource Web API on the global scope.
|
||||
.
|
||||
.It Fl -experimental-ffi
|
||||
Enable the experimental \fBnode:ffi\fR module.
|
||||
This flag is only available in builds with FFI support.
|
||||
.
|
||||
.It Fl -experimental-import-meta-resolve
|
||||
Enable experimental \fBimport.meta.resolve()\fR parent URL support, which allows
|
||||
passing a second \fBparentURL\fR argument for contextual resolution.
|
||||
@@ -1101,6 +1097,10 @@ Silence deprecation warnings.
|
||||
.It Fl -no-experimental-detect-module
|
||||
Disable using syntax detection to determine module type.
|
||||
.
|
||||
.It Fl -no-experimental-ffi
|
||||
Disable the experimental \fBnode:ffi\fR module.
|
||||
This flag is only available in builds with FFI support.
|
||||
.
|
||||
.It Fl -no-experimental-global-navigator
|
||||
Disable exposition of Navigator API on the global scope.
|
||||
.
|
||||
@@ -1996,8 +1996,6 @@ one is included in the list below.
|
||||
.It
|
||||
\fB--experimental-eventsource\fR
|
||||
.It
|
||||
\fB--experimental-ffi\fR
|
||||
.It
|
||||
\fB--experimental-import-meta-resolve\fR
|
||||
.It
|
||||
\fB--experimental-import-text\fR
|
||||
@@ -2092,6 +2090,8 @@ one is included in the list below.
|
||||
.It
|
||||
\fB--no-deprecation\fR
|
||||
.It
|
||||
\fB--no-experimental-ffi\fR
|
||||
.It
|
||||
\fB--no-experimental-global-navigator\fR
|
||||
.It
|
||||
\fB--no-experimental-sqlite\fR
|
||||
|
||||
+1
-1
@@ -593,7 +593,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
|
||||
"experimental node:ffi module",
|
||||
BOOL_FIELD(experimental_ffi),
|
||||
kAllowedInEnvvar,
|
||||
false);
|
||||
HAVE_FFI);
|
||||
#endif // HAVE_FFI
|
||||
AddOption("--experimental-web-worker",
|
||||
"experimental Web Worker API",
|
||||
|
||||
+1
-1
@@ -201,7 +201,7 @@ class EnvironmentOptions : public Options {
|
||||
DEFINE_BOOL_FIELD(enable_source_maps) = false;
|
||||
DEFINE_BOOL_FIELD(experimental_addon_modules) = true;
|
||||
DEFINE_BOOL_FIELD(experimental_eventsource) = EXPERIMENTALS_DEFAULT_VALUE;
|
||||
DEFINE_BOOL_FIELD(experimental_ffi) = EXPERIMENTALS_DEFAULT_VALUE;
|
||||
DEFINE_BOOL_FIELD(experimental_ffi) = HAVE_FFI;
|
||||
DEFINE_BOOL_FIELD(experimental_web_worker) = EXPERIMENTALS_DEFAULT_VALUE;
|
||||
DEFINE_BOOL_FIELD(experimental_websocket) = true;
|
||||
DEFINE_BOOL_FIELD(experimental_sqlite) = HAVE_SQLITE;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --experimental-ffi --expose-gc --allow-natives-syntax
|
||||
// Flags: --expose-gc --allow-natives-syntax
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
common.skipIfFFIMissing();
|
||||
@@ -313,7 +313,6 @@ test('ffi division helpers behave as expected', () => {
|
||||
|
||||
function assertInvalidCallbackReturnAborts(returnExpression) {
|
||||
const { stderr, status, signal } = spawnSync(process.execPath, [
|
||||
'--experimental-ffi',
|
||||
'-e',
|
||||
`'use strict';
|
||||
const ffi = require('node:ffi');
|
||||
@@ -336,7 +335,6 @@ stderr: ${stderr}`);
|
||||
|
||||
function assertInvalidCallbackBehaviorAborts(callbackBody, message) {
|
||||
const { stderr, status, signal } = spawnSync(process.execPath, [
|
||||
'--experimental-ffi',
|
||||
'-e',
|
||||
`'use strict';
|
||||
const ffi = require('node:ffi');
|
||||
@@ -366,7 +364,6 @@ const { functions } = ffi.dlopen(libraryPath, fixtureSymbols);
|
||||
functions.call_int_callback(workerData, 21);
|
||||
`;
|
||||
const { stderr, status, signal } = spawnSync(process.execPath, [
|
||||
'--experimental-ffi',
|
||||
'-e',
|
||||
`'use strict';
|
||||
const { Worker } = require('node:worker_threads');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --experimental-ffi --expose-gc --allow-natives-syntax
|
||||
// Flags: --expose-gc --allow-natives-syntax
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
common.skipIfFFIMissing();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --experimental-ffi --expose-internals --allow-natives-syntax
|
||||
// Flags: --expose-internals --allow-natives-syntax
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --experimental-ffi --allow-natives-syntax
|
||||
// Flags: --allow-natives-syntax
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Flags: --experimental-ffi
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
+10
-10
@@ -1,4 +1,3 @@
|
||||
// Flags: --experimental-ffi
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
@@ -33,22 +32,24 @@ test('ffi builtin is unavailable when disabled', () => {
|
||||
assert.strictEqual(signal, null);
|
||||
});
|
||||
|
||||
test('ffi builtin is listed', () => {
|
||||
for (const [flag, stdout] of Object.entries({
|
||||
'--experimental-ffi': 'true\n',
|
||||
'--no-experimental-ffi': 'false\n',
|
||||
})) {
|
||||
test('ffi builtin is listed by default', () => {
|
||||
for (const flags of [[], ['--experimental-ffi']]) {
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
flag,
|
||||
...flags,
|
||||
'-p',
|
||||
'require("node:module").builtinModules.includes("node:ffi")',
|
||||
], { stdout });
|
||||
], { stdout: 'true\n' });
|
||||
}
|
||||
|
||||
spawnSyncAndAssert(process.execPath, [
|
||||
'--no-experimental-ffi',
|
||||
'-p',
|
||||
'require("node:module").builtinModules.includes("node:ffi")',
|
||||
], { stdout: 'false\n' });
|
||||
});
|
||||
|
||||
test('ffi can be imported from ESM', () => {
|
||||
const { stdout, stderr, status, signal } = spawnSync(process.execPath, [
|
||||
'--experimental-ffi',
|
||||
'--input-type=module',
|
||||
'-e',
|
||||
'import * as ffi from "node:ffi"; console.log(typeof ffi.dlopen);',
|
||||
@@ -64,7 +65,6 @@ test('ffi can be imported from ESM', () => {
|
||||
|
||||
test('DynamicLibrary requires new', () => {
|
||||
const { stdout, stderr, status, signal } = spawnSync(process.execPath, [
|
||||
'--experimental-ffi',
|
||||
'-e',
|
||||
'const ffi = require("node:ffi"); ffi.DynamicLibrary("missing");',
|
||||
], {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --permission --allow-ffi --allow-child-process --experimental-ffi --allow-fs-read=* --allow-fs-write=*
|
||||
// Flags: --permission --allow-ffi --allow-child-process --allow-fs-read=* --allow-fs-write=*
|
||||
'use strict';
|
||||
|
||||
const { skipIfFFIMissing } = require('../common');
|
||||
@@ -19,7 +19,6 @@ test('allow-ffi enables ffi APIs and permission flag discovery', () => {
|
||||
const { stdout, status, signal } = spawnSync(process.execPath, [
|
||||
'--permission',
|
||||
'--expose-internals',
|
||||
'--experimental-ffi',
|
||||
'-p',
|
||||
'JSON.stringify(require("internal/process/permission").availableFlags())',
|
||||
], {
|
||||
|
||||
@@ -10,7 +10,6 @@ skipIfFFIMissing();
|
||||
test('permission audit does not deny ffi access', () => {
|
||||
const { stdout, stderr, status, signal } = spawnSync(process.execPath, [
|
||||
'--permission-audit',
|
||||
'--experimental-ffi',
|
||||
'-e',
|
||||
'const ffi = require("node:ffi"); ' +
|
||||
'console.log(JSON.stringify({ ' +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --permission --experimental-ffi --allow-fs-read=*
|
||||
// Flags: --permission --allow-fs-read=*
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('node:assert');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Flags: --experimental-ffi
|
||||
'use strict';
|
||||
const { skipIfFFIMissing, isWindows, skip } = require('../common');
|
||||
const assert = require('node:assert');
|
||||
@@ -15,7 +14,6 @@ test('writing to readonly memory via buffer fails', () => {
|
||||
const symbols = JSON.stringify(fixtureSymbols);
|
||||
const libPath = JSON.stringify(libraryPath);
|
||||
const { stdout, status } = spawnSync(process.execPath, [
|
||||
'--experimental-ffi',
|
||||
'-p',
|
||||
`
|
||||
const ffi = require('node:ffi');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --experimental-ffi --expose-internals
|
||||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
common.skipIfFFIMissing();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Flags: --experimental-ffi
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --experimental-ffi --expose-gc
|
||||
// Flags: --expose-gc
|
||||
'use strict';
|
||||
const { skipIfFFIMissing } = require('../common');
|
||||
skipIfFFIMissing();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Flags: --permission --allow-ffi --experimental-ffi --allow-fs-read=*
|
||||
// Flags: --permission --allow-ffi --allow-fs-read=*
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
@@ -49,9 +49,6 @@ if (!hasSQLite) {
|
||||
publicBuiltins.delete('node:sqlite');
|
||||
}
|
||||
|
||||
// TODO: Remove this once node:ffi graduates from unflagged.
|
||||
publicBuiltins.delete('node:ffi');
|
||||
|
||||
for (const id of publicBuiltins) {
|
||||
assert.strictEqual(process.getBuiltinModule(id), require(id));
|
||||
}
|
||||
|
||||
@@ -62,8 +62,6 @@ require(fixtures.path('resolve-paths', 'default', 'verify-paths.js'));
|
||||
builtinModules.forEach((mod) => {
|
||||
// TODO(@jasnell): Remove once node:quic is no longer flagged
|
||||
if (mod === 'node:quic') return;
|
||||
// TODO: Remove once node:ffi is no longer flagged
|
||||
if (mod === 'node:ffi') return;
|
||||
// Remove once node:vfs is no longer flagged
|
||||
if (mod === 'node:vfs') return;
|
||||
if (mod === 'node:sqlite' && !common.hasSQLite) return;
|
||||
|
||||
Reference in new issue
Block a user