sgidevnet / sgug-rse

Silicon Graphics User Group RPM Software Environment
GNU General Public License v3.0
61 stars 20 forks source link

Support use of packages / binaries without needing LD_LIBRARYN32_PATH #4

Closed danielhams closed 1 year ago

danielhams commented 4 years ago

This will avoid conflicts with system software / other binaries.

Idea is to set a "default" rpath in the GCC itself, probably via modifying the gcc specs file.

There's a few packages I manually added rpath to that will need this reverting.

danielhams commented 4 years ago

And for further clarification - we'll need this to be able to support sudo in a non-statically linked variant.

This is because the runtime linker refuses to honour LD_LIBRARYN32_PATH for binaries that are setuid or setguid.

danielhams commented 4 years ago

When building something with autotools - if a library being linked to does not have the appropriate libblah.la libtool linker file - libtool won't embed an appropriate RPATH entry.

Perhaps the simplest solution here is to add -rpath to the default LDFLAGS used by rpm.

I've verified this works OK for three little toy packages (libone, libtwo, program using them).

Once done, the binary can be run without needed a modified LD_LIBRARYN32_PATH. Which was nice.

onre commented 4 years ago

From my viewpoint adding -rpath to flags is way better than forcing GCC to do it.

danielhams commented 4 years ago

Agreed about using -rpath.

My motivation for tweaking gcc -> if someone is using the gcc from the sgug-rse outside of the rse - it would be nice that they don't have to fiddle with LD_LIBRARYN32_PATH etc to get something to build + run.

The first step is putting the rpath bits in place, removing the manually fudged packages I've already half arsed this in + we can revisit using gcc outside at a later time.

danielhams commented 4 years ago

First set of changes to move to rpath contained in f22140921d57b9897b2b684a74d4c0204f8af0cd.

So far so good, although some packages still have some hacky LDFLAGS to avoid using --as-needed as this causes linktime issues.

danielhams commented 4 years ago

Discovered the tweak needed in binutils to set the appropriate "search path".

Binutils ld by default was set to use /usr/local/lib:/lib:/usr/lib as the default search path. Coming tweak to ld means that by default the search path will be /usr/sgug/lib32:/usr/lib32:/lib32.

danielhams commented 4 years ago

Across the board rpath changes included, but leaving this open for a little bit to see if I've missing anything.

danielhams commented 4 years ago

This is mostly fixed. There still seems to be a remaining issue with gcc libraries not having the appropriate rpath.

dillera commented 1 year ago

Close due to age and it seems to be working. Deeper rpath fixes may not be in gcc land but perhaps llvm.