Skip to contentSkip to conversation

selftests/memfd: clean Makefile

PATCH RESEND In review Chen Linxuan 2 participants 5 messages Jun 10, 2025 – Jun 20, 2025 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 selftests/memfd: clean Makefile

When writing a test for fusectl, I referred to this Makefile as a reference for creating a FUSE daemon in the selftests. While doing so, I noticed that there is a minor issue in the Makefile.

The fuse_mnt.c file is not actually compiled into fuse_mnt.o, and the code setting CFLAGS for it never takes effect. The reason fuse_mnt compiles successfully is because CFLAGS is set at the very beginning of the file.

---
 tools/testing/selftests/memfd/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/testing/selftests/memfd/Makefile +1 -3
index 163b6f68631c4..e9b886c65153d 100644
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := memfd_test
@@ -16,10 +15,9 @@ ifeq ($(VAR_LDLIBS),)
 VAR_LDLIBS := -lfuse -pthread
 endif
 
-fuse_mnt.o: CFLAGS += $(VAR_CFLAGS)
-
 include ../lib.mk
 
+$(OUTPUT)/fuse_mnt: CFLAGS += $(VAR_CFLAGS)
 $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS)
 
 $(OUTPUT)/memfd_test: memfd_test.c common.c
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 3 lines · Chen Linxuan

When writing a test for fusectl, I referred to this Makefile as a reference for creating a FUSE daemon in the selftests. While doing so, I noticed that there is a minor issue in the Makefile.

What happens if this change isn't made?

Quoted 16 lines

The fuse_mnt.c file is not actually compiled into fuse_mnt.o, and the code setting CFLAGS for it never takes effect. The reason fuse_mnt compiles successfully is because CFLAGS is set at the very beginning of the file.

---
  tools/testing/selftests/memfd/Makefile | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
tools/testing/selftests/memfd/Makefile +0 -0
index 163b6f68631c4..e9b886c65153d 100644

tools/testing/selftests/memfd/Makefile line 2

Quoted 2 lines
tools/testing/selftests/memfd/Makefile +0 -1
@@ -1,5 +1,4 @@
  # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -D_FILE_OFFSET_BITS=64

What's the reason for deleting the above?

Quoted 5 lines
tools/testing/selftests/memfd/Makefile +0 -0
  CFLAGS += $(KHDR_INCLUDES)
 
  TEST_GEN_PROGS := memfd_test
@@ -16,10 +15,9 @@ ifeq ($(VAR_LDLIBS),)
  VAR_LDLIBS := -lfuse -pthread

tools/testing/selftests/memfd/Makefile ifeq ($(VAR_LDLIBS),) · line 23

Quoted 10 lines
tools/testing/selftests/memfd/Makefile +1 -2
  endif
 
-fuse_mnt.o: CFLAGS += $(VAR_CFLAGS)
-
  include ../lib.mk
 
+$(OUTPUT)/fuse_mnt: CFLAGS += $(VAR_CFLAGS)
  $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS)
 
  $(OUTPUT)/memfd_test: memfd_test.c common.c

thanks,
-- Shuah

#2 lore raw
Quoted 7 lines · Shuah Khan
Quoted 3 lines · Chen Linxuan

When writing a test for fusectl, I referred to this Makefile as a reference for creating a FUSE daemon in the selftests. While doing so, I noticed that there is a minor issue in the Makefile.

What happens if this change isn't made?

Nothing will happen.
When I was writing tests for the fusectl filesystem in the kernel repository, I came across this file as a reference.
Then I found that the process of passing CFLAGS was not correct. So, for the reason of not wanting others to be misled again,
I want to update the compilation process here.

Quoted 12 lines
Quoted 12 lines

The fuse_mnt.c file is not actually compiled into fuse_mnt.o, and the code setting CFLAGS for it never takes effect. The reason fuse_mnt compiles successfully is because CFLAGS is set at the very beginning of the file.

---
  tools/testing/selftests/memfd/Makefile | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 9 lines

tools/testing/selftests/memfd/Makefile line 2

Quoted 7 lines
tools/testing/selftests/memfd/Makefile +0 -1
index 163b6f68631c4..e9b886c65153d 100644
@@ -1,5 +1,4 @@
  # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -D_FILE_OFFSET_BITS=64

What's the reason for deleting the above?

The CFLAGS update here actually doesn't take effect.
I believe it is the -D_FILE_OFFSET_BITS=64 in VAR_CFLAGS that truly takes effect.

Quoted 22 lines
Quoted 6 lines
tools/testing/selftests/memfd/Makefile +0 -0
  CFLAGS += $(KHDR_INCLUDES)
 
  TEST_GEN_PROGS := memfd_test
@@ -16,10 +15,9 @@ ifeq ($(VAR_LDLIBS),)
  VAR_LDLIBS := -lfuse -pthread

tools/testing/selftests/memfd/Makefile ifeq ($(VAR_LDLIBS),) · line 23

Quoted 10 lines
tools/testing/selftests/memfd/Makefile +1 -2
  endif
 
-fuse_mnt.o: CFLAGS += $(VAR_CFLAGS)
-
  include ../lib.mk
 
+$(OUTPUT)/fuse_mnt: CFLAGS += $(VAR_CFLAGS)
  $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS)
 
  $(OUTPUT)/memfd_test: memfd_test.c common.c

thanks,
-- Shuah

maintainer
#3 lore raw
Quoted 7 lines · Chen Linxuan
Quoted 6 lines · Shuah Khan
Quoted 3 lines · Chen Linxuan

When writing a test for fusectl, I referred to this Makefile as a reference for creating a FUSE daemon in the selftests. While doing so, I noticed that there is a minor issue in the Makefile.

Quoted 9 lines
Quoted 1 line

What happens if this change isn't made?

Nothing will happen.
When I was writing tests for the fusectl filesystem in the kernel repository, I came across this file as a reference.
Then I found that the process of passing CFLAGS was not correct. So, for the reason of not wanting others to be misled again,
I want to update the compilation process here.

If there is no obvious reason then let's not make this change.

thanks,
-- Shuah

#4 lore raw
Quoted 19 lines · Shuah Khan
Quoted 7 lines · Chen Linxuan
Quoted 6 lines · Shuah Khan
Quoted 3 lines · Chen Linxuan

When writing a test for fusectl, I referred to this Makefile as a reference for creating a FUSE daemon in the selftests. While doing so, I noticed that there is a minor issue in the Makefile.

Quoted 9 lines
Quoted 1 line

What happens if this change isn't made?

Nothing will happen.
When I was writing tests for the fusectl filesystem in the kernel repository, I came across this file as a reference.
Then I found that the process of passing CFLAGS was not correct. So, for the reason of not wanting others to be misled again,
I want to update the compilation process here.

Quoted 1 line

If there is no obvious reason then let's not make this change.

Once https://lore.kernel.org/all/[email protected]/
gets merged,
there will be another example of compiling fuse in selftests in the kernel. So I think it's not a big problem if we don't make this change here.

thanks,
Chen Linxuan

Quoted 5 lines

thanks,
-- Shuah