Bug 226403 - [PATCH] Fix for not being able to link against just "libGL.so" with x11/nvidia-driver
Summary: [PATCH] Fix for not being able to link against just "libGL.so" with x11/nvidi...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Alexey Dokuchaev
URL:
Keywords: easy, patch
: 231875 234876 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-03-06 20:14 UTC by Tatu Kilappa
Modified: 2019-01-18 18:01 UTC (History)
8 users (show)

See Also:
bugzilla: maintainer-feedback? (danfe)


Attachments
x11/nvidia-driver/Makefile - libGL.so, libEGL.so, libGLESv2.so rename fix (945 bytes, patch)
2018-03-06 20:14 UTC, Tatu Kilappa
no flags Details | Diff
x11/nvidia-driver/Makefile - updated patch (r2) (1.40 KB, patch)
2018-10-08 16:22 UTC, Tatu Kilappa
tatu.kilappa: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tatu Kilappa 2018-03-06 20:14:14 UTC
Created attachment 191260 [details]
x11/nvidia-driver/Makefile - libGL.so, libEGL.so, libGLESv2.so rename fix

I have found a problem in the Makefile of the nvidia-driver package.

At the end of processing, the files are renamed as follows:

${MV} -f ${STAGEDIR}${PREFIX}/lib/libGL.so \
    ${STAGEDIR}${PREFIX}/lib/libGL-NVIDIA.so

Ok, no name conflicts. That's nice. However, we also have a libmap
setting that looks like this:

libGL.so      libGL-NVIDIA.so
libGL.so.1    libGL-NVIDIA.so.1

Which means that anyone accessing libGL,so actually accesses
libGL-NVIDIA.so. However, since the directive in the makefile was a
move, libGL-NVIDIA.so, which is a symbolic link, will remain pointing
at libGL.so.1.

Now, libmap only does simple translation (see libmap.c under
src/libexec/rtld-elf) and does not follow any symbolic link paths in
the filesystem because at the time of translation, only the name of
the library - not its actual location - is known.

Unfortunately this means any program linking to libGL.so directly will
try to load libGL-NVIDIA.so, and then follow the symbolic link to
libGL.so.1 and then that symbolic link to libGL.so.1.2.0. Thus, any
program linking against libGL.so as opposed to libGL.so.1 will not
work since Nvidia and Mesa GL implementations obviously do not mix.

I propose changing the directive in the makefile to:

${LN} -sf libGL-NVIDIA.so.1 \
    ${STAGEDIR}${PREFIX}/lib/libGL-NVIDIA.so

This will mean that libGL-NVIDIA.so remains pointing at the same
library it was supposed to point at before the rename.

I have attached a patch that does this change, and then similar change
to libEGL-NVIDIA.so and libGLESv2.so, so everything will work.

NOTE: Most (almost all) GL programs work because they explicitly link
against libGL.so.1. However, I feel also the few that use libGL.so
without that extra .1 should also work.
Comment 1 Thibault Payet 2018-06-10 16:54:01 UTC
In addition to the link, the old files should be rm (since it was move before, to not have orphaned files)
Comment 2 Wesley Moore 2018-10-05 22:08:59 UTC
Just want to note this in case it helps someone else: I upgraded to the new GNOME 3.28 packages today and I believe gdm/gnome-session failed to start due to this issue. /var/log/gdm/:0-greeter.log showed these errors:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

(gnome-shell:1792): Clutter-CRITICAL **: 07:30:09.088: Unable to initialize Clutter: Unable to initialize the Clutter backend: no available drivers found.

After applying the Makefile patch attached to this bug I rebuilt the nvidia-driver port and GNOME is now working.
Comment 3 mvharding 2018-10-07 17:00:39 UTC
Same for me as well, this fixed the issue I reported in PR 231875.
Comment 4 John Hein 2018-10-08 14:03:13 UTC
(In reply to Thibault Payet from comment #1)

Tatu, can you regenerate the patch to resolve the problem with orphaned files (as detected by 'make check-plist'):

===> Checking for items in STAGEDIR missing from pkg-plist
Error: Orphaned: lib/libEGL.so
Error: Orphaned: lib/libGL.so
Error: Orphaned: lib/libGLESv2.so


Other than that, the patch seems right to me.

Maintainer timeout?
Comment 5 Tatu Kilappa 2018-10-08 16:22:18 UTC
Created attachment 197917 [details]
x11/nvidia-driver/Makefile - updated patch (r2)

Insofar I can see, since this file is not supposed to provide libGL.so, libEGL.so or libGLESv2.so, the Makefile should remove them from staging.

This updated patch should fix the pkg-plist discrepancy.
Comment 6 John Hein 2018-10-08 17:59:55 UTC
(In reply to Tatu Kilappa from comment #5)
Yes, something like that update (that removes the link) works fine.  Can you set the maintainer-approval flag for the patch to '?'?  I'd also mark reve 1 of the patch obsolete.
Comment 7 Tatu Kilappa 2018-10-08 20:21:39 UTC
Don't see a way to mark r1 of the patch obsolete, but I marked r2 as '?'.
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-01-18 17:53:50 UTC
A commit references this bug:

Author: tijl
Date: Fri Jan 18 17:53:00 UTC 2019
New revision: 490643
URL: https://svnweb.freebsd.org/changeset/ports/490643

Log:
  Recreate symlinks instead of renaming them, so they point to the right
  file.

  PR:		226403
  Submitted by:	Tatu Kilappa <tatu.kilappa@iki.fi>
  Approved by:	maintainer timeout (10 months)

Changes:
  head/x11/nvidia-driver/Makefile
  head/x11/nvidia-driver-304/Makefile
  head/x11/nvidia-driver-340/Makefile
Comment 9 Tijl Coosemans freebsd_committer freebsd_triage 2019-01-18 17:54:07 UTC
*** Bug 234876 has been marked as a duplicate of this bug. ***
Comment 10 Tijl Coosemans freebsd_committer freebsd_triage 2019-01-18 17:54:56 UTC
*** Bug 231875 has been marked as a duplicate of this bug. ***
Comment 11 commit-hook freebsd_committer freebsd_triage 2019-01-18 18:00:00 UTC
A commit references this bug:

Author: tijl
Date: Fri Jan 18 17:59:42 UTC 2019
New revision: 490644
URL: https://svnweb.freebsd.org/changeset/ports/490644

Log:
  MFH: r490643

  Recreate symlinks instead of renaming them, so they point to the right
  file.

  PR:		226403
  Submitted by:	Tatu Kilappa <tatu.kilappa@iki.fi>
  Approved by:	ports-secteam (blanket)

Changes:
_U  branches/2019Q1/
  branches/2019Q1/x11/nvidia-driver/Makefile
  branches/2019Q1/x11/nvidia-driver-304/Makefile
  branches/2019Q1/x11/nvidia-driver-340/Makefile