* [PATCH liburing 1/2] examples/Makefile: Fix missing clean up
2021-10-30 15:55 [PATCH liburing 0/2] Fixes for Makefile Ammar Faizi
@ 2021-10-30 15:55 ` Ammar Faizi
2021-10-30 15:55 ` [PATCH liburing 2/2] test/Makefile: Refactor the Makefile Ammar Faizi
2021-10-31 22:30 ` [PATCH liburing 0/2] Fixes for Makefile Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2021-10-30 15:55 UTC (permalink / raw)
To: Jens Axboe; +Cc: Pavel Begunkov, io-uring Mailing List, Ammar Faizi
Several things go wrong with this Makefile:
1) Using `test_srcs` to generate `test_objs`.
2) `test_objs` is an unused variable. So (1) is pointless.
3) `make clean` does not remove `ucontext-cp` binary.
I assume (1) and (2) were blindly copied from the test Makefile.
For 3, the `make clean` removes $(all_targets) and $(test_objs). But
`ucontext-cp` only exists in $(all_targets) if we have
`CONFIG_HAVE_UCONTEXT`. When the target goal is `clean`, we will not
have any of `CONFIG_*` variables. Thus, `ucontext-cp` is not removed.
Clean them up!
Signed-off-by: Ammar Faizi <[email protected]>
---
examples/Makefile | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/examples/Makefile b/examples/Makefile
index d3c5000..f966f94 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -10,20 +10,29 @@ ifneq ($(MAKECMDGOALS),clean)
include ../config-host.mak
endif
-all_targets += io_uring-test io_uring-cp link-cp
+example_srcs := \
+ io_uring-cp.c \
+ io_uring-test.c \
+ link-cp.c
+
+all_targets :=
+
ifdef CONFIG_HAVE_UCONTEXT
-all_targets += ucontext-cp
+ example_srcs += ucontext-cp.c
endif
+all_targets += ucontext-cp
-all: $(all_targets)
+example_targets := $(patsubst %.c,%,$(patsubst %.cc,%,$(example_srcs)))
+all_targets += $(example_targets)
-test_srcs := io_uring-test.c io_uring-cp.c link-cp.c
-test_objs := $(patsubst %.c,%.ol,$(test_srcs))
+all: $(example_targets)
%: %.c
$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)
clean:
- @rm -f $(all_targets) $(test_objs)
+ @rm -f $(all_targets)
+
+.PHONY: all clean
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH liburing 2/2] test/Makefile: Refactor the Makefile
2021-10-30 15:55 [PATCH liburing 0/2] Fixes for Makefile Ammar Faizi
2021-10-30 15:55 ` [PATCH liburing 1/2] examples/Makefile: Fix missing clean up Ammar Faizi
@ 2021-10-30 15:55 ` Ammar Faizi
2021-10-31 22:30 ` [PATCH liburing 0/2] Fixes for Makefile Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2021-10-30 15:55 UTC (permalink / raw)
To: Jens Axboe; +Cc: Pavel Begunkov, io-uring Mailing List, Ammar Faizi
The Makefile for test is not efficient and reads bad. We have to
specify the name for each test 2 times (filename and name without
the ext) while we could have just elided the extension from the
source filename.
Let's make it simpler and easier to manage.
Changes summary:
- Clean up and reorder things.
- Sort the `test_srcs` alphabetically.
- Remove `test_objs` (it turned out unused).
- Generate `test_targets` variable from `test_srcs` by simply
removing the `.c` and `.cc` file extension.
Signed-off-by: Ammar Faizi <[email protected]>
---
test/Makefile | 263 ++++++++++++++++----------------------------------
1 file changed, 83 insertions(+), 180 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index 1a10a24..f7eafad 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -8,177 +8,32 @@ include ../config-host.mak
endif
CPPFLAGS ?=
-override CPPFLAGS += -D_GNU_SOURCE -D__SANE_USERSPACE_TYPES__ \
- -I../src/include/ -include ../config-host.h
-CFLAGS ?= -g -O2 -Wall -Wextra
+override CPPFLAGS += \
+ -D_GNU_SOURCE \
+ -D__SANE_USERSPACE_TYPES__ \
+ -I../src/include/ \
+ -include ../config-host.h
+
+CFLAGS ?= -g -O2 -Wall -Wextra
XCFLAGS = -Wno-unused-parameter -Wno-sign-compare
+
ifdef CONFIG_HAVE_STRINGOP_OVERFLOW
- XCFLAGS += -Wstringop-overflow=0
+ XCFLAGS += -Wstringop-overflow=0
endif
+
ifdef CONFIG_HAVE_ARRAY_BOUNDS
- XCFLAGS += -Warray-bounds=0
+ XCFLAGS += -Warray-bounds=0
endif
CXXFLAGS ?= $(CFLAGS)
override CFLAGS += $(XCFLAGS) -DLIBURING_BUILD_TEST
override CXXFLAGS += $(XCFLAGS) -std=c++11 -DLIBURING_BUILD_TEST
+
LDFLAGS ?=
override LDFLAGS += -L../src/ -luring
-test_targets += \
- 232c93d07b74-test \
- 35fa71a030ca-test \
- 500f9fbadef8-test \
- 7ad0e4b2f83c-test \
- 8a9973408177-test \
- 917257daa0fe-test \
- a0908ae19763-test \
- a4c0b3decb33-test \
- accept \
- accept-link \
- accept-reuse \
- accept-test \
- across-fork splice \
- b19062a56726-test \
- b5837bd5311d-test \
- ce593a6c480a-test \
- close-opath \
- connect \
- cq-full \
- cq-overflow \
- cq-peek-batch \
- cq-ready \
- cq-size \
- d4ae271dfaae-test \
- d77a67ed5f27-test \
- defer \
- double-poll-crash \
- eeed8b54e0df-test \
- empty-eownerdead \
- eventfd \
- eventfd-disable \
- eventfd-ring \
- fadvise \
- fallocate \
- fc2a85cb02ef-test \
- file-register \
- file-verify \
- file-update \
- files-exit-hang-poll \
- files-exit-hang-timeout \
- fixed-link \
- fsync \
- hardlink \
- io-cancel \
- io_uring_enter \
- io_uring_register \
- io_uring_setup \
- iopoll \
- lfs-openat \
- lfs-openat-write \
- link \
- link-timeout \
- link_drain \
- madvise \
- mkdir \
- multicqes_drain \
- nop \
- nop-all-sizes \
- open-close \
- openat2 \
- personality \
- pipe-eof \
- pipe-reuse \
- poll \
- poll-cancel \
- poll-cancel-ton \
- poll-link \
- poll-many \
- poll-mshot-update \
- poll-ring \
- poll-v-poll \
- probe \
- read-write \
- register-restrictions \
- rename \
- ring-leak \
- ring-leak2 \
- rw_merge_test \
- self \
- send_recv \
- send_recvmsg \
- shared-wq \
- short-read \
- shutdown \
- sigfd-deadlock \
- socket-rw \
- socket-rw-eagain \
- sq-full \
- sq-poll-dup \
- sq-poll-kthread \
- sq-poll-share \
- sqpoll-disable-exit \
- sqpoll-exit-hang \
- sqpoll-cancel-hang \
- sqpoll-sleep \
- sq-space_left \
- stdout \
- submit-reuse \
- submit-link-fail \
- symlink \
- teardowns \
- thread-exit \
- timeout \
- timeout-new \
- timeout-overflow \
- unlink \
- wakeup-hang \
- sendmsg_fs_cve \
- rsrc_tags \
- exec-target \
- # EOL
-
-all_targets += $(test_targets)
-
-include ../Makefile.quiet
-
-ifdef CONFIG_HAVE_STATX
-test_targets += statx
-endif
-all_targets += statx
-
-ifdef CONFIG_HAVE_CXX
-test_targets += sq-full-cpp
-endif
-all_targets += sq-full-cpp
-
-#
-# Build ../src/syscall.c manually from test's Makefile to support
-# liburing nolibc.
-#
-# Functions in ../src/syscall.c require libc to work with, if we
-# build liburing without libc, we don't have those functions
-# in liburing.a. So build it manually here.
-#
-helpers = helpers.o ../src/syscall.o
-
-all: ${helpers} $(test_targets)
-
-../src/syscall.o: ../src/syscall.c
- $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-
-helpers.o: helpers.c
- $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-
-%: %.c ${helpers} helpers.h
- $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< ${helpers} $(LDFLAGS)
-
-%: %.cc ${helpers} helpers.h
- $(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< ${helpers} $(LDFLAGS)
-
test_srcs := \
- helpers.c \
232c93d07b74-test.c \
35fa71a030ca-test.c \
500f9fbadef8-test.c \
@@ -187,10 +42,10 @@ test_srcs := \
917257daa0fe-test.c \
a0908ae19763-test.c \
a4c0b3decb33-test.c \
+ accept.c \
accept-link.c \
accept-reuse.c \
accept-test.c \
- accept.c \
across-fork.c \
b19062a56726-test.c \
b5837bd5311d-test.c \
@@ -200,7 +55,7 @@ test_srcs := \
cq-full.c \
cq-overflow.c \
cq-peek-batch.c \
- cq-ready.c\
+ cq-ready.c \
cq-size.c \
d4ae271dfaae-test.c \
d77a67ed5f27-test.c \
@@ -208,56 +63,60 @@ test_srcs := \
double-poll-crash.c \
eeed8b54e0df-test.c \
empty-eownerdead.c \
+ eventfd.c \
eventfd-disable.c \
eventfd-ring.c \
- eventfd.c \
+ exec-target.c \
fadvise.c \
fallocate.c \
fc2a85cb02ef-test.c \
file-register.c \
- file-verify.c \
- file-update.c \
files-exit-hang-poll.c \
files-exit-hang-timeout.c \
+ file-update.c \
+ file-verify.c \
fixed-link.c \
fsync.c \
hardlink.c \
io-cancel.c \
+ iopoll.c \
io_uring_enter.c \
io_uring_register.c \
io_uring_setup.c \
- iopoll.c \
- lfs-openat-write.c \
lfs-openat.c \
- link-timeout.c \
+ lfs-openat-write.c \
link.c \
link_drain.c \
+ link-timeout.c \
madvise.c \
mkdir.c \
multicqes_drain.c \
nop-all-sizes.c \
nop.c \
- open-close.c \
openat2.c \
+ open-close.c \
personality.c \
pipe-eof.c \
pipe-reuse.c \
- poll-cancel-ton.c \
+ poll.c \
poll-cancel.c \
+ poll-cancel-ton.c \
poll-link.c \
poll-many.c \
poll-mshot-update.c \
poll-ring.c \
poll-v-poll.c \
- poll.c \
probe.c \
read-write.c \
register-restrictions.c \
rename.c \
- ring-leak.c \
ring-leak2.c \
+ ring-leak.c \
+ rsrc_tags.c \
rw_merge_test.c \
self.c \
+ sendmsg_fs_cve.c \
+ send_recv.c \
send_recvmsg.c \
shared-wq.c \
short-read.c \
@@ -266,34 +125,74 @@ test_srcs := \
socket-rw.c \
socket-rw-eagain.c \
splice.c \
- sq-full-cpp.cc \
sq-full.c \
+ sq-full-cpp.cc \
+ sqpoll-cancel-hang.c \
+ sqpoll-disable-exit.c \
sq-poll-dup.c \
+ sqpoll-exit-hang.c \
sq-poll-kthread.c \
sq-poll-share.c \
- sqpoll-disable-exit.c \
- sqpoll-exit-hang.c \
- sqpoll-cancel-hang.c \
sqpoll-sleep.c \
sq-space_left.c \
statx.c \
stdout.c \
- submit-reuse.c \
submit-link-fail.c \
+ submit-reuse.c \
symlink.c \
teardowns.c \
thread-exit.c \
+ timeout.c \
timeout-new.c \
timeout-overflow.c \
- timeout.c \
unlink.c \
wakeup-hang.c \
- sendmsg_fs_cve.c \
- rsrc_tags.c \
- exec-target.c \
# EOL
-test_objs := $(patsubst %.c,%.ol,$(patsubst %.cc,%.ol,$(test_srcs)))
+
+all_targets :=
+include ../Makefile.quiet
+
+
+ifdef CONFIG_HAVE_STATX
+ test_srcs += statx.c
+endif
+all_targets += statx
+
+
+ifdef CONFIG_HAVE_CXX
+ test_srcs += sq-full-cpp.cc
+endif
+all_targets += sq-full-cpp
+
+
+test_targets := $(patsubst %.c,%,$(patsubst %.cc,%,$(test_srcs)))
+all_targets += $(test_targets)
+
+#
+# Build ../src/syscall.c manually from test's Makefile to support
+# liburing nolibc.
+#
+# Functions in ../src/syscall.c require libc to work with, if we
+# build liburing without libc, we don't have those functions
+# in liburing.a. So build it manually here.
+#
+helpers = helpers.o ../src/syscall.o
+
+all: $(test_targets)
+
+../src/syscall.o: ../src/syscall.c
+ $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
+
+helpers.o: helpers.c
+ $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
+
+%: %.c $(helpers) helpers.h
+ $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
+
+%: %.cc $(helpers) helpers.h
+ $(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
+
35fa71a030ca-test: override LDFLAGS += -lpthread
232c93d07b74-test: override LDFLAGS += -lpthread
@@ -317,11 +216,15 @@ install: $(test_targets) runtests.sh runtests-loop.sh
$(INSTALL) -D -m 755 $(test_targets) $(datadir)/liburing-test/
$(INSTALL) -D -m 755 runtests.sh $(datadir)/liburing-test/
$(INSTALL) -D -m 755 runtests-loop.sh $(datadir)/liburing-test/
+
clean:
- @rm -f $(all_targets) $(test_objs) helpers.o output/*
+ @rm -f $(all_targets) helpers.o output/*
@rm -rf output/
runtests: all
@./runtests.sh $(test_targets)
+
runtests-loop: all
@./runtests-loop.sh $(test_targets)
+
+.PHONY: all install clean runtests runtests-loop
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread