Skip to contentSkip to conversation

skeleton: add support for /etc/ld.so.conf.d/*.conf files

PATCH New Jérôme Pouiller 4 participants 9 messages Oct 31, 2014 – Nov 2, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 skeleton: add support for /etc/ld.so.conf.d/*.conf files

---
 toolchain/toolchain.mk | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
toolchain/toolchain.mk +25 -0
index 3f9900b..cd65cfc 100644
@@ -13,6 +13,31 @@ endef
 TARGET_FINALIZE_HOOKS += GLIBC_COPY_NSSWITCH_FILE
 endif
 
+# - glibc can include configuration files at runtime
+# - uclibc does not support "include" feature
+# - musl use /etc/ld-musl-${ARCH}.path file. This file use same syntax
+#     than $LD_LIBRARY_PATH. Since there are plenty of corner cases in
+#     generation of this file, we prefer to not support it. User can
+#     fix the problem by providing file manualy (in a an overlay).
+#
+ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
+define GENERATE_LD_SO_CONF_FILE
+	echo 'include /etc/ld.so.conf.d/*.conf' > $(TARGET_DIR)/etc/ld.so.conf
+endef
+else
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+define GENERATE_LD_SO_CONF_FILE
+	ls $(TARGET_DIR)/etc/ld.so.conf.d/*.conf > /dev/null 2>&1 && \
+	    echo "Usage of /etc/ld.so.conf.d/*.conf files with musl libc is not supported"
+endef
+else # UCLIBC
+define GENERATE_LD_SO_CONF_FILE
+	cat $(TARGET_DIR)/etc/ld.so.conf.d/*.conf > $(TARGET_DIR)/etc/ld.so.conf
+endef
+endif
+endif
+TARGET_FINALIZE_HOOKS += GENERATE_LD_SO_CONF_FILE
+
 # Install the gconv modules
 ifeq ($(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY),y)
 GCONV_LIBS = $(call qstrip,$(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST))
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 2/3 gst-fsl-plugins: fix plugins loading

Problem was reported :
http://lists.busybox.net/pipermail/buildroot/2014-July/101566.html
http://lists.busybox.net/pipermail/buildroot/2014-October/107613.html

---
 package/gstreamer/gst-fsl-plugins/gst-fsl-plugins.mk             | 9 +++++++++
 .../gstreamer/gst-fsl-plugins/ld.so.conf.d-gst-fsl-plugins.conf  | 5 +++++
 2 files changed, 14 insertions(+)
 create mode 100644 package/gstreamer/gst-fsl-plugins/ld.so.conf.d-gst-fsl-plugins.conf
package/gstreamer/gst-fsl-plugins/gst-fsl-plugins.mk +9 -0
index 8d8b8b4..21046fc 100644
@@ -40,4 +40,13 @@ endef
 
 GST_FSL_PLUGINS_POST_PATCH_HOOKS += GST_FSL_PLUGINS_PATCH_M4
 
+define GST_FSL_PLUGINS_FIX_LD_PATH
+	$(INSTALL) -d $(TARGET_DIR)/etc/ld.so.conf.d
+	$(INSTALL) -m 644 \
+		package/gstreamer/gst-fsl-plugins/ld.so.conf.d-gst-fsl-plugins.conf \
+		$(TARGET_DIR)/etc/ld.so.conf.d
+endef
+
+GST_FSL_PLUGINS_POST_INSTALL_TARGET_HOOKS += GST_FSL_PLUGINS_FIX_LD_PATH
+
 $(eval $(autotools-package))
package/gstreamer/gst-fsl-plugins/ld.so.conf.d-gst-fsl-plugins.conf new file +5 -0
new file mode 100644
index 0000000..325fbf1
@@ -0,0 +1,5 @@
+# cf. https://community.freescale.com/thread/300387
+/usr/lib/imx-mm/audio-codec
+/usr/lib/imx-mm/video-codec
+/usr/lib/imx-mm/parser
+
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/3 gst-fsl-plugins: fix plugins loading

Dear J?r?me Pouiller,

package/gstreamer/gst-fsl-plugins/gst-fsl-plugins.mk endef · line 47

Quoted 5 lines · J?r?me Pouiller
package/gstreamer/gst-fsl-plugins/gst-fsl-plugins.mk +5 -0
+define GST_FSL_PLUGINS_FIX_LD_PATH
+	$(INSTALL) -d $(TARGET_DIR)/etc/ld.so.conf.d
+	$(INSTALL) -m 644 \
+		package/gstreamer/gst-fsl-plugins/ld.so.conf.d-gst-fsl-plugins.conf \
+		$(TARGET_DIR)/etc/ld.so.conf.d

In a review of an earlier patch, Yann already suggested to do this in one command using $(INSTALL) -D -m 644.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v2 3/3 mysql: use /etc/ld.so.conf.d instead of /etc/ld.so.conf

In reply to Jérôme Pouiller
---
 package/mysql/ld.so.conf.d-mysql.conf | 1 +
 package/mysql/mysql.mk                | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 package/mysql/ld.so.conf.d-mysql.conf
package/mysql/ld.so.conf.d-mysql.conf new file +1 -0
new file mode 100644
index 0000000..33d9ace
@@ -0,0 +1 @@
+/usr/lib/mysql
package/mysql/mysql.mk +4 -1
index 945ca18..1a35378 100644
@@ -114,7 +114,10 @@ define MYSQL_REMOVE_TEST_PROGS
 endef
 
 define MYSQL_ADD_MYSQL_LIB_PATH
-	echo "/usr/lib/mysql" >> $(TARGET_DIR)/etc/ld.so.conf
+	$(INSTALL) -d $(TARGET_DIR)/etc/ld.so.conf.d
+	$(INSTALL) -m 644 \
+		package/mysql g/ld.so.conf.d-mysql.conf \
+		$(TARGET_DIR)/etc/ld.so.conf.d
 endef
 
 MYSQL_POST_INSTALL_TARGET_HOOKS += MYSQL_REMOVE_TEST_PROGS
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 3/3 mysql: use /etc/ld.so.conf.d instead of /etc/ld.so.conf

Dear J?r?me Pouiller,

package/mysql/mysql.mk define MYSQL_REMOVE_TEST_PROGS · line 121

Quoted 7 lines · J?r?me Pouiller

define MYSQL_ADD_MYSQL_LIB_PATH

package/mysql/mysql.mk +4 -1
-	echo "/usr/lib/mysql" >> $(TARGET_DIR)/etc/ld.so.conf
+	$(INSTALL) -d $(TARGET_DIR)/etc/ld.so.conf.d
+	$(INSTALL) -m 644 \
+		package/mysql g/ld.so.conf.d-mysql.conf \
+		$(TARGET_DIR)/etc/ld.so.conf.d
 endef

Does this works with uClibc?

The gst-fsl-plugins package is limited to glibc, so we don't care. But mysql is supported with uClibc, and I'm not sure uClibc supports /etc/ld.so.conf.d/.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH v2 1/3 skeleton: add support for /etc/ld.so.conf.d/*.conf files

In reply to Jérôme Pouiller

Dear J?r?me Pouiller,

toolchain/toolchain.mk endef · line 31

Quoted 4 lines · J?r?me Pouiller
toolchain/toolchain.mk +4 -0
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+define GENERATE_LD_SO_CONF_FILE
+	ls $(TARGET_DIR)/etc/ld.so.conf.d/*.conf > /dev/null 2>&1 && \
+	    echo "Usage of /etc/ld.so.conf.d/*.conf files with musl libc is not supported"

We should error out here.

Does musl supports /etc/ld.so.conf ? If so, then I believe we should simply not use the /etc/ld.so.conf.d/ feature of glibc, and instead keep using /etc/ld.so.conf only, like MySQL was doing.

If you don't want to see repeated entries, you can do something like:

	grep -q "^/usr/lib/mysql$" $(TARGET_DIR)/etc/ld.so.conf ||
		echo "/usr/lib/mysql" >> $(TARGET_DIR)/etc/ld.so.conf

We could even imagine having a make function to do that.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

PATCH v2 1/3 skeleton: add support for /etc/ld.so.conf.d/*.conf files

Quoted 9 lines · On Friday 31 October 2014 16:41:56 Thomas Petazzoni wrote:

Dear J?r?me Pouiller,

Quoted 5 lines · J?r?me Pouiller
toolchain/toolchain.mk +4 -0
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+define GENERATE_LD_SO_CONF_FILE
+	ls $(TARGET_DIR)/etc/ld.so.conf.d/*.conf > /dev/null 2>&1 && \
+	    echo "Usage of /etc/ld.so.conf.d/*.conf files with musl libc is not

supported"

We should error out here.

User may fix problem by providing correct file in an overlay. However, I haven't a strong opinion about that.

Quoted 1 line

Does musl supports /etc/ld.so.conf ?

I have checked in sources and it seems it doesn't :( . It use a file called /etc/ld-musl-${ARCH}.path (with ARCH={arm,x86,...}). Syntax of this file is same than $LD_LIBRARY_PATH (paths separated with ':').

Quoted 10 lines

If so, then I believe we should
simply not use the /etc/ld.so.conf.d/ feature of glibc, and instead keep using /etc/ld.so.conf only, like MySQL was doing.

If you don't want to see repeated entries, you can do something like:

	grep -q "^/usr/lib/mysql$" $(TARGET_DIR)/etc/ld.so.conf ||
		echo "/usr/lib/mysql" >> $(TARGET_DIR)/etc/ld.so.conf

We could even imagine having a make function to do that.

The two options have their drawbacks. I have no strong opinion.

Signature · 1 line
J?r?me Pouiller, Sysmic
#7 lore raw

PATCH v2 1/3 skeleton: add support for /etc/ld.so.conf.d/*.conf files

In reply to Jérôme Pouiller

J?r?me, All,

On 2014-10-31 16:19 +0100, J?r?me Pouiller spake thusly:

Quoted 27 lines
---
 toolchain/toolchain.mk | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
toolchain/toolchain.mk +14 -0
index 3f9900b..cd65cfc 100644
@@ -13,6 +13,31 @@ endef
 TARGET_FINALIZE_HOOKS += GLIBC_COPY_NSSWITCH_FILE
 endif
 
+# - glibc can include configuration files at runtime
+# - uclibc does not support "include" feature
+# - musl use /etc/ld-musl-${ARCH}.path file. This file use same syntax
+#     than $LD_LIBRARY_PATH. Since there are plenty of corner cases in
+#     generation of this file, we prefer to not support it. User can
+#     fix the problem by providing file manualy (in a an overlay).
+#
+ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
+define GENERATE_LD_SO_CONF_FILE
+	echo 'include /etc/ld.so.conf.d/*.conf' > $(TARGET_DIR)/etc/ld.so.conf
+endef
+else
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+define GENERATE_LD_SO_CONF_FILE

toolchain/toolchain.mk endef · line 39

Quoted 10 lines
toolchain/toolchain.mk +10 -0
+	ls $(TARGET_DIR)/etc/ld.so.conf.d/*.conf > /dev/null 2>&1 && \
+	    echo "Usage of /etc/ld.so.conf.d/*.conf files with musl libc is not supported"
+endef
+else # UCLIBC
+define GENERATE_LD_SO_CONF_FILE
+	cat $(TARGET_DIR)/etc/ld.so.conf.d/*.conf > $(TARGET_DIR)/etc/ld.so.conf
+endef
+endif
+endif
+TARGET_FINALIZE_HOOKS += GENERATE_LD_SO_CONF_FILE

I think it would be much better to not support this glibcism.

I can only see one use-case for that:

- the package installs such a file in its install procedure => we should provide a post-install hook to move the content of this file into /etc/ld.so.conf

As Thomas P. said, we can provide a macro to ease doing that. I propose something slightly different, because 'grep -q' is not portable and I do not like 'echo':

    # Add a path in $(1) to /etc/ld.so.conf
    define UPDATE_LD_SO_CONF
        grep -E '^$(1)$$' $(TARGET_DIR)/etc/ld.so.conf >/dev/null 2>&1 || \
        printf '%s\n' '$(1)' >>$(TARGET_DIR)/etc/ld.so.conf
    endef

which you could then call like that:

    define FOO_UPDATE_LD_SO_CONF
        $(call UPDATE_LD_SO_CONF,/usr/lib/foo)
    endef
    FOO_POST_TARGET_INSTALL_HOOKS += FOO_UPDATE_LD_SO_CONF

Alternatively, we could include that in the pakage infra:

FOO_LD_SO_CONF_PATHS = /usr/lib/foo /usr/lib/foo/bar

and the infra would look at that variable, and if set, add all the paths to /et/ld/so/conf.

I thionk the pkg-infra solution is a bit overkill, given we currently do not have that much packages that use that (well, only mysql needs it), but the macro would not be very much justified either.

So, I just NAK this feature.

Regards,
Yann E. MORIN.

Quoted 6 lines
toolchain/toolchain.mk +0 -0
 # Install the gconv modules
 ifeq ($(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY),y)
 GCONV_LIBS = $(call qstrip,$(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST))
Signature · 1 line
1.9.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.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw

PATCH v2 1/3 skeleton: add support for /etc/ld.so.conf.d/*.conf files

In reply to Jérôme Pouiller

Hi J?r?me,

Quoted 10 lines · J?r?me Pouiller
---
 toolchain/toolchain.mk | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
toolchain/toolchain.mk +0 -0
index 3f9900b..cd65cfc 100644

toolchain/toolchain.mk endef · line 19

Quoted 7 lines
toolchain/toolchain.mk +4 -0
@@ -13,6 +13,31 @@ endef
 TARGET_FINALIZE_HOOKS += GLIBC_COPY_NSSWITCH_FILE
 endif
 
+# - glibc can include configuration files at runtime
+# - uclibc does not support "include" feature
+# - musl use /etc/ld-musl-${ARCH}.path file. This file use same syntax
+#     than $LD_LIBRARY_PATH. Since there are plenty of corner cases in

s/than/as/

toolchain/toolchain.mk endef · line 21

Quoted 2 lines
toolchain/toolchain.mk +2 -0
+#     generation of this file, we prefer to not support it. User can
+#     fix the problem by providing file manualy (in a an overlay).

Redundant "a".

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -