Message ID | 20180216221845.13337-1-daniel.serpell@gmail.com |
---|---|
State | Rejected |
Headers | show |
Series | Sets LD_LIBRARY_PATH inside toolchain-wrapper. | expand |
Hello, On Fri, 16 Feb 2018 19:18:45 -0300, Daniel Serpell wrote: > 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. > > Signed-off-by: Daniel Serpell <daniel.serpell@gmail.com> 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
Hi Thomas, On Fri, Feb 16, 2018 at 7:46 PM, Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote: > Hello, > > On Fri, 16 Feb 2018 19:18:45 -0300, Daniel Serpell wrote: >> 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. >> >> Signed-off-by: Daniel Serpell <daniel.serpell@gmail.com> > > 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? > > 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. From 9c2d1d7bf57f93a819447327c73028e4aeb28925 Mon Sep 17 00:00:00 2001 From: Daniel Serpell <daniel.serpell@gmail.com> Date: Fri, 16 Feb 2018 21:30:54 -0300 Subject: [PATCH] Adds documentation to the make sdk rule. Signed-off-by: Daniel Serpell <daniel.serpell@gmail.com> --- docs/manual/using-buildroot-toolchain.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/manual/using-buildroot-toolchain.txt b/docs/manual/using-buildroot-toolchain.txt index 6a90645649..3246dc2411 100644 --- a/docs/manual/using-buildroot-toolchain.txt +++ b/docs/manual/using-buildroot-toolchain.txt @@ -12,11 +12,15 @@ The toolchain generated by Buildroot is located by default in +output/host/bin/+ to your PATH environment variable and then to use +ARCH-linux-gcc+, +ARCH-linux-objdump+, +ARCH-linux-ld+, etc. -It is possible to relocate the toolchain - but then +--sysroot+ must -be passed every time the compiler is called to tell where the -libraries and header files are. +It is possible to relocate the toolchain, this allows to distribute +the toolchain to other developers to build applications for your +target. To achieve this: + +* run +make sdk+, which prepares the toolchain to be relocatable; +* tarball the contents of the +output/host+ directory; +* distribute the resulting tarball. + +Once the toolchain is installed to the new location, the user must run +the +relocate-sdk.sh+ script to make sure all paths are updated with +the new location. -It is also possible to generate the Buildroot toolchain in a directory -other than +output/host+ by using the +Build options -> Host dir+ -option. This could be useful if the toolchain must be shared with -other users.
Hello, On Fri, 16 Feb 2018 21:43:36 -0300, Daniel Serpell wrote: > 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. > 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
diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c index 2928ea42d0..53ea73fdf1 100644 --- a/toolchain/toolchain-wrapper.c +++ b/toolchain/toolchain-wrapper.c @@ -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);
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. Signed-off-by: Daniel Serpell <daniel.serpell@gmail.com> --- toolchain/toolchain-wrapper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)