-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shlibs functionnality should be arch dependant #2331
Comments
I've just opened #2333 which is a first step towards making pkg's shlib features work in the presence of lib32. I believe the next step is to append the architecture of the I think this approach is preferable over modifying the pkgbase bits of the src/ build system to append additional metadata to lib32 packages or otherwise try to solve https://bugs.freebsd.org/bugzilla//show_bug.cgi?id=265061 outside of pkg. |
This is very straightforward. Please also consider future-proofing any approach taken by considering kernel modules similar to shared libraries. |
hum I think kernel modules should use the regular provides/requires (which didn't exist at the time we the the shlibs) |
Doesn't pkg already allow specifying |
yes this is how it should be done, imho, one could argue we should do the same for shlibs_* aka deprecate shlibs_* and use the regular provides/requires, the only reason why not to do it, that the backup library functionality depends on it. (aka we only backup libraries which are marked as "provided" there are also rooms of thinking here on how this should be done) |
note: #1048 this should be taken in consideration is someone is working on improving the shlibs provides/requires |
I don't know if anyone is working on this right now, if not, I will start working on this. What I propose to do is the following, keep as is anything which matches the ABI of the host aka what we currently have. @emaste @evadot @ifreund @kevemueller am I missing anything ? For example nvidia drivers whill provide:
|
linux_base-rl9 on amd64 will provide:
|
Maybe it will be easier to split the tag, something like (Linux)(32) or (Linux,32) etc ... |
I started working on this but paused work to do some higher level design thinking. I see two alternative paths we could take with this feature that I wanted to explore and discuss before starting down one of them. I'll finish up the writeup I intended to post to this issue shortly. (I should have finished it last week, but I got sick) |
I'll wait for your proposal |
I see two alternative options pkg could choose for its shlib handling: Option 1: Try to duplicate ld-elf.so search orderThis is the goal pkg currently seems to be working towards (#1048) From
In order to get the shlibs_provided/shlibs_required feature closer to the
If Option 2: only track shared objects in "standard" search pathsGet rid of shlibs_provided/shlibs_required as a pkg feature. This approach intentionally ignores DT_RPATH and DT_RUNPATH as they cannot be tracked without a special shlibs_required/shlibs_provided feature. Define "standard" search paths based on the target system. On FreeBSD define "standard" search paths as the output of Note that on FreeBSD packages can add their own "standard" paths by installing a file containing a list of paths to /usr/local/libdata/ldconfig/foo. On
If Advantages/DisadvantagesOverall the first option is more complex but gets closer to the actual runtime linker's behavior. I think the second option likely has better UX since it uses the more general provides/requires mechanism and doesn't require the user to know the runtime linker search order to determine whether a shlibs_required is fulfilled by a The main downside of the second option is of course that DT_RPATH and DT_RUNPATH would need to be handled manually by the porter (e.g. by adding a explicit dependency) rather than automatically by pkg. I personally think this is a Other notes:
|
I think the second case is also the less complex to undertsand/debug so I am fine with the second case, about the RUNPATH, having a special case with hard dependencies for such case is perfectly fine. right now what we have is closer to the option 2 we read the elf hints to get the known ldconfig path, and lookup there we lookup for RUNPATH as well, and this is imho fine (we could arguably drop entirely the RUNPATH but that is another storry). Regarding the solver provides/requires and shlibs_provides/shlibs_required are already working the same way, the only difference is they are in 2 separated fields, which in terms of UX is kind of convenient, I don't think eliminating one would simplify anything, but if it does, then so be it. |
Yeah, "Option 2" is pretty much identical to what you proposed. It just spells out more of the details of how it should actually be implemented.
Indeed, I think this is mostly a UX question in the end. What would you think about using a namespace for shared library provides/requires (e.g. This could be potentially extended in the future for pkg-config provides/requires files ( |
i like namespaces |
When looking at pkg_elf I noticed and very much disliked ld.so.hints parsing. This is an absolutely non-portable way of handling things, but I am the 1‰ here. In my use-case the (FreeBSD) packages are created and used completely outside FreeBSD, no way I can have an ld.so.hints lying around. Namespaces also solve my previous request for Happy to write the Mach-O update after the work was done for ELF (I would like to keep the code close in its logic). |
Btw. standard search paths are a happy route with Mach-O, as I could just handle |
I think the approach of ignoring RPATH/RUNPATH and sticking to standard search paths is great for 99% percent of packages and significantly reduces complexity. However, we do need to allow the user creating a package to override the automatically generated provides/requires for shlibs if a program relies on rpaths or has other unusual properties. I think that this can be supported with a few additions to the manifest format:
Does this sound sufficient to integrate with the ports tree? Is the a better way to expose this functionality? |
After writing the unit tests in #2372 I now understand better what pkg_elf tries to do. I honestly disagree with the approach. I propose the following paradigm shift in handline requires/provides.
Advantages
Disadvantages
|
I 100% agree that the current approach of ALLOW_BASE_SHLIBS is bad. It wouldn't exist at all in a post-pkgbase world and makes cross-building packages from a non-FreeBSD host quite problematic. I had more or less written it off as a necessary evil to be tolerated until pkgbase rules all but I like your general idea. I think there are some simplifications that can be made though, here's the approach I would propose:
|
I do like @ifreund proposal to remove ALLOW_BASE_SHLIBS (which yes is a giant hack) |
Ah, this seems like a good approach to me. You're right that dynamically creating a package is overkill, supplying a simple list of system-provided shlibs to the solver would hardly increase the complexity. |
I have merged all the pending code. Note that the fact the elf analysis does not work for all OSes is due to the code look for elfhints, to it is very FreeBSD and dragonfly specific so it fails as finding for example libc.so.8 for dragonfly binary running pkg create on freebsd and fails at finding libc.so.6 binary for linux on FreeBSD. this part of the code needs to be more cross os friendly. |
I agree, I've been thinking about this more and I think with the new idea for how to get rid of ALLOW_BASE_SHLIBS we can stop using elfhints at all for the generation of shlib provides/requires entries. Instead, we could add a set of options that provide pkg with lists of paths to scan for provided shared libraries. I think the following would be sufficient for now:
These could be automatically populated by the FreeBSD ports system based on the existing USE_LDCONFIG or If we take this path, the only place we might still want to keep using elfhints is the code to backup shared libraries if BACKUP_LIBRARIES is set. Reading the elfhints file to determine paths that need backup seems straightforward but there are likely other options we could take here. I'll give this case a bit more thought. |
I would like to continue along my initial proposal that was confirmed by @bapt and @ifreund to simplify ELF parsing at package creation time. As this is a major change, I suggest to implement it alongside current ELF functionality. The proposed new way for ELF is deemed to have less (no?) impact on users with ALLOW_BASE_SHLIBS=yes, which is not the default and allows to gain experience with a limited risk exposure. @bapt do you agree on going ahead like this? |
I think we should entirely nuke the ALLOW_BASE_SHLIBS, no fallback, we should test if a predictable file belong to a package "uname"? if yes then we consider we are using pkgbase and nothing to do, if not we scan /lib and /usr/lib to propulate the list of provided libs (this is for the solver). Now regarding the provided/required shlibs, I think what we should do now, nuke the rpath and elfhints thing. As stated this is not portable. which means where pkg scans an elf file it should expose all its DT_NEEDED as required if not provided by itself. This will simplify a lot the code inside pkg as well as making it portable. |
Yes, I started implementing the approach described by @bapt in #2331 (comment) and #2331 (comment) |
All shared objects NEEDED by an ELF file are added to shlibs_required by pkg-create rather than filtering them based on the host system ELF hints file and installed libraries. The ALLOW_BASE_SHLIBS option is deprecated and ignored. Before running the solver, pkg now scans /lib and /usr/lib (taking --rootdir into account) and builds a list of system-provided shlibs that is used as an input to the solver. If pkg detects that it is targeting a pkgbase system this scan for system shlibs is skipped as the base packages will provide all necessary shlibs. The detection of a pkgbase system is implemented by checking if /usr/bin/uname is tracked in the pkg database. The main user-facing change is that pkg-create now adds *all* shared objects listed as NEEDED by an ELF file to shlibs_required. In general this should not cause issues due to the solver taking the shlibs provided by the base system into account but there may be exceptions. An option to filter these entries will be added in the next commit. References: freebsd#2331 Sponsored by: The FreeBSD Foundation
All shared objects NEEDED by an ELF file are added to shlibs_required by pkg-create rather than filtering them based on the host system ELF hints file and installed libraries. The ALLOW_BASE_SHLIBS option is deprecated and ignored. Before running the solver, pkg now scans /lib and /usr/lib (taking --rootdir into account) and builds a list of system-provided shlibs that is used as an input to the solver. If pkg detects that it is targeting a pkgbase system this scan for system shlibs is skipped as the base packages will provide all necessary shlibs. The detection of a pkgbase system is implemented by checking if /usr/bin/uname is tracked in the pkg database. The main user-facing change is that pkg-create now adds *all* shared objects listed as NEEDED by an ELF file to shlibs_required. In general this should not cause issues due to the solver taking the shlibs provided by the base system into account but there may be exceptions. An option to filter these entries will be added in the next commit. References: freebsd#2331 Sponsored by: The FreeBSD Foundation
shlibs_provides vs shlibs_requires should take in account the ABI to avoid issue between lib32 and non lib32
Also when backing up libs, we should have compat & compat32 taken in account.
The text was updated successfully, but these errors were encountered: