Skip to contentSkip to conversation

Changes for Makefile

PATCH Superseded Alviro Iskandar Setiawan 2 participants 7 messages Mar 10, 2022 io_uring

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Changes for Makefile

Hello sir,

This patchset (v2) changes Makefile. 4 patches here:

1. Remove -fomit-frame-pointer flag, because it's already covered by the -O2 optimization flag.

2. When the header files are modified, the compiled objects are not going to be recompiled because the header files are not marked as a dependency for the objects.

- Instruct the compiler to generate dependency files.

- Include those files from src/Makefile. Ensure if any changes are made, files that depend on the changes are recompiled.

3. The test binaries statically link liburing using liburing.a file. When liburing.a is recompiled, make sure the tests are also recompiled to ensure changes are applied to the test binary. It makes "make clean" command optional when making changes.

4. Same as no. 3, but for examples.

please review,
thx

link v1: https://lore.kernel.org/io-uring/[email protected]/
v1 -> v2:
- Instruct the compiler to generate dependency files instead
of hard code it in the Makefile.
- Add liburing.a to dependency for test (patch 3).
- Add liburing.a to dependency for examples (patch 4).

---

Alviro Iskandar Setiawan (4):
src/Makefile: Remove -fomit-frame-pointer from default build src/Makefile: Add header files as dependency test/Makefile: Add liburing.a as a dependency examples/Makefile: Add liburing.a as a dependency

 examples/Makefile |  2 +-
 src/Makefile      | 13 ++++++-------
 test/Makefile     |  4 ++--
 3 files changed, 9 insertions(+), 10 deletions(-)

base-commit: 6231f56da7881bde6fb011e1b54d672f8fe5a224

Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/4 src/Makefile: Remove `-fomit-frame-pointer` from default build

-fomit-frame-pointer is already turned on by -O1 optimization flag.

The liburing default compilation uses -O2 optimization, -O2 turns on all optimization flags specified by -O1. Therefore, we don't need to specify -fomit-frame-pointer here. Remove it.

---
 src/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/Makefile +1 -1
index 3e1192f..f19d45e 100644
@@ -8,7 +8,7 @@ libdevdir ?= $(prefix)/lib
 CPPFLAGS ?=
 override CPPFLAGS += -D_GNU_SOURCE \
 	-Iinclude/ -include ../config-host.h
-CFLAGS ?= -g -fomit-frame-pointer -O2 -Wall -Wextra -fno-stack-protector
+CFLAGS ?= -g -O2 -Wall -Wextra -fno-stack-protector
 override CFLAGS += -Wno-unused-parameter -Wno-sign-compare -DLIBURING_INTERNAL
 SO_CFLAGS=-fPIC $(CFLAGS)
 L_CFLAGS=$(CFLAGS)
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/4 src/Makefile: Add header files as dependency

In reply to Alviro Iskandar Setiawan

When the header files are modified, the compiled objects are not going to be recompiled because the header files are not marked as a dependency for the objects.

- Instruct the compiler to generate dependency files.

- Include those files from src/Makefile. Ensure if any changes are made, files that depend on the changes are recompiled.

---
 src/Makefile | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
src/Makefile +5 -6
index f19d45e..bb165fa 100644
@@ -43,19 +43,20 @@ else
 	liburing_srcs += syscall.c
 endif
 
+override CPPFLAGS += -MT "$@" -MMD -MP -MF "[email protected]"
 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
 	$(QUIET_CC)$(CC) $(CPPFLAGS) $(SO_CFLAGS) -c -o $@ $<
 
 %.ol: %.c
 	$(QUIET_CC)$(CC) $(CPPFLAGS) $(L_CFLAGS) -c -o $@ $<
 
+# Include compiler generated dependency files.
+-include $(liburing_objs:%=%.d)
+-include $(liburing_sobjs:%=%.d)
+
 AR ?= ar
 RANLIB ?= ranlib
 liburing.a: $(liburing_objs)
@@ -78,8 +79,6 @@ ifeq ($(ENABLE_SHARED),1)
 	ln -sf $(relativelibdir)$(libname) $(libdevdir)/liburing.so
 endif
 
-$(liburing_objs): include/liburing.h
-
 clean:
 	@rm -f $(all_targets) $(liburing_objs) $(liburing_sobjs) $(soname).new
 	@rm -f *.so* *.a *.o
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH liburing v2 2/4] src/Makefile: Add header files as dependency

Quoted 11 lines · Alviro Iskandar Setiawan

When the header files are modified, the compiled objects are not going to be recompiled because the header files are not marked as a dependency for the objects.

- Instruct the compiler to generate dependency files.

- Include those files from src/Makefile. Ensure if any changes are made, files that depend on the changes are recompiled.

You should add the dependency files to .gitignore, otherwise we will have these files untracked after build.

Untracked files:
(use "git add <file>..." to include in what will be committed)
src/queue.ol.d
src/queue.os.d
src/register.ol.d
src/register.os.d
src/setup.ol.d
src/setup.os.d
src/syscall.ol.d
src/syscall.os.d

Also, when doing make clean, the dependency files should be removed.

Signature · 1 line
Ammar Faizi
#4 lore raw

Re: [PATCH liburing v2 2/4] src/Makefile: Add header files as dependency

Quoted 14 lines · Ammar Faizi

You should add the dependency files to .gitignore, otherwise we will have these files untracked after build.

Untracked files:
(use "git add <file>..." to include in what will be committed)
src/queue.ol.d
src/queue.os.d
src/register.ol.d
src/register.os.d
src/setup.ol.d
src/setup.os.d
src/syscall.ol.d
src/syscall.os.d

Quoted 1 line

Also, when doing make clean, the dependency files should be removed.

lmao, i forgot, oc, i'll be sending v3

-- Viro

#5 lore raw

PATCH v2 3/4 test/Makefile: Add liburing.a as a dependency

In reply to Alviro Iskandar Setiawan

The test binaries statically link liburing using liburing.a file. When liburing.a is recompiled, make sure the tests are also recompiled to ensure changes are applied to the test binary. It makes "make clean" command optional when making changes.

---
 test/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/Makefile +2 -2
index f421f53..9dae002 100644
@@ -196,10 +196,10 @@ all: $(test_targets)
 helpers.o: helpers.c
 	$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 
-%: %.c $(helpers) helpers.h
+%: %.c $(helpers) helpers.h ../src/liburing.a
 	$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
 
-%: %.cc $(helpers) helpers.h
+%: %.cc $(helpers) helpers.h ../src/liburing.a
 	$(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
 
 
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 4/4 examples/Makefile: Add liburing.a as a dependency

In reply to Alviro Iskandar Setiawan

The example binaries statically link liburing using liburing.a file. When liburing.a is recompiled, make sure the example binaries are also recompiled to ensure changes are applied to the binaries. It makes "make clean" command optional when making changes.

---
 examples/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/Makefile +1 -1
index f966f94..95a45f9 100644
@@ -29,7 +29,7 @@ all_targets += $(example_targets)
 
 all: $(example_targets)
 
-%: %.c
+%: %.c ../src/liburing.a
 	$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)
 
 clean:
Signature · 1 line
2.25.1