Skip to content

Commit f03ab48

Browse files
committed
Drop "LTO mode" from qjsc
1 parent bebdfce commit f03ab48

File tree

2 files changed

+6
-102
lines changed

2 files changed

+6
-102
lines changed

CMakeLists.txt

+2-25
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,9 @@ target_compile_definitions(unicode_gen PRIVATE ${qjs_defines})
206206
#
207207

208208
if(BUILD_EXAMPLES AND NOT MINGW)
209-
list(APPEND HELLO_OPTS
210-
-fno-string-normalize
211-
-fno-map
212-
-fno-promise
213-
-fno-typedarray
214-
-fno-typedarray
215-
-fno-regexp
216-
-fno-json
217-
-fno-eval
218-
-fno-proxy
219-
-fno-date
220-
-fno-module-loader
221-
)
222209
add_custom_command(
223210
OUTPUT hello.c
224-
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o ./hello.c ${HELLO_OPTS} ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
211+
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o hello.c ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
225212
DEPENDS qjsc
226213
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
227214
COMMENT "Compile hello.js to a C file with bytecode embeddee"
@@ -235,19 +222,9 @@ if(BUILD_EXAMPLES AND NOT MINGW)
235222
target_compile_definitions(hello PRIVATE ${qjs_defines})
236223
target_link_libraries(hello ${qjs_libs})
237224

238-
list(APPEND HELLO_MODULE_OPTS
239-
-fno-string-normalize
240-
-fno-map
241-
-fno-typedarray
242-
-fno-regexp
243-
-fno-json
244-
-fno-eval
245-
-fno-proxy
246-
-fno-date
247-
)
248225
add_custom_command(
249226
OUTPUT hello_module.c
250-
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o ./hello_module.c ${HELLO_MODULE_OPTS} -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
227+
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o hello_module.c -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
251228
DEPENDS qjsc
252229
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
253230
COMMENT "Compile hello_module.js to a C file with bytecode embeddee"

qjsc.c

+4-77
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,13 @@ typedef struct namelist_t {
4747
int size;
4848
} namelist_t;
4949

50-
typedef struct {
51-
const char *option_name;
52-
const char *init_name;
53-
} FeatureEntry;
54-
5550
static namelist_t cname_list;
5651
static namelist_t cmodule_list;
5752
static namelist_t init_module_list;
58-
static uint64_t feature_bitmap;
5953
static FILE *outfile;
6054
static BOOL byte_swap;
6155
static const char *c_ident_prefix = "qjsc_";
6256

63-
#define FE_ALL (-1)
64-
65-
static const FeatureEntry feature_list[] = {
66-
{ "date", "Date" },
67-
{ "eval", "Eval" },
68-
{ "string-normalize", "StringNormalize" },
69-
{ "regexp", "RegExp" },
70-
{ "json", "JSON" },
71-
{ "proxy", "Proxy" },
72-
{ "map", "MapSet" },
73-
{ "typedarray", "TypedArrays" },
74-
{ "promise", "Promise" },
75-
#define FE_MODULE_LOADER 9
76-
{ "module-loader", NULL },
77-
{ "bigint", "BigInt" },
78-
};
7957

8058
void namelist_add(namelist_t *lp, const char *name, const char *short_name,
8159
int flags)
@@ -349,20 +327,6 @@ void help(void)
349327
"-S n set the maximum stack size to 'n' bytes (default=%d)\n",
350328
JS_GetVersion(),
351329
JS_DEFAULT_STACK_SIZE);
352-
#ifdef CONFIG_LTO
353-
{
354-
int i;
355-
printf("-flto use link time optimization\n");
356-
printf("-fno-[");
357-
for(i = 0; i < countof(feature_list); i++) {
358-
if (i != 0)
359-
printf("|");
360-
printf("%s", feature_list[i].option_name);
361-
}
362-
printf("]\n"
363-
" disable selected language features (smaller code size)\n");
364-
}
365-
#endif
366330
exit(1);
367331
}
368332

@@ -379,7 +343,6 @@ int main(int argc, char **argv)
379343
FILE *fo;
380344
JSRuntime *rt;
381345
JSContext *ctx;
382-
BOOL use_lto;
383346
int module;
384347
OutputTypeEnum output_type;
385348
size_t stack_size;
@@ -388,11 +351,9 @@ int main(int argc, char **argv)
388351
out_filename = NULL;
389352
output_type = OUTPUT_C;
390353
cname = NULL;
391-
feature_bitmap = FE_ALL;
392354
module = -1;
393355
byte_swap = FALSE;
394356
verbose = 0;
395-
use_lto = FALSE;
396357
stack_size = 0;
397358
memset(&dynamic_module_list, 0, sizeof(dynamic_module_list));
398359

@@ -401,7 +362,7 @@ int main(int argc, char **argv)
401362
namelist_add(&cmodule_list, "os", "os", 0);
402363

403364
for(;;) {
404-
c = getopt(argc, argv, "ho:N:f:mxevM:p:S:D:");
365+
c = getopt(argc, argv, "ho:N:mxevM:p:S:D:");
405366
if (c == -1)
406367
break;
407368
switch(c) {
@@ -416,29 +377,6 @@ int main(int argc, char **argv)
416377
case 'N':
417378
cname = optarg;
418379
break;
419-
case 'f':
420-
{
421-
const char *p;
422-
p = optarg;
423-
if (!strcmp(optarg, "lto")) {
424-
use_lto = TRUE;
425-
} else if (strstart(p, "no-", &p)) {
426-
use_lto = TRUE;
427-
for(i = 0; i < countof(feature_list); i++) {
428-
if (!strcmp(p, feature_list[i].option_name)) {
429-
feature_bitmap &= ~((uint64_t)1 << i);
430-
break;
431-
}
432-
}
433-
if (i == countof(feature_list))
434-
goto bad_feature;
435-
} else {
436-
bad_feature:
437-
fprintf(stderr, "unsupported feature: %s\n", optarg);
438-
exit(1);
439-
}
440-
}
441-
break;
442380
case 'm':
443381
module = 1;
444382
break;
@@ -531,18 +469,9 @@ int main(int argc, char **argv)
531469
fprintf(fo,
532470
"static JSContext *JS_NewCustomContext(JSRuntime *rt)\n"
533471
"{\n"
534-
" JSContext *ctx = JS_NewContextRaw(rt);\n"
472+
" JSContext *ctx = JS_NewContext(rt);\n"
535473
" if (!ctx)\n"
536474
" return NULL;\n");
537-
/* add the basic objects */
538-
fprintf(fo, " JS_AddIntrinsicBaseObjects(ctx);\n");
539-
for(i = 0; i < countof(feature_list); i++) {
540-
if ((feature_bitmap & ((uint64_t)1 << i)) &&
541-
feature_list[i].init_name) {
542-
fprintf(fo, " JS_AddIntrinsic%s(ctx);\n",
543-
feature_list[i].init_name);
544-
}
545-
}
546475
/* add the precompiled modules (XXX: could modify the module
547476
loader instead) */
548477
for(i = 0; i < init_module_list.count; i++) {
@@ -574,10 +503,8 @@ int main(int argc, char **argv)
574503
(unsigned int)stack_size);
575504
}
576505

577-
/* add the module loader if necessary */
578-
if (feature_bitmap & (1 << FE_MODULE_LOADER)) {
579-
fprintf(fo, " JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);\n");
580-
}
506+
/* add the module loader */
507+
fprintf(fo, " JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);\n");
581508

582509
fprintf(fo,
583510
" ctx = JS_NewCustomContext(rt);\n"

0 commit comments

Comments
 (0)