Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lang/quickjs: Build shared libraries
PR: 274681 Reported by: Robert Clausecker <fuz@FreeBSD.org>
- Loading branch information
Showing
7 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- Makefile.orig 2023-10-23 23:26:12 UTC | ||
+++ Makefile | ||
@@ -76,6 +76,7 @@ ifdef CONFIG_CLANG | ||
HOST_CC=clang | ||
CC=$(CROSS_PREFIX)clang | ||
CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d | ||
+ CFLAGS += -fPIC | ||
CFLAGS += -Wextra | ||
CFLAGS += -Wno-sign-compare | ||
CFLAGS += -Wno-missing-field-initializers | ||
@@ -156,9 +157,9 @@ endif | ||
ifdef CONFIG_M32 | ||
PROGS+=qjs32 qjs32_s | ||
endif | ||
-PROGS+=libquickjs.a | ||
+PROGS+=libquickjs.so | ||
ifdef CONFIG_LTO | ||
-PROGS+=libquickjs.lto.a | ||
+PROGS+=libquickjs.lto.so | ||
endif | ||
|
||
# examples | ||
@@ -235,12 +236,12 @@ else | ||
LTOEXT= | ||
endif | ||
|
||
-libquickjs$(LTOEXT).a: $(QJS_LIB_OBJS) | ||
- $(AR) rcs $@ $^ | ||
+libquickjs$(LTOEXT).so: $(QJS_LIB_OBJS) | ||
+ $(CC) -shared $(LDFLAGS) -o $@ $^ | ||
|
||
ifdef CONFIG_LTO | ||
-libquickjs.a: $(patsubst %.o, %.nolto.o, $(QJS_LIB_OBJS)) | ||
- $(AR) rcs $@ $^ | ||
+libquickjs.so: $(patsubst %.o, %.nolto.o, $(QJS_LIB_OBJS)) | ||
+ $(CC) -shared $(LDFLAGS) -o $@ $^ | ||
endif # CONFIG_LTO | ||
|
||
repl.c: $(QJSC) repl.js | ||
@@ -311,10 +312,10 @@ install: all | ||
$(STRIP) qjs qjsc | ||
install -m755 qjs qjsc "$(DESTDIR)$(prefix)/bin" | ||
ln -sf qjs "$(DESTDIR)$(prefix)/bin/qjscalc" | ||
- mkdir -p "$(DESTDIR)$(prefix)/lib/quickjs" | ||
- install -m644 libquickjs.a "$(DESTDIR)$(prefix)/lib/quickjs" | ||
+ mkdir -p "$(DESTDIR)$(prefix)/lib" | ||
+ install -m644 libquickjs.so "$(DESTDIR)$(prefix)/lib" | ||
ifdef CONFIG_LTO | ||
- install -m644 libquickjs.lto.a "$(DESTDIR)$(prefix)/lib/quickjs" | ||
+ install -m644 libquickjs.lto.so "$(DESTDIR)$(prefix)/lib" | ||
endif | ||
mkdir -p "$(DESTDIR)$(prefix)/include/quickjs" | ||
install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(prefix)/include/quickjs" | ||
@@ -347,7 +348,7 @@ HELLO_MODULE_SRCS=examples/hello_module.js | ||
HELLO_MODULE_OPTS=-fno-string-normalize -fno-map -fno-promise -fno-typedarray \ | ||
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \ | ||
-fno-date -m | ||
-examples/hello_module: $(QJSC) libquickjs$(LTOEXT).a $(HELLO_MODULE_SRCS) | ||
+examples/hello_module: $(QJSC) libquickjs$(LTOEXT).so $(HELLO_MODULE_SRCS) | ||
$(QJSC) $(HELLO_MODULE_OPTS) -o $@ $(HELLO_MODULE_SRCS) | ||
|
||
# use of an external C module (static compilation) | ||
@@ -355,7 +356,7 @@ examples/hello_module: $(QJSC) libquickjs$(LTOEXT).a $ | ||
test_fib.c: $(QJSC) examples/test_fib.js | ||
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/test_fib.js | ||
|
||
-examples/test_fib: $(OBJDIR)/test_fib.o $(OBJDIR)/examples/fib.o libquickjs$(LTOEXT).a | ||
+examples/test_fib: $(OBJDIR)/test_fib.o $(OBJDIR)/examples/fib.o libquickjs$(LTOEXT).so | ||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) | ||
|
||
examples/fib.so: $(OBJDIR)/examples/fib.pic.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- qjsc.c.orig 2023-10-23 23:25:39 UTC | ||
+++ qjsc.c | ||
@@ -446,7 +446,7 @@ static int output_executable(const char *out_filename, | ||
if (dynamic_export) | ||
*arg++ = "-rdynamic"; | ||
*arg++ = cfilename; | ||
- snprintf(libjsname, sizeof(libjsname), "%s/libquickjs%s%s.a", | ||
+ snprintf(libjsname, sizeof(libjsname), "%s/libquickjs%s%s.so", | ||
lib_dir, bn_suffix, lto_suffix); | ||
*arg++ = libjsname; | ||
*arg++ = "-lm"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters