Skip to contentSkip to conversation

Per-package folder fixes

PATCH Superseded Thomas Petazzoni 2 participants 6 messages Nov 15, 2018 – Nov 20, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Per-package folder fixes

Hello,

Here are two patches that illustrate the kind of issue that one can face with some packages when using per-package folders.

The commit log explain in further details the problems.

Thomas

Thomas Petazzoni (2):
package/apr-util: fix build with per-package folders package/apache: add patch to fix per-package folder build

 ...in-handle-separate-APR_INCLUDE_DIR-A.patch | 47 +++++++++++++++++++
 package/apr-util/apr-util.mk                  |  9 ++++
 2 files changed, 56 insertions(+)
 create mode 100644 package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch
Signature · 1 line
2.19.1
#1 lore raw

PATCH 1/2 package/apr-util: fix build with per-package folders

With per-package folder support enable, the build of apr-util fails, for two reasons:

- The rules.mk file is generated by the 'apr' package, and then copied into the 'apr-util' source directory. This is done by the 'apr-util' build process. Unfortunately, this rules.mk file has a number of hardcoded paths: to the compiler and to the libtool script.

Due to this, the compiler from the 'apr' per-package folder gets used. But this compiler uses the 'apr' package sysroot, which does not have all the dependencies of the 'apr-util' package, causing the build to fail because <expat.h> is not found.

- Similarly, the libtool script itself has some hardcoded paths, which make it use the compiler/linker from the 'apr' per-package folder, so it does not find the expat library.

We fix both issues by doing the necessary replacement in both rules.mk and libtool. For rules.mk, since it's in the source directoryt, we can do the replacement in-place. For libtool, since it's hard-linked between the 'apr' copy and the 'apr-util' copy, we need to make a temporary copy to break the hard link and do the replacement.

---
 package/apr-util/apr-util.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/apr-util/apr-util.mk +9 -0
index b006964ccb..e685f76838 100644
@@ -15,6 +15,15 @@ APR_UTIL_CONF_OPTS = \
 	--with-apr=$(STAGING_DIR)/usr/bin/apr-1-config
 APR_UTIL_CONFIG_SCRIPTS = apu-1-config
 
+define APR_UTIL_FIX_RULES_MK_LIBTOOL
+	$(SED) 's,$(PER_PACKAGE_DIR)/apr/,$(PER_PACKAGE_DIR)/apr-util/,g' $(@D)/build/rules.mk
+	cp $(STAGING_DIR)/usr/build-1/libtool $(STAGING_DIR)/usr/build-1/libtool.fixed
+	$(SED) 's,$(PER_PACKAGE_DIR)/apr/,$(PER_PACKAGE_DIR)/apr-util/,g' \
+		$(STAGING_DIR)/usr/build-1/libtool.fixed
+	mv $(STAGING_DIR)/usr/build-1/libtool.fixed $(STAGING_DIR)/usr/build-1/libtool
+endef
+APR_UTIL_POST_CONFIGURE_HOOKS += APR_UTIL_FIX_RULES_MK_LIBTOOL
+
 # When iconv is available, then use it to provide charset conversion
 # features.
 APR_UTIL_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBICONV),libiconv)
Signature · 1 line
2.19.1
#2 lore raw

PATCH 1/2 package/apr-util: fix build with per-package folders

Thomas, All,

On 2018-11-15 16:21 +0100, Thomas Petazzoni spake thusly:

Quoted 18 lines

With per-package folder support enable, the build of apr-util fails, for two reasons:

- The rules.mk file is generated by the 'apr' package, and then copied into the 'apr-util' source directory. This is done by the 'apr-util' build process. Unfortunately, this rules.mk file has a number of hardcoded paths: to the compiler and to the libtool script.

Due to this, the compiler from the 'apr' per-package folder gets used. But this compiler uses the 'apr' package sysroot, which does not have all the dependencies of the 'apr-util' package, causing the build to fail because <expat.h> is not found.

- Similarly, the libtool script itself has some hardcoded paths, which make it use the compiler/linker from the 'apr' per-package folder, so it does not find the expat library.

Quoted 5 lines

We fix both issues by doing the necessary replacement in both rules.mk and libtool. For rules.mk, since it's in the source directoryt, we can do the replacement in-place. For libtool, since it's hard-linked between the 'apr' copy and the 'apr-util' copy, we need to make a temporary copy to break the hard link and do the replacement.

I don't know what sed version you are using, but mine breaks the hardlink when doing in-place replacement:

    $ echo OK >foo
    $ ln foo bar
    $ sed -i -e 's/OK/in-bar/' bar
    $ cat foo
    OK
    $ cat bar
    in-bar

Regards,
Yann E. MORIN.

Quoted 28 lines
---
 package/apr-util/apr-util.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/apr-util/apr-util.mk +9 -0
index b006964ccb..e685f76838 100644
@@ -15,6 +15,15 @@ APR_UTIL_CONF_OPTS = \
 	--with-apr=$(STAGING_DIR)/usr/bin/apr-1-config
 APR_UTIL_CONFIG_SCRIPTS = apu-1-config
 
+define APR_UTIL_FIX_RULES_MK_LIBTOOL
+	$(SED) 's,$(PER_PACKAGE_DIR)/apr/,$(PER_PACKAGE_DIR)/apr-util/,g' $(@D)/build/rules.mk
+	cp $(STAGING_DIR)/usr/build-1/libtool $(STAGING_DIR)/usr/build-1/libtool.fixed
+	$(SED) 's,$(PER_PACKAGE_DIR)/apr/,$(PER_PACKAGE_DIR)/apr-util/,g' \
+		$(STAGING_DIR)/usr/build-1/libtool.fixed
+	mv $(STAGING_DIR)/usr/build-1/libtool.fixed $(STAGING_DIR)/usr/build-1/libtool
+endef
+APR_UTIL_POST_CONFIGURE_HOOKS += APR_UTIL_FIX_RULES_MK_LIBTOOL
+
 # When iconv is available, then use it to provide charset conversion
 # features.
 APR_UTIL_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBICONV),libiconv)
Signature · 1 line
2.19.1
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/2 package/apr-util: fix build with per-package folders

Hello,

Quoted 10 lines · Yann E. MORIN

I don't know what sed version you are using, but mine breaks the hardlink when doing in-place replacement:

    $ echo OK >foo
    $ ln foo bar
    $ sed -i -e 's/OK/in-bar/' bar
    $ cat foo
    OK
    $ cat bar
    in-bar

I tested again, and you're right, I'll simplify the logic accordingly. Thanks for the review!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 2/2 package/apache: add patch to fix per-package folder build

In reply to Thomas Petazzoni

When APR_INCLUDEDIR and APU_INCLUDEDIR point to the same directory, Apache builds properly. However, with per-package folder support, they point to different directories, and APU_INCLUDEDIR contains both the APR headers and the APU headers.

Due to this, the Apache Makefile logic to generate its exports.c file leads to duplicate definitions, because the APR headers are considered
twice: once from APR_INCLUDEDIR, once from APU_INCLUDEDIR.

We fix this by introducing a patch to the Apache build system.

---
 ...in-handle-separate-APR_INCLUDE_DIR-A.patch | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch
