-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,18 @@ OBJCOPY := llvm-objcopy${LLVM_SURFFIX} | |
AR := llvm-ar${LLVM_SURFFIX} | ||
RANLIB := llvm-ranlib${LLVM_SURFFIX} | ||
|
||
CFLAGS := -fPIC -O3 -fno-builtin -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I lualib -I include/ckb-c-stdlib -I include/ckb-c-stdlib/libc -I include/ckb-c-stdlib/molecule -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -g | ||
CFLAGS := --target=riscv64 -march=rv64imc_zba_zbb_zbc_zbs | ||
CFLAGS += -D__ISO_C_VISIBLE=1999 -DCKB_DECLARATION_ONLY -fPIC -g -O3 | ||
CFLAGS += -fno-builtin-printf -fno-builtin-memcmp \ | ||
-nostdinc -nostdlib\ | ||
-fdata-sections -ffunction-sections | ||
|
||
LDFLAGS := -nostdlib -nostartfiles -fno-builtin -Wl,-static -fdata-sections -ffunction-sections -Wl,--gc-sections | ||
CFLAGS += -I lualib -I lualib/c-stdlib -I include/ckb-c-stdlib -I include/ckb-c-stdlib/libc -I include/ckb-c-stdlib/molecule | ||
CFLAGS += -I deps/compiler-rt-builtins-riscv/compiler-rt/lib/builtins | ||
CFLAGS += -Wall -Werror -Wno-error=unused-command-line-argument -Wno-error=incompatible-library-redeclaration -Wno-error=invalid-noreturn -Wno-error=unused-function | ||
|
||
LDFLAGS := -static --gc-sections | ||
LDFLAGS += -Ldeps/compiler-rt-builtins-riscv/build -lcompiler-rt | ||
|
||
DOCKER_USER := $(shell id -u):$(shell id -g) | ||
DOCKER_EXTRA_FLAGS ?= | ||
|
@@ -32,6 +41,10 @@ docker-interactive: | |
deps/compiler-rt-builtins-riscv/build/libcompiler-rt.a: | ||
cd deps/compiler-rt-builtins-riscv && $(MAKE) CC=$(CC) LD=$(LD) OBJCOPY=$(OBJCOPY) AR=$(AR) RANLIB=$(RANLIB) | ||
|
||
build/impl.o: include/ckb-c-stdlib/libc/src/impl.c | ||
@echo $(CC) $(filter-out -DCKB_DECLARATION_ONLY, $(CFLAGS)) -c -o $@ $< | ||
@$(CC) $(filter-out -DCKB_DECLARATION_ONLY, $(CFLAGS)) -c -o $@ $< | ||
|
||
lualib/liblua.a: | ||
make -C lualib liblua.a | ||
|
||
|
@@ -51,8 +64,8 @@ build/lua-loader.o: lua-loader/lua-loader.c | |
# Note when -nostdlib is specified, libgcc is not linked to the program automatically. | ||
# Also note libgcc.a must be appended to the file list, simply -lgcc does not for some reason. | ||
# It seems gcc does not search libgcc in the install path. | ||
build/lua-loader: build/lua-loader.o lualib/liblua.a | ||
$(LD) $(LDFLAGS) -o $@ $^ $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a | ||
build/lua-loader: build/lua-loader.o build/impl.o lualib/liblua.a deps/compiler-rt-builtins-riscv/build/libcompiler-rt.a | ||
$(LD) $(LDFLAGS) -o $@ $^ | ||
cp $@ [email protected] | ||
$(OBJCOPY) --strip-debug --strip-all $@ | ||
|
||
|