From 1829ca47d47a278688778edf7d72448066a9c980 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Thu, 4 Apr 2019 13:46:09 +0800 Subject: [PATCH] Make nginx compile on 32bit platform, fix bitcuit on riscv Signed-off-by: Harry Chen --- Makefile | 4 ---- README.md | 4 ++-- biscuit/CMakeLists.txt | 3 +-- nginx/Makefile | 3 ++- redis/Makefile | 1 + 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 7c82aff..5626ef5 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,6 @@ ifneq ($(arch), x86_64) endif biscuit: -ifeq ($(arch), $(filter $(arch), x86_64 aarch64 riscv64 mipsel)) ifneq ($(shell uname)-$(arch), Darwin-riscv64) @echo Building biscuit programs @mkdir -p biscuit/build @@ -54,7 +53,6 @@ ifneq ($(shell uname)-$(arch), Darwin-riscv64) @rm -rf $(out_dir)/biscuit && mkdir -p $(out_dir)/biscuit @cp $(biscuit_bin_path)/* $(out_dir)/biscuit endif -endif $(busybox): ifeq ($(arch), x86_64) @@ -75,7 +73,6 @@ endif busybox: $(busybox) nginx: -ifneq ($(arch), riscv32) ifneq ($(shell uname), Darwin) @echo Building nginx mkdir -p $(out_dir)/usr/local/nginx/conf @@ -84,7 +81,6 @@ ifneq ($(shell uname), Darwin) @cp nginx/build/$(arch)/nginx $(out_dir) @cp nginx/nginx.conf $(out_dir)/usr/local/nginx/conf endif -endif redis: ifneq ($(shell uname), Darwin) diff --git a/README.md b/README.md index a1230a3..cb59801 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ A rootfs is created at `build/$(arch)` and converted to `qcow2`. | ------------------ | ------ | ------- | ------- | ------- | ------ | | ucore | ❌ | ✅ | ✅ | ✅ | ✅ | | rust | ✅ | ✅ | ✅ | ✅ | ✅ | -| biscuit | ✅ | ✅ | ❌ | ✅ | ✅ | -| nginx (linux only) | ✅ | ✅ | 🚧 | ✅ | 🚧 | +| biscuit | ✅ | ✅ | ✅ | ✅ | ✅ | +| nginx (linux only) | ✅ | ✅ | ✅ | ✅ | ✅ | | redis (linux only) | ✅ | ✅ | ✅ | ✅ | ✅ | | busybox | ✅ | ✅ | ❌ | ✅ | 🚧 | | alpine rootfs | ✅ | ✅ | ❌ | ❌ | ❌ | diff --git a/biscuit/CMakeLists.txt b/biscuit/CMakeLists.txt index 31df56a..30a518d 100644 --- a/biscuit/CMakeLists.txt +++ b/biscuit/CMakeLists.txt @@ -29,8 +29,7 @@ set(PREFIX ${ARCH}-linux-musl-) if (${ARCH} STREQUAL x86_64) set(CMAKE_C_FLAGS "-m64 -mno-red-zone") elseif (${ARCH} STREQUAL riscv32) - set(PREFIX riscv64-unknown-elf-) - set(CMAKE_C_FLAGS "-march=rv32imac -mabi=ilp32 -mcmodel=medany") + set(CMAKE_C_FLAGS "-march=rv32imafdc -mabi=ilp32d -mcmodel=medany") elseif (${ARCH} STREQUAL riscv64) set(CMAKE_C_FLAGS "-march=rv64imafdc -mabi=lp64d -mcmodel=medany") elseif (${ARCH} STREQUAL aarch64) diff --git a/nginx/Makefile b/nginx/Makefile index ca8e62c..efe57d9 100644 --- a/nginx/Makefile +++ b/nginx/Makefile @@ -23,7 +23,8 @@ $(nginx_dir)/objs/nginx: $(nginx_dir) cd $(nginx_dir) && ./configure --with-cc=$(cc) --with-cc-opt=-static --with-ld-opt=-static --without-pcre --without-http_rewrite_module --without-http_gzip_module --with-poll_module --without-http_upstream_zone_module cd $(nginx_dir) && printf "#ifndef NGX_SYS_NERR\n#define NGX_SYS_NERR 132\n#endif\n" >> objs/ngx_auto_config.h cd $(nginx_dir) && printf "#ifndef NGX_HAVE_SVSVSHM\n#define NGX_HAVE_SYSVSHM 1\n#endif\n" >> objs/ngx_auto_config.h - cd $(nginx_dir) && make + # FIXME: overflow will occur on 32-bit platforms, this is only a temporary workaround + cd $(nginx_dir) && make CFLAGS="${CFLGAS} -Wno-error=overflow" $(bin_unstripped): $(nginx_dir)/objs/nginx cp $(nginx_dir)/objs/nginx $(bin_unstripped) diff --git a/redis/Makefile b/redis/Makefile index 96e3245..dd82ade 100644 --- a/redis/Makefile +++ b/redis/Makefile @@ -25,6 +25,7 @@ $(redis_dir)/src/redis-server: $(redis_dir)/src/config.h sed -i 's/#define HAVE_EPOLL 1//' $(redis_dir)/src/config.h # our accept does not have backlog sed -i 's/#define MAX_ACCEPTS_PER_CALL 1000/#define MAX_ACCEPTS_PER_CALL 1/' $(redis_dir)/src/networking.c + # note: on some platforms gcc seems to forget linking with libatomic, fix it anyway cd $(redis_dir) && make CC=$(cc) LDFLAGS="${LDFLAGS} -latomic" MALLOC=libc $(bin_server_unstripped): $(redis_dir)/src/redis-server