Skip to content

Commit f60d6d3

Browse files
committed
src: fix --disable-single-executable-application
Previously it would not compile if the build is configured with --disable-single-executable-application because we use directives to exclude the definition of SEA-related code completely. This patch changes them so that the SEA code are still compiled and internals still check whether the executable is an SEA. If future modifications to the C++ code attempt to load the SEA blob when SEA is disabled, UNREACHABLE() would be raised. If user attempt to generate the SEA blob with --experimental-sea-config with an executable that disables SEA, they would get an error.
1 parent fe22990 commit f60d6d3

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/node.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,13 +1403,16 @@ static ExitCode StartInternal(int argc, char** argv) {
14031403
});
14041404

14051405
uv_loop_configure(uv_default_loop(), UV_METRICS_IDLE_TIME);
1406-
14071406
std::string sea_config = per_process::cli_options->experimental_sea_config;
14081407
if (!sea_config.empty()) {
1408+
#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
14091409
return sea::BuildSingleExecutableBlob(
14101410
sea_config, result->args(), result->exec_args());
1411+
#else
1412+
fprintf(stderr, "Single executable application is disabled.\n");
1413+
return ExitCode::kGenericUserError;
1414+
#endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
14111415
}
1412-
14131416
// --build-snapshot indicates that we are in snapshot building mode.
14141417
if (per_process::cli_options->per_isolate->build_snapshot) {
14151418
if (per_process::cli_options->per_isolate->build_snapshot_config.empty() &&

src/node_sea.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <tuple>
2828
#include <vector>
2929

30-
#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
31-
3230
using node::ExitCode;
3331
using v8::ArrayBuffer;
3432
using v8::BackingStore;
@@ -189,6 +187,7 @@ SeaResource SeaDeserializer::Read() {
189187
}
190188

191189
std::string_view FindSingleExecutableBlob() {
190+
#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
192191
CHECK(IsSingleExecutable());
193192
static const std::string_view result = []() -> std::string_view {
194193
size_t size;
@@ -209,6 +208,9 @@ std::string_view FindSingleExecutableBlob() {
209208
result.data(),
210209
result.size());
211210
return result;
211+
#else
212+
UNREACHABLE();
213+
#endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
212214
}
213215

214216
} // anonymous namespace
@@ -668,5 +670,3 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
668670

669671
NODE_BINDING_CONTEXT_AWARE_INTERNAL(sea, node::sea::Initialize)
670672
NODE_BINDING_EXTERNAL_REFERENCE(sea, node::sea::RegisterExternalReferences)
671-
672-
#endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)

src/node_sea.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
55

6-
#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
7-
86
#include <cinttypes>
97
#include <optional>
108
#include <string>
@@ -52,8 +50,6 @@ node::ExitCode BuildSingleExecutableBlob(
5250
} // namespace sea
5351
} // namespace node
5452

55-
#endif // !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)
56-
5753
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5854

5955
#endif // SRC_NODE_SEA_H_

0 commit comments

Comments
 (0)