Skip to content

Commit 6e76fd9

Browse files
author
llgoer
committed
更新到2019-09-18版本
1 parent a33ae52 commit 6e76fd9

21 files changed

+868
-349
lines changed

Changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2019-09-18:
2+
3+
- added os.exec and other system calls
4+
- exported JS_ValueToAtom()
5+
- qjsc: added 'qjsc_' prefix to the generated C identifiers
6+
- added cross-compilation support
7+
- misc bug fixes
8+
19
2019-09-01:
210

311
- added globalThis

Makefile

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ endif
3131
CONFIG_LTO=y
3232
# consider warnings as errors (for development)
3333
#CONFIG_WERROR=y
34-
35-
ifndef CONFIG_WIN32
3634
# force 32 bit build for some utilities
37-
CONFIG_M32=y
38-
endif
35+
#CONFIG_M32=y
36+
3937
ifdef CONFIG_DARWIN
4038
# use clang instead of gcc
4139
CONFIG_CLANG=y
@@ -60,6 +58,7 @@ else
6058
EXE=
6159
endif
6260
ifdef CONFIG_CLANG
61+
HOST_CC=clang
6362
CC=$(CROSS_PREFIX)clang
6463
CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
6564
CFLAGS += -Wextra
@@ -80,15 +79,17 @@ ifdef CONFIG_CLANG
8079
endif
8180
endif
8281
else
82+
HOST_CC=gcc
8383
CC=$(CROSS_PREFIX)gcc
8484
CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
85-
CFLAGS += -Wno-array-bounds
85+
CFLAGS += -Wno-array-bounds -Wno-format-truncation
8686
ifdef CONFIG_LTO
8787
AR=$(CROSS_PREFIX)gcc-ar
8888
else
8989
AR=$(CROSS_PREFIX)ar
9090
endif
9191
endif
92+
STRIP=$(CROSS_PREFIX)strip
9293
ifdef CONFIG_WERROR
9394
CFLAGS+=-Werror
9495
endif
@@ -118,7 +119,17 @@ else
118119
LDEXPORT=-rdynamic
119120
endif
120121

121-
PROGS=qjs$(EXE) qjsbn$(EXE) qjsc qjsbnc run-test262 run-test262-bn
122+
PROGS=qjs$(EXE) qjsbn$(EXE) qjsc$(EXE) qjsbnc$(EXE) run-test262 run-test262-bn
123+
ifneq ($(CROSS_PREFIX),)
124+
QJSC_CC=gcc
125+
QJSC=./host-qjsc
126+
QJSBNC=./host-qjsbnc
127+
PROGS+=$(QJSC) $(QJSBNC)
128+
else
129+
QJSC_CC=$(CC)
130+
QJSC=./qjsc$(EXE)
131+
QJSBNC=./qjsbnc$(EXE)
132+
endif
122133
ifndef CONFIG_WIN32
123134
PROGS+=qjscalc
124135
endif
@@ -129,14 +140,15 @@ PROGS+=libquickjs.a libquickjs.bn.a
129140
ifdef CONFIG_LTO
130141
PROGS+=libquickjs.lto.a libquickjs.bn.lto.a
131142
endif
143+
132144
# examples
145+
ifeq ($(CROSS_PREFIX),)
133146
ifdef CONFIG_ASAN
134147
PROGS+=
135-
else ifdef CONFIG_WIN32
136-
PROGS+=
137148
else
138149
PROGS+=examples/hello examples/hello_module examples/c_module
139150
endif
151+
endif
140152

141153
all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)
142154

@@ -162,20 +174,32 @@ qjs$(EXE): $(QJS_OBJS)
162174
qjs-debug$(EXE): $(patsubst %.o, %.debug.o, $(QJS_OBJS))
163175
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
164176

165-
qjsc: $(OBJDIR)/qjsc.o $(QJS_LIB_OBJS)
177+
qjsc$(EXE): $(OBJDIR)/qjsc.o $(QJS_LIB_OBJS)
166178
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
167179

168-
qjsbnc: $(OBJDIR)/qjsc.bn.o $(QJSBN_LIB_OBJS)
180+
qjsbnc$(EXE): $(OBJDIR)/qjsc.bn.o $(QJSBN_LIB_OBJS)
169181
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
170182

183+
ifneq ($(CROSS_PREFIX),)
184+
185+
$(QJSC): $(OBJDIR)/qjsc.host.o \
186+
$(patsubst %.o, %.host.o, $(QJS_LIB_OBJS))
187+
$(HOST_CC) $(LDFLAGS) -o $@ $^ $(LIBS)
188+
189+
$(QJSBNC): $(OBJDIR)/qjsc.bn.host.o \
190+
$(patsubst %.o, %.host.o, $(QJSBN_LIB_OBJS))
191+
$(HOST_CC) $(LDFLAGS) -o $@ $^ $(LIBS)
192+
193+
endif #CROSS_PREFIX
171194

172-
QJSC_DEFINES:=-DCONFIG_CC=\"$(CC)\"
195+
QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\" -DCONFIG_PREFIX=\"$(prefix)\"
173196
ifdef CONFIG_LTO
174197
QJSC_DEFINES+=-DCONFIG_LTO
175198
endif
176-
QJSC_DEFINES+=-DCONFIG_PREFIX=\"$(prefix)\"
199+
QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(prefix)\"
177200

178201
$(OBJDIR)/qjsc.o $(OBJDIR)/qjsc.bn.o: CFLAGS+=$(QJSC_DEFINES)
202+
$(OBJDIR)/qjsc.host.o $(OBJDIR)/qjsc.bn.host.o: CFLAGS+=$(QJSC_HOST_DEFINES)
179203

180204
qjs32: $(patsubst %.o, %.m32.o, $(QJS_OBJS))
181205
$(CC) -m32 $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS)
@@ -216,14 +240,14 @@ libquickjs.bn.a: $(patsubst %.o, %.nolto.o, $(QJSBN_LIB_OBJS))
216240
$(AR) rcs $@ $^
217241
endif # CONFIG_LTO
218242

219-
repl.c: qjsc repl.js
220-
./qjsc -c -o $@ -m repl.js
243+
repl.c: $(QJSC) repl.js
244+
$(QJSC) -c -o $@ -m repl.js
221245

222-
repl-bn.c: qjsbnc repl.js
223-
./qjsbnc -c -o $@ -m repl.js
246+
repl-bn.c: $(QJSBNC) repl.js
247+
$(QJSBNC) -c -o $@ -m repl.js
224248

225-
qjscalc.c: qjsbnc qjscalc.js
226-
./qjsbnc -c -o $@ qjscalc.js
249+
qjscalc.c: $(QJSBNC) qjscalc.js
250+
$(QJSBNC) -c -o $@ qjscalc.js
227251

228252
ifneq ($(wildcard unicode/UnicodeData.txt),)
229253
$(OBJDIR)/libunicode.o $(OBJDIR)/libunicode.m32.o $(OBJDIR)/libunicode.m32s.o $(OBJDIR)/libunicode.bn.o $(OBJDIR)/libunicode.bn.m32.o \
@@ -253,12 +277,18 @@ run-test262-bn32: $(patsubst %.o, %.m32.o, $(OBJDIR)/run-test262.bn.o $(QJSBN_LI
253277
$(OBJDIR)/%.o: %.c | $(OBJDIR)
254278
$(CC) $(CFLAGS_OPT) -c -o $@ $<
255279

280+
$(OBJDIR)/%.host.o: %.c | $(OBJDIR)
281+
$(HOST_CC) $(CFLAGS_OPT) -c -o $@ $<
282+
256283
$(OBJDIR)/%.pic.o: %.c | $(OBJDIR)
257284
$(CC) $(CFLAGS_OPT) -fPIC -DJS_SHARED_LIBRARY -c -o $@ $<
258285

259286
$(OBJDIR)/%.bn.o: %.c | $(OBJDIR)
260287
$(CC) $(CFLAGS_OPT) -DCONFIG_BIGNUM -c -o $@ $<
261288

289+
$(OBJDIR)/%.bn.host.o: %.c | $(OBJDIR)
290+
$(HOST_CC) $(CFLAGS_OPT) -DCONFIG_BIGNUM -c -o $@ $<
291+
262292
$(OBJDIR)/%.nolto.o: %.c | $(OBJDIR)
263293
$(CC) $(CFLAGS_NOLTO) -c -o $@ $<
264294

@@ -289,8 +319,8 @@ regexp_test: libregexp.c libunicode.c cutils.c
289319
jscompress: jscompress.c
290320
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ jscompress.c
291321

292-
unicode_gen: unicode_gen.c cutils.c libunicode.c unicode_gen_def.h
293-
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ unicode_gen.c cutils.c
322+
unicode_gen: $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o libunicode.c unicode_gen_def.h
323+
$(HOST_CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o
294324

295325
clean:
296326
rm -f repl.c repl-bn.c qjscalc.c out.c
@@ -300,17 +330,17 @@ clean:
300330
rm -rf run-test262-debug run-test262-32 run-test262-bn32
301331

302332
install: all
303-
mkdir -p "$(prefix)/bin"
304-
install -m755 -s qjs qjsc qjsbn qjsbnc "$(prefix)/bin"
305-
ln -sf qjsbn "$(prefix)/bin/qjscalc"
306-
mkdir -p "$(prefix)/lib/quickjs"
307-
install -m755 libquickjs.a libquickjs.bn.a "$(prefix)/lib/quickjs"
333+
mkdir -p "$(DESTDIR)$(prefix)/bin"
334+
$(STRIP) qjs qjsbn qjsc qjsbnc
335+
install -m755 qjs qjsbn qjsc qjsbnc "$(DESTDIR)$(prefix)/bin"
336+
ln -sf qjsbn "$(DESTDIR)$(prefix)/bin/qjscalc"
337+
mkdir -p "$(DESTDIR)$(prefix)/lib/quickjs"
338+
install -m644 libquickjs.a libquickjs.bn.a "$(DESTDIR)$(prefix)/lib/quickjs"
308339
ifdef CONFIG_LTO
309-
install -m755 libquickjs.lto.a libquickjs.bn.lto.a "$(prefix)/lib/quickjs"
340+
install -m644 libquickjs.lto.a libquickjs.bn.lto.a "$(DESTDIR)$(prefix)/lib/quickjs"
310341
endif
311-
mkdir -p "$(prefix)/include/quickjs"
312-
install -m755 quickjs.h quickjs-libc.h "$(prefix)/include/quickjs"
313-
342+
mkdir -p "$(DESTDIR)$(prefix)/include/quickjs"
343+
install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(prefix)/include/quickjs"
314344

315345
###############################################################################
316346
# examples
@@ -319,10 +349,10 @@ endif
319349
HELLO_SRCS=examples/hello.js
320350
HELLO_OPTS=-fno-string-normalize -fno-map -fno-promise -fno-typedarray \
321351
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \
322-
-fno-date
352+
-fno-date -fno-module-loader
323353

324-
hello.c: qjsc $(HELLO_SRCS)
325-
./qjsc -e $(HELLO_OPTS) -o $@ $(HELLO_SRCS)
354+
hello.c: $(QJSC) $(HELLO_SRCS)
355+
$(QJSC) -e $(HELLO_OPTS) -o $@ $(HELLO_SRCS)
326356

327357
ifdef CONFIG_M32
328358
examples/hello: $(OBJDIR)/hello.m32s.o $(patsubst %.o, %.m32s.o, $(QJS_LIB_OBJS))
@@ -337,13 +367,13 @@ HELLO_MODULE_SRCS=examples/hello_module.js
337367
HELLO_MODULE_OPTS=-fno-string-normalize -fno-map -fno-promise -fno-typedarray \
338368
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \
339369
-fno-date -m
340-
examples/hello_module: qjsc libquickjs$(LTOEXT).a $(HELLO_MODULE_SRCS)
341-
./qjsc $(HELLO_MODULE_OPTS) -o $@ $(HELLO_MODULE_SRCS)
370+
examples/hello_module: $(QJSC) libquickjs$(LTOEXT).a $(HELLO_MODULE_SRCS)
371+
$(QJSC) $(HELLO_MODULE_OPTS) -o $@ $(HELLO_MODULE_SRCS)
342372

343373
# use of an external C module (static compilation)
344374

345-
c_module.c: qjsc examples/c_module.js
346-
./qjsc -e -M examples/fib.so,fib -m -o $@ examples/c_module.js
375+
c_module.c: $(QJSC) examples/c_module.js
376+
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/c_module.js
347377

348378
examples/c_module: $(OBJDIR)/c_module.o $(OBJDIR)/fib.o libquickjs$(LTOEXT).a
349379
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

TODO

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ REPL:
7575
Test262o: 0/11262 errors, 463 excluded
7676
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
7777

78-
Test262: 2/67303 errors, 839 excluded, 1390 skipped
79-
Test262bn: 2/69404 errors, 772 excluded, 403 skipped
80-
test262 commit: b63cdfd4f4a00f5fdb732778244d3456725f46c9
78+
Test262: 2/67351 errors, 839 excluded, 1370 skipped
79+
Test262bn: 2/69452 errors, 772 excluded, 383 skipped
80+
test262 commit: d65b9b35be091147edf31ec527a47cb95a327217

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2019-09-01
1+
2019-09-18

cutils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define unlikely(x) __builtin_expect(!!(x), 0)
3636
#define force_inline inline __attribute__((always_inline))
3737
#define no_inline __attribute__((noinline))
38+
#define __maybe_unused __attribute__((unused))
3839

3940
#define xglue(x, y) x ## y
4041
#define glue(x, y) xglue(x, y)

doc/quickjs.html

Lines changed: 73 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/quickjs.pdf

1.67 KB
Binary file not shown.

0 commit comments

Comments
 (0)