diff mbox

[1/2] Makefile: use root-relative -f path for /sbin/ldconfig

Message ID 1445502151-25735-1-git-send-email-bjorn.forsman@gmail.com
State Superseded
Headers show

Commit Message

Bjørn Forsman Oct. 22, 2015, 8:22 a.m. UTC
Without this, the -f path argument is ignored:

 $ strace -f -s128 /sbin/ldconfig -r /home/vagrant/buildroot/output/target -f /home/vagrant/buildroot/output/target/etc/ld.so.conf |& grep "ld\.so\.conf"
 execve("/sbin/ldconfig", ["/sbin/ldconfig", "-r", "/home/vagrant/buildroot/output/target", "-f", "/home/vagrant/buildroot/output/target/etc/ld.so.conf"], [/* 61 vars */]) = 0
 execve("/sbin/ldconfig.real", ["/sbin/ldconfig.real", "-r", "/home/vagrant/buildroot/output/target", "-f", "/home/vagrant/buildroot/output/target/etc/ld.so.conf"], [/* 61 vars */]) = 0
 write(2, "Warning: ignoring configuration file that cannot be opened: /home/vagrant/buildroot/output/target/etc/ld.so.conf", 112Warning: ignoring configuration file that cannot be opened: /home/vagrant/buildroot/output/target/etc/ld.so.conf) = 112

