shared library build
This commit is contained in:
parent
9d97c20c38
commit
e92dce58fb
3
.gitignore
vendored
3
.gitignore
vendored
@ -12,4 +12,7 @@ perf.*
|
||||
CBQNHeapDump
|
||||
/test/ffi/ffiTest.o
|
||||
/test/ffi/test.got
|
||||
/test/ffi/shared.got
|
||||
/test/ffi/sharedTest
|
||||
/test/ffi/lib.so
|
||||
libcbqn.so
|
||||
|
||||
12
makefile
12
makefile
@ -33,6 +33,10 @@ wasi-o3:
|
||||
@${MAKE} i_singeli=0 i_t=wasi_o3 OUTPUT=BQN.wasm i_f="-DWASM -DWASI -DNO_MMAP -O3 -DCATCH_ERRORS=0 -D_WASI_EMULATED_MMAN --target=wasm32-wasi" i_lf="-lwasi-emulated-mman --target=wasm32-wasi -Wl,-z,stack-size=8388608 -Wl,--initial-memory=67108864" i_LD_LIBS= i_PIE= i_FFI=0 run_incremental_0
|
||||
emcc-o3:
|
||||
@${MAKE} i_singeli=0 i_t=emcc_o3 OUTPUT=BQN.js CC=emcc i_f='-DWASM -DEMCC -O3' i_lf='-s EXPORTED_FUNCTIONS=_main,_cbqn_runLine,_cbqn_evalSrc -s EXPORTED_RUNTIME_METHODS=ccall,cwrap -s ALLOW_MEMORY_GROWTH=1' i_FFI=0 run_incremental_0
|
||||
shared-o3:
|
||||
@${MAKE} OUTPUT=libcbqn.so i_SHARED=1 i_t=shared_o3 i_f="-O3" run_incremental_0
|
||||
shared-c:
|
||||
@${MAKE} OUTPUT=libcbqn.so i_SHARED=1 custom=1 run_incremental_0
|
||||
c:
|
||||
@${MAKE} custom=1 run_incremental_0
|
||||
|
||||
@ -44,6 +48,12 @@ i_FFI := 2
|
||||
i_singeli := 0
|
||||
OUTPUT := BQN
|
||||
|
||||
ifeq ($(i_SHARED),1)
|
||||
i_PIE := -shared
|
||||
SHARED_CCFLAGS := -fPIC -DCBQN_SHARED
|
||||
else
|
||||
SHARED_CCFLAGS :=
|
||||
endif
|
||||
ifeq ($(origin CC),command line)
|
||||
i_CC := $(CC)
|
||||
custom = 1
|
||||
@ -94,7 +104,7 @@ else
|
||||
NOWARN = -Wno-parentheses
|
||||
endif
|
||||
|
||||
ALL_CC_FLAGS = -std=gnu11 -Wall -Wno-unused-function -fms-extensions $(CCFLAGS) $(f) $(i_f) $(NOWARN) -DSINGELI=$(i_singeli) -DFFI=$(i_FFI)
|
||||
ALL_CC_FLAGS = -std=gnu11 -Wall -Wno-unused-function -fms-extensions $(CCFLAGS) $(f) $(i_f) $(NOWARN) -DSINGELI=$(i_singeli) -DFFI=$(i_FFI) $(SHARED_CCFLAGS)
|
||||
ALL_LD_FLAGS = $(LDFLAGS) $(lf) $(i_lf) $(i_PIE) $(i_LD_LIBS)
|
||||
|
||||
ifneq (${manualJobs},1)
|
||||
|
||||
@ -269,7 +269,7 @@ void cbqn_evalSrc(char* src, i64 len) {
|
||||
int main() {
|
||||
repl_init();
|
||||
}
|
||||
#else
|
||||
#elif !CBQN_SHARED
|
||||
int main(int argc, char* argv[]) {
|
||||
repl_init();
|
||||
bool startREPL = argc==1;
|
||||
|
||||
@ -1,7 +1,20 @@
|
||||
test: build
|
||||
test: testLib testShared
|
||||
|
||||
|
||||
|
||||
testShared: buildShared
|
||||
@LD_LIBRARY_PATH=../../ ./sharedTest > shared.got
|
||||
@diff --color -su shared.expected shared.got
|
||||
|
||||
buildShared:
|
||||
$(CC) sharedTest.c -o sharedTest -L../.. -lcbqn
|
||||
|
||||
|
||||
|
||||
testLib: buildLib
|
||||
@../../BQN test.bqn > test.got
|
||||
@diff --color -su test.expected test.got
|
||||
|
||||
build:
|
||||
buildLib:
|
||||
$(CC) -O3 -g -c -fpic ffiTest.c -o ffiTest.o
|
||||
$(CC) -shared -olib.so ffiTest.o
|
||||
1
test/ffi/shared.expected
Normal file
1
test/ffi/shared.expected
Normal file
@ -0,0 +1 @@
|
||||
4
|
||||
9
test/ffi/sharedTest.c
Normal file
9
test/ffi/sharedTest.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../../include/bqnffi.h"
|
||||
|
||||
int main() {
|
||||
bqn_init();
|
||||
double res = bqn_toF64(bqn_evalCStr("2+2"));
|
||||
printf("%g\n", res);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user