Skip to contentSkip to conversation

btrfs-progs: set include path relatively

PATCH In review Naohiro Aota 2 participants 4 messages Oct 12, 2017 – Oct 14, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: set include path relatively

Currently, gcc is passed the include directory with full path. As a result, dependency files (*.o.d) also record the full path at the build time. Such full path dependency is annoying for sharing the source between multiple machines, containers, or anything the path differ.

And this is the same way what other program using autotools e.g. e2fsprogs is doing:

$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2  -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index b1f3388..69b94fb 100644
@@ -70,8 +70,8 @@ CFLAGS = $(SUBST_CFLAGS) \
 	 -D_XOPEN_SOURCE=700  \
 	 -fno-strict-aliasing \
 	 -fPIC \
-	 -I$(TOPDIR) \
-	 -I$(TOPDIR)/kernel-lib \
+	 -I. \
+	 -I./kernel-lib \
 	 $(EXTRAWARN_CFLAGS) \
 	 $(DEBUG_CFLAGS_INTERNAL) \
 	 $(EXTRA_CFLAGS)
Signature · 1 line
2.14.1
#1 lore raw

Re: [PATCH] btrfs: set include path relatively

Quoted 5 lines · Naohiro Aota

Currently, gcc is passed the include directory with full path. As a result, dependency files (*.o.d) also record the full path at the build time. Such full path dependency is annoying for sharing the source between multiple machines, containers, or anything the path differ.

Quoted 8 lines

And this is the same way what other program using autotools e.g. e2fsprogs is doing:

$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2  -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>

Makes sense for the header files. TOPDIR is also used for linking, can it cause similar problems, where the library search path is set as -L$(TOPDIR) ?

I wonder if we should do the same as in the example above and set default value of TOPDIR to '.', instead of pwd.

Quoted 27 lines
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index b1f3388..69b94fb 100644
@@ -70,8 +70,8 @@ CFLAGS = $(SUBST_CFLAGS) \
 	 -D_XOPEN_SOURCE=700  \
 	 -fno-strict-aliasing \
 	 -fPIC \
-	 -I$(TOPDIR) \
-	 -I$(TOPDIR)/kernel-lib \
+	 -I. \
+	 -I./kernel-lib \
 	 $(EXTRAWARN_CFLAGS) \
 	 $(DEBUG_CFLAGS_INTERNAL) \
 	 $(EXTRA_CFLAGS)
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Re: [PATCH] btrfs: set include path relatively

2017-10-12 21:38 GMT+09:00 David Sterba <[email protected]>:

Quoted 9 lines · Naohiro Aota
Quoted 8 lines

Currently, gcc is passed the include directory with full path. As a result, dependency files (*.o.d) also record the full path at the build time. Such full path dependency is annoying for sharing the source between multiple machines, containers, or anything the path differ.

And this is the same way what other program using autotools e.g. e2fsprogs is doing:

Quoted 8 lines
Quoted 5 lines
$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2  -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>

Makes sense for the header files. TOPDIR is also used for linking, can it cause similar problems, where the library search path is set as -L$(TOPDIR) ?

Since both "TOPDIR := $(shell pwd)" and -L$(TOPDIR) is evaluated at the build time,
it never cause problem on linking itself. What the problem with dependency files is persisting
the full path into the dep files. We generate the dep files only for objects (%.o.d rule)

Well, it's ok to use "-L." here, and it's the same way with autotools does.

Quoted 3 lines

I wonder if we should do the same as in the example above and set default value of TOPDIR to '.', instead of pwd.

TOPDIR is also used by library-test{,.static}. They run gcc in a temporary directory.
Thus, TOPDIR here should be absolute.

Quoted 29 lines
Quoted 29 lines
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -3
index b1f3388..69b94fb 100644
@@ -70,8 +70,8 @@ CFLAGS = $(SUBST_CFLAGS) \
       -D_XOPEN_SOURCE=700  \
       -fno-strict-aliasing \
       -fPIC \
-      -I$(TOPDIR) \
-      -I$(TOPDIR)/kernel-lib \
+      -I. \
+      -I./kernel-lib \
       $(EXTRAWARN_CFLAGS) \
       $(DEBUG_CFLAGS_INTERNAL) \
       $(EXTRA_CFLAGS)
--

2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Re: [PATCH] btrfs: set include path relatively

Quoted 26 lines · Naohiro Aota

2017-10-12 21:38 GMT+09:00 David Sterba <[email protected]>:

Quoted 9 lines · Naohiro Aota
Quoted 8 lines

Currently, gcc is passed the include directory with full path. As a result, dependency files (*.o.d) also record the full path at the build time. Such full path dependency is annoying for sharing the source between multiple machines, containers, or anything the path differ.

And this is the same way what other program using autotools e.g. e2fsprogs is doing:

Quoted 8 lines
Quoted 5 lines
$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2  -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>

Makes sense for the header files. TOPDIR is also used for linking, can it cause similar problems, where the library search path is set as -L$(TOPDIR) ?

Since both "TOPDIR := $(shell pwd)" and -L$(TOPDIR) is evaluated at the build time,
it never cause problem on linking itself. What the problem with dependency files is persisting
the full path into the dep files. We generate the dep files only for objects (%.o.d rule)

Quoted 8 lines

Well, it's ok to use "-L." here, and it's the same way with autotools does.

Quoted 2 lines

I wonder if we should do the same as in the example above and set default value of TOPDIR to '.', instead of pwd.

TOPDIR is also used by library-test{,.static}. They run gcc in a temporary directory.
Thus, TOPDIR here should be absolute.

I've added another variable with absolute path to make library-test work and updated your patch so we can use TOPDIR = .