Proof that using root-relative path -f path (/etc/ld.so.conf, without
$(TARGET_DIR) in front) picks up the correct file:

 $ strace -f -s128 /sbin/ldconfig -r /home/vagrant/buildroot/output/target -f /etc/ld.so.conf |& grep "ld\.so\.conf"
 execve("/sbin/ldconfig", ["/sbin/ldconfig", "-r", "/home/vagrant/buildroot/output/target", "-f", "/etc/ld.so.conf"], [/* 61 vars */]) = 0
 execve("/sbin/ldconfig.real", ["/sbin/ldconfig.real", "-r", "/home/vagrant/buildroot/output/target", "-f", "/etc/ld.so.conf"], [/* 61 vars */]) = 0
 lstat("/home/vagrant/buildroot/output/target/etc/ld.so.conf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
 open("/home/vagrant/buildroot/output/target/etc/ld.so.conf", O_RDONLY) = 3

Tested on Ubuntu 14.04.

 $ /sbin/ldconfig --version
 ldconfig (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19
 ...

$(TARGET_CROSS)ldconfig behaves differently (at least the ldconfig I
tested, which was built by Buildroot) and should not have root-relative
-f path. If it does, it will pick up host /etc/ld.so.conf file.

Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arnout Vandecappelle Oct. 22, 2015, 9:19 p.m. UTC | #1
On 22-10-15 10:22, Bjørn Forsman wrote:
> Without this, the -f path argument is ignored:
> 
>  $ strace -f -s128 /sbin/ldconfig -r /home/vagrant/buildroot/output/target -f /home/vagrant/buildroot/output/target/etc/ld.so.conf |& grep "ld\.so\.conf"
>  execve("/sbin/ldconfig", ["/sbin/ldconfig", "-r", "/home/vagrant/buildroot/output/target", "-f", "/home/vagrant/buildroot/output/target/etc/ld.so.conf"], [/* 61 vars */]) = 0
>  execve("/sbin/ldconfig.real", ["/sbin/ldconfig.real", "-r", "/home/vagrant/buildroot/output/target", "-f", "/home/vagrant/buildroot/output/target/etc/ld.so.conf"], [/* 61 vars */]) = 0
>  write(2, "Warning: ignoring configuration file that cannot be opened: /home/vagrant/buildroot/output/target/etc/ld.so.conf", 112Warning: ignoring configuration file that cannot be opened: /home/vagrant/buildroot/output/target/etc/ld.so.conf) = 112
> 
> Proof that using root-relative path -f path (/etc/ld.so.conf, without
> $(TARGET_DIR) in front) picks up the correct file:
> 
>  $ strace -f -s128 /sbin/ldconfig -r /home/vagrant/buildroot/output/target -f /etc/ld.so.conf |& grep "ld\.so\.conf"
>  execve("/sbin/ldconfig", ["/sbin/ldconfig", "-r", "/home/vagrant/buildroot/output/target", "-f", "/etc/ld.so.conf"], [/* 61 vars */]) = 0
>  execve("/sbin/ldconfig.real", ["/sbin/ldconfig.real", "-r", "/home/vagrant/buildroot/output/target", "-f", "/etc/ld.so.conf"], [/* 61 vars */]) = 0
>  lstat("/home/vagrant/buildroot/output/target/etc/ld.so.conf", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
>  open("/home/vagrant/buildroot/output/target/etc/ld.so.conf", O_RDONLY) = 3
> 
> Tested on Ubuntu 14.04.
> 
>  $ /sbin/ldconfig --version
>  ldconfig (Ubuntu EGLIBC 2.19-0ubuntu6.6) 2.19
>  ...
> 
> $(TARGET_CROSS)ldconfig behaves differently (at least the ldconfig I
> tested, which was built by Buildroot) and should not have root-relative
> -f path. If it does, it will pick up host /etc/ld.so.conf file.

 This makes me worried that it will do the wrong thing on some other build
hosts. In fact, using /sbin/ldconfig is fundamentally broken since we can't be
sure that it's compatible with the target dynamic linker.


 Regards,
 Arnout

> 
> Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index dd8959f..61ce1f9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -607,7 +607,7 @@ endif
>  					-f $(TARGET_DIR)/etc/ld.so.conf; \
>  	else \
>  		/sbin/ldconfig -r $(TARGET_DIR) \
> -			       -f $(TARGET_DIR)/etc/ld.so.conf; \
> +			       -f /etc/ld.so.conf; \
>  	fi
>  	( \
>  		echo "NAME=Buildroot"; \
>
Bjørn Forsman Oct. 23, 2015, 7:12 a.m. UTC | #2
On 22 October 2015 at 23:19, Arnout Vandecappelle <arnout@mind.be> wrote:
> This makes me worried that it will do the wrong thing on some other build
> hosts. In fact, using /sbin/ldconfig is fundamentally broken since we can't be
> sure that it's compatible with the target dynamic linker.

If you don't want to apply this patch, that is totally fine. It just
fixes a warning I saw while debugging an issue that ended up being
fixed by the next patch:

[PATCH 2/2] Makefile: add -C flag for /sbin/ldconfig

The 2nd patch is the one I really care about, it currently blocks me
from running Buildroot in my preferred environment.

If you want to completely remove use of (host) /sbin/ldconfig, that's fine too.

Just tell me what to do :-)

- Bjørn
Thomas Petazzoni Oct. 23, 2015, 8:26 a.m. UTC | #3
Dear Bjørn Forsman,

On Fri, 23 Oct 2015 09:12:02 +0200, Bjørn Forsman wrote:

> If you want to completely remove use of (host) /sbin/ldconfig, that's fine too.
> 
> Just tell me what to do :-)

We need to completely remove the ldconfig stuff, since it simply cannot
work. However, there is at least one package (mysql) that installs
libraries in a non-standard location (/usr/lib/mysql) and relies on
ld.so.conf for the dynamic linker to find them. I believe we need to
fix MySQL so that it installs its libraries in /usr/lib, and then get
rid of all the ldconfig/ld.so.conf stuff.

Or, alternatively, see how to get it working with an init script which
runs ldconfig at boot time. But then you have to look at how uClibc and
musl handle this, and implement a solution that works for all three C
libraries.

Best regards,

Thomas
Bjørn Forsman Oct. 23, 2015, 12:06 p.m. UTC | #4
Hi Thomas,

On 23 October 2015 at 10:26, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Bjørn Forsman,
>
> On Fri, 23 Oct 2015 09:12:02 +0200, Bjørn Forsman wrote:
>
>> If you want to completely remove use of (host) /sbin/ldconfig, that's fine too.
>>
>> Just tell me what to do :-)
>
> We need to completely remove the ldconfig stuff, since it simply cannot
> work. However, there is at least one package (mysql) that installs
> libraries in a non-standard location (/usr/lib/mysql) and relies on
> ld.so.conf for the dynamic linker to find them. I believe we need to
> fix MySQL so that it installs its libraries in /usr/lib, and then get
> rid of all the ldconfig/ld.so.conf stuff.
>
> Or, alternatively, see how to get it working with an init script which
> runs ldconfig at boot time. But then you have to look at how uClibc and
> musl handle this, and implement a solution that works for all three C
> libraries.

Sounds like a bigger task than I planned... :-/  (I'm afraid to break things.)

Would it be possible to merge "[PATCH 2/2] Makefile: add -C flag for
/sbin/ldconfig" as a stop-gap fix for my build problem then?

- Bjørn
Thomas Petazzoni Dec. 29, 2015, 8:32 p.m. UTC | #5
Bjørn,

On Thu, 22 Oct 2015 10:22:30 +0200, Bjørn Forsman wrote:

> $(TARGET_CROSS)ldconfig behaves differently (at least the ldconfig I
> tested, which was built by Buildroot) and should not have root-relative
> -f path. If it does, it will pick up host /etc/ld.so.conf file.
> 
> Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

As we discussed previously, our ldconfig handling is broken. So we are
simply planning to remove entirely. I have just posted a patch to this
effect:

	https://patchwork.ozlabs.org/patch/561618/

The idea is that from now on, packages are expected to install
libraries in path that are in the default search path of the dynamic
linker.

Consequently, I've marked your patches as Superseded. If you find any
package that doesn't work properly following our ldconfig removal, do
not hesitate to let us know.

Thanks!

Thomas
diff mbox

Patch

diff --git a/Makefile b/Makefile
index dd8959f..61ce1f9 100644
--- a/Makefile
+++ b/Makefile
@@ -607,7 +607,7 @@  endif
 					-f $(TARGET_DIR)/etc/ld.so.conf; \
 	else \
 		/sbin/ldconfig -r $(TARGET_DIR) \
-			       -f $(TARGET_DIR)/etc/ld.so.conf; \
+			       -f /etc/ld.so.conf; \
 	fi
 	( \
 		echo "NAME=Buildroot"; \