package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch new file +47 -0
new file mode 100644
index 0000000000..299840bee2
@@ -0,0 +1,47 @@
+From 00281390e82db18fe0de4033be4045f9391a8ee5 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Thu, 15 Nov 2018 14:04:29 +0100
+Subject: [PATCH] server/Makefile.in: handle separate
+ APR_INCLUDE_DIR/APU_INCLUDE_DIR
+
+If APR_INCLUDEDIR and APU_INCLUDEDIR point to different directories,
+but for example APU_INCLUDEDIR contains both the apr headers and apu
+headers, the "export_files" file will contain duplicate header files,
+causing the exports.c file to contain duplicate definitions, making
+the build fail.
+
+This commit fixes that by making sure we only use the apr headers from
+APR_INCLUDEDIR and the apu headers from the APU_INCLUDEDIR.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ server/Makefile.in | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/server/Makefile.in b/server/Makefile.in
+index 1fa334467d..2258f0bdf2 100644
+--- a/server/Makefile.in
++++ b/server/Makefile.in
+@@ -34,7 +34,6 @@ test_char.h: gen_test_char
+ util.lo: test_char.h
+ 
+ EXPORT_DIRS = $(top_srcdir)/include $(top_srcdir)/os/$(OS_DIR)
+-EXPORT_DIRS_APR = $(APR_INCLUDEDIR) $(APU_INCLUDEDIR)
+ 
+ # If export_files is a dependency here, but we remove it during this stage,
+ # when exports.c is generated, make will not detect that export_files is no
+@@ -60,9 +59,8 @@ export_files:
+ 	      ls $$dir/*.h ; \
+ 	  done; \
+ 	  echo "$(top_srcdir)/server/mpm_fdqueue.h"; \
+-	  for dir in $(EXPORT_DIRS_APR); do \
+-	      ls $$dir/ap[ru].h $$dir/ap[ru]_*.h 2>/dev/null; \
+-	  done; \
++	  ls $(APR_INCLUDE_DIR)/{apr.h,apr_*.h} 2>/dev/null; \
++	  ls $(APU_INCLUDE_DIR)/{apu.h,apu_*.h} 2>/dev/null; \
+ 	) | sed -e s,//,/,g | sort -u > $@
+ 
+ exports.c: export_files
+-- 
+2.19.1
+
Signature · 1 line
2.19.1
#5 lore raw

PATCH 2/2 package/apache: add patch to fix per-package folder build

Thomas, All,

On 2018-11-15 16:21 +0100, Thomas Petazzoni spake thusly:

Quoted 5 lines

When APR_INCLUDEDIR and APU_INCLUDEDIR point to the same directory, Apache builds properly. However, with per-package folder support, they point to different directories, and APU_INCLUDEDIR contains both the APR headers and the APU headers.

Quoted 7 lines

Due to this, the Apache Makefile logic to generate its exports.c file leads to duplicate definitions, because the APR headers are considered
twice: once from APR_INCLUDEDIR, once from APU_INCLUDEDIR.

We fix this by introducing a patch to the Apache build system.

I guess this can very well be applied now, without waiting for TLPB.

Quoted 17 lines
---
 ...in-handle-separate-APR_INCLUDE_DIR-A.patch | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch
package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch new file +6 -0
new file mode 100644
index 0000000000..299840bee2
@@ -0,0 +1,47 @@
+From 00281390e82db18fe0de4033be4045f9391a8ee5 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Thu, 15 Nov 2018 14:04:29 +0100
+Subject: [PATCH] server/Makefile.in: handle separate
+ APR_INCLUDE_DIR/APU_INCLUDE_DIR
+

package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch line 16

Quoted 10 lines
package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch new file +10 -0
+If APR_INCLUDEDIR and APU_INCLUDEDIR point to different directories,
+but for example APU_INCLUDEDIR contains both the apr headers and apu
+headers, the "export_files" file will contain duplicate header files,
+causing the exports.c file to contain duplicate definitions, making
+the build fail.
+
+This commit fixes that by making sure we only use the apr headers from
+APR_INCLUDEDIR and the apu headers from the APU_INCLUDEDIR.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>

No upstream status? I think they want patches to be contributed as bug reports [0], and there is a section dealing just with the buildsystem [1].

[0] https://httpd.apache.org/dev/patches.html
[1] https://bz.apache.org/bugzilla/buglist.cgi?component=Build&order=bug_id%20DESC&product=Apache%20httpd-2

Regards,
Yann E. MORIN.

Quoted 34 lines
package/apache/0003-server-Makefile.in-handle-separate-APR_INCLUDE_DIR-A.patch new file +31 -0
+---
+ server/Makefile.in | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/server/Makefile.in b/server/Makefile.in
+index 1fa334467d..2258f0bdf2 100644
+--- a/server/Makefile.in
++++ b/server/Makefile.in
+@@ -34,7 +34,6 @@ test_char.h: gen_test_char
+ util.lo: test_char.h
+ 
+ EXPORT_DIRS = $(top_srcdir)/include $(top_srcdir)/os/$(OS_DIR)
+-EXPORT_DIRS_APR = $(APR_INCLUDEDIR) $(APU_INCLUDEDIR)
+ 
+ # If export_files is a dependency here, but we remove it during this stage,
+ # when exports.c is generated, make will not detect that export_files is no
+@@ -60,9 +59,8 @@ export_files:
+ 	      ls $$dir/*.h ; \
+ 	  done; \
+ 	  echo "$(top_srcdir)/server/mpm_fdqueue.h"; \
+-	  for dir in $(EXPORT_DIRS_APR); do \
+-	      ls $$dir/ap[ru].h $$dir/ap[ru]_*.h 2>/dev/null; \
+-	  done; \
++	  ls $(APR_INCLUDE_DIR)/{apr.h,apr_*.h} 2>/dev/null; \
++	  ls $(APU_INCLUDE_DIR)/{apu.h,apu_*.h} 2>/dev/null; \
+ 	) | sed -e s,//,/,g | sort -u > $@
+ 
+ exports.c: export_files
+-- 
+2.19.1
+
Signature · 1 line
2.19.1
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'