Skip to contentSkip to conversation

Sets LD_LIBRARY_PATH inside toolchain-wrapper.

PATCH New Daniel Serpell 2 participants 4 messages Feb 16, 2018 – Feb 18, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Sets LD_LIBRARY_PATH inside toolchain-wrapper.

Setting the host library path in the toolchain wrapper allows moving the host toolchain folder to a new path, as some of the tools depends on buildroot provided libraries.

---
 toolchain/toolchain-wrapper.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
toolchain/toolchain-wrapper.c +14 -0
index 2928ea42d0..53ea73fdf1 100644
@@ -231,6 +231,7 @@ int main(int argc, char **argv)
 	char *progpath = argv[0];
 	char *basename;
 	char *env_debug;
+        char *ld_path, *new_ld_path;
 	char *paranoid_wrapper;
 	int paranoid;
 	int ret, i, count = 0, debug;
@@ -442,6 +443,19 @@ int main(int argc, char **argv)
 	}
 #endif
 
+        /* Adds library path to our host libraries */
+	if ((ld_path = getenv("LD_LIBRARY_PATH")) && ld_path[0]) {
+		new_ld_path = malloc(strlen(ld_path) + strlen(absbasedir) + 6);
+		sprintf(new_ld_path, "%s:%s/lib", ld_path, absbasedir);
+	} else {
+		new_ld_path = malloc(strlen(absbasedir) + 5);
+		sprintf(new_ld_path, "%s/lib", absbasedir);
+	}
+	if (setenv("LD_LIBRARY_PATH", new_ld_path, 1)) {
+		perror(__FILE__ ": Failed to set LD_LIBRARY_PATH");
+		return 3;
+	}
+
 	if (execv(exec_args[0], exec_args))
 		perror(path);
 
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/1 Sets LD_LIBRARY_PATH inside toolchain-wrapper.

Hello,

Quoted 5 lines · Daniel Serpell

Setting the host library path in the toolchain wrapper allows moving the host toolchain folder to a new path, as some of the tools depends on buildroot provided libraries.

This is not needed. If you want to move around the host toolchain folder, run "make sdk", which prepares the host toolchain to be a relocatable SDK.

See slide 280 of
https://bootlin.com/doc/training/buildroot/buildroot-slides.pdf for more details.

And yes, we should mention this in the Buildroot manual. Patches welcome :-)

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com

A message that is not in the archive (sent off-list or not yet received): CANepG=MckvkieMHtLfR2fsrH1yJzvjUwDiritOk-YvP5-ghE8g@mail.gmail.com

#3 lore raw

PATCH 1/1 Sets LD_LIBRARY_PATH inside toolchain-wrapper.

Hi Thomas,

Quoted 9 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Daniel Serpell

Setting the host library path in the toolchain wrapper allows moving the host toolchain folder to a new path, as some of the tools depends on buildroot provided libraries.

Quoted 7 lines

This is not needed. If you want to move around the host toolchain folder, run "make sdk", which prepares the host toolchain to be a relocatable SDK.

See slide 280 of
https://bootlin.com/doc/training/buildroot/buildroot-slides.pdf for more details.

Yes, I missed that.

I see that you are using patchelf to make RPATH relative inside host binaries, is there any reason to not run that always, or at least in the "make toolchain" target?

Quoted 4 lines

And yes, we should mention this in the Buildroot manual. Patches welcome :-)

I'm not very good at writing documentation, perhaps the attached patch is enough.

Regards,

Daniel.

PD: Sorry, I first emailed this off-list on error.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Adds-documentation-to-the-make-sdk-rule.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180216/24479338/attachment.bin>

#4 lore raw

PATCH 1/1 Sets LD_LIBRARY_PATH inside toolchain-wrapper.

Hello,

Quoted 3 lines · Daniel Serpell

I see that you are using patchelf to make RPATH relative inside host binaries, is there any reason to not run that always, or at least in the "make toolchain" target?

Because there's no real reason to do that. During the build, the toolchain and other host tools are not moving, so keeping the absolute RPATH is fine. It's only when you want to move the toolchain/SDK around that the rpath needs to be adjusted to be relative RPATH.

Quoted 2 lines

I'm not very good at writing documentation, perhaps the attached patch is enough.

Patch looks good. Could you send it with "git send-email", and change the commit title to something like:

docs/manual: add documentation for the "make sdk" target

Thanks!

Thoas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com