Skip to content

Commit

Permalink
SDL2: do not propagate private dependencies
Browse files Browse the repository at this point in the history
Fixes NixOS#41620 by adding libGL directory to libSDL2 runpath
  • Loading branch information
orivej committed Jul 2, 2018
1 parent 3db4ce9 commit ccfc0d5
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions pkgs/development/libraries/SDL2/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{ stdenv, lib, fetchurl, pkgconfig, audiofile
{ stdenv, lib, fetchurl, pkgconfig, pruneLibtoolFiles
, openglSupport ? false, libGL
, alsaSupport ? true, alsaLib
, x11Support ? true, libICE, libXi, libXScrnSaver, libXcursor, libXinerama, libXext, libXxf86vm, libXrandr
, x11Support ? true, libX11, xproto, libICE, libXi, libXScrnSaver, libXcursor, libXinerama, libXext, libXxf86vm, libXrandr
, waylandSupport ? true, wayland, wayland-protocols, libxkbcommon
, dbusSupport ? false, dbus
, udevSupport ? false, udev
, ibusSupport ? false, ibus
, pulseaudioSupport ? true, libpulseaudio
, AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL
, libiconv
, audiofile, libiconv
}:

# NOTE: When editing this expression see if the same change applies to
Expand All @@ -33,18 +33,26 @@ stdenv.mkDerivation rec {

patches = [ ./find-headers.patch ];

nativeBuildInputs = [ pkgconfig ];
nativeBuildInputs = [ pkgconfig pruneLibtoolFiles ];

propagatedBuildInputs = [ libiconv ]
propagatedBuildInputs = dlopenPropagatedBuildInputs;

dlopenPropagatedBuildInputs = [ ]
# Propagated for #include <GLES/gl.h> in SDL_opengles.h.
++ optional openglSupport libGL
# Propagated for #include <X11/Xlib.h> and <X11/Xatom.h> in SDL_syswm.h.
++ optionals x11Support [ libX11 xproto ];

dlopenBuildInputs = [ ]
++ optional alsaSupport alsaLib
++ optional dbusSupport dbus
++ optional pulseaudioSupport libpulseaudio
++ optional udevSupport udev
++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]
++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
++ optional alsaSupport alsaLib
++ optional pulseaudioSupport libpulseaudio;
++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ];

buildInputs = [ audiofile ]
++ optional openglSupport libGL
buildInputs = [ audiofile libiconv ]
++ dlopenBuildInputs
++ optional ibusSupport ibus
++ optionals stdenv.isDarwin [ AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL ];

Expand Down Expand Up @@ -76,12 +84,13 @@ stdenv.mkDerivation rec {
# SDL API that requires said libraries will fail to start.
#
# You can grep SDL sources with `grep -rE 'SDL_(NAME|.*_SYM)'` to
# confirm that they actually use most of the `propagatedBuildInputs`
# from above in this way. This is pretty weird.
postFixup = optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
# list the symbols used in this way.
postFixup = let
rpath = makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
in optionalString (stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
for lib in $out/lib/*.so* ; do
if ! [[ -L "$lib" ]]; then
patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath propagatedBuildInputs}" "$lib"
patchelf --set-rpath "$(patchelf --print-rpath $lib):${rpath}" "$lib"
fi
done
'';
Expand Down

0 comments on commit ccfc0d5

Please sign in to comment.