diff options
author | Ammar Faizi <ammar.faizi@students.amikom.ac.id> | 2021-10-10 20:53:38 +0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-10-10 09:09:56 -0600 |
commit | c7d03dc2c123bc2ee85582d8f922acd268d6ac78 (patch) | |
tree | f574898f74cf7a79cba1b8c5924759c70406828a | |
parent | f48ee3168cdc325233825603269f304d348d323c (diff) | |
download | liburing-c7d03dc2c123bc2ee85582d8f922acd268d6ac78.tar.gz liburing-c7d03dc2c123bc2ee85582d8f922acd268d6ac78.tar.bz2 |
configure: Add `CONFIG_NOLIBC` variable and macro
It's for conditonal variable and macro to enable nolibc build.
Also add `--nolibc` option to `configure` to enable it.
Link: https://github.com/axboe/liburing/issues/443
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Ammar Faizi <ammar.faizi@students.amikom.ac.id>
Link: https://lore.kernel.org/r/20211010135338.397115-4-ammar.faizi@students.amikom.ac.id
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rwxr-xr-x | configure | 9 | ||||
-rw-r--r-- | src/Makefile | 17 |
2 files changed, 25 insertions, 1 deletions
@@ -24,6 +24,8 @@ for opt do ;; --cxx=*) cxx="$optarg" ;; + --nolibc) liburing_nolibc="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -71,6 +73,7 @@ Options: [defaults in brackets after descriptions] --datadir=PATH install shared data in PATH [$datadir] --cc=CMD use CMD as the C compiler --cxx=CMD use CMD as the C++ compiler + --nolibc build liburing without libc EOF exit 0 fi @@ -358,6 +361,12 @@ print_config "has_memfd_create" "$has_memfd_create" ############################################################################# +if test "$liburing_nolibc" = "yes"; then + output_sym "CONFIG_NOLIBC" +else + liburing_nolibc="no" +fi +print_config "liburing_nolibc" "$liburing_nolibc" if test "$__kernel_rwf_t" = "yes"; then output_sym "CONFIG_HAVE_KERNEL_RWF_T" diff --git a/src/Makefile b/src/Makefile index 5e46a9d..09ff395 100644 --- a/src/Makefile +++ b/src/Makefile @@ -32,11 +32,22 @@ endif all: $(all_targets) -liburing_srcs := setup.c queue.c syscall.c register.c +liburing_srcs := setup.c queue.c register.c + +ifeq ($(CONFIG_NOLIBC),y) + liburing_srcs += nolibc.c + override CFLAGS += -nostdlib -nodefaultlibs -ffreestanding -fno-stack-protector + override CPPFLAGS += -nostdlib -nodefaultlibs -ffreestanding -fno-stack-protector + override LINK_FLAGS += -nostdlib -nodefaultlibs +else + liburing_srcs += syscall.c +endif liburing_objs := $(patsubst %.c,%.ol,$(liburing_srcs)) liburing_sobjs := $(patsubst %.c,%.os,$(liburing_srcs)) +$(liburing_srcs): syscall.h lib.h + $(liburing_objs) $(liburing_sobjs): include/liburing/io_uring.h %.os: %.c @@ -73,3 +84,7 @@ clean: @rm -f $(all_targets) $(liburing_objs) $(liburing_sobjs) $(soname).new @rm -f *.so* *.a *.o @rm -f include/liburing/compat.h + + @# When cleaning, we don't include ../config-host.mak, + @# so the nolibc objects are always skipped, clean them up! + @rm -f nolibc.ol nolibc.os |