Skip to content

Commit

Permalink
mesa: Use symlinks instead of hard links for the DRI/vdpau drivers
Browse files Browse the repository at this point in the history
This reduces the size of the drivers output from 193 MiB to 44 MiB.

@vcunat
  • Loading branch information
edolstra committed May 22, 2016
1 parent 3ee6b22 commit 1a52fdc
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgs/development/libraries/mesa/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ stdenv.mkDerivation {

patches = [
./glx_ro_text_segm.patch # fix for grsecurity/PaX
./symlink-drivers.patch
# TODO: revive ./dricore-gallium.patch when it gets ported (from Ubuntu),
# as it saved ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
] ++ optional stdenv.isLinux
Expand Down
72 changes: 72 additions & 0 deletions pkgs/development/libraries/mesa/symlink-drivers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
diff -ru -x '*~' mesa-11.1.4-orig/src/gallium/targets/dri/Makefile.am mesa-11.1.4/src/gallium/targets/dri/Makefile.am
--- mesa-11.1.4-orig/src/gallium/targets/dri/Makefile.am 2016-05-09 14:20:52.000000000 +0200
+++ mesa-11.1.4/src/gallium/targets/dri/Makefile.am 2016-05-22 17:56:03.396185082 +0200
@@ -126,14 +126,13 @@
done;
endif

-# hardlink each megadriver instance, but don't actually have
-# gallium_dri.so in the set of final installed files.
+# symlink each megadriver instance.
install-data-hook:
for i in $(TARGET_DRIVERS); do \
- ln -f $(DESTDIR)$(dridir)/gallium_dri.so \
+ ln -sf $(DESTDIR)$(dridir)/gallium_dri.so \
$(DESTDIR)$(dridir)/$${i}_dri.so; \
done; \
- $(RM) $(DESTDIR)$(dridir)/gallium_dri.*
+ $(RM) $(DESTDIR)$(dridir)/gallium_dri.la

uninstall-hook:
for i in $(TARGET_DRIVERS); do \
diff -ru -x '*~' mesa-11.1.4-orig/src/gallium/targets/vdpau/Makefile.am mesa-11.1.4/src/gallium/targets/vdpau/Makefile.am
--- mesa-11.1.4-orig/src/gallium/targets/vdpau/Makefile.am 2016-01-29 13:21:30.000000000 +0100
+++ mesa-11.1.4/src/gallium/targets/vdpau/Makefile.am 2016-05-22 20:54:12.722358242 +0200
@@ -103,15 +103,14 @@
done;
endif

-# hardlink each megadriver instance, but don't actually have
-# libvdpau_gallium.so in the set of final installed files.
+# symlink each megadriver instance.
install-data-hook:
$(AM_V_GEN)dest_dir=$(DESTDIR)/$(vdpaudir); \
for i in $(TARGET_DRIVERS); do \
j=libvdpau_gallium.$(LIB_EXT); \
k=libvdpau_$${i}.$(LIB_EXT); \
l=$${k}.$(VDPAU_MAJOR).$(VDPAU_MINOR).0; \
- ln -f $${dest_dir}/$${j}.$(VDPAU_MAJOR).$(VDPAU_MINOR).0 \
+ ln -sf $${dest_dir}/$${j}.$(VDPAU_MAJOR).$(VDPAU_MINOR).0 \
$${dest_dir}/$${l}; \
ln -sf $${l} \
$${dest_dir}/$${k}.$(VDPAU_MAJOR).$(VDPAU_MINOR); \
@@ -120,7 +119,7 @@
ln -sf $${l} \
$${dest_dir}/$${k}; \
done; \
- $(RM) $${dest_dir}/libvdpau_gallium.*
+ $(RM) $${dest_dir}/libvdpau_gallium.la

uninstall-hook:
for i in $(TARGET_DRIVERS); do \
diff -ru -x '*~' mesa-11.1.4-orig/src/mesa/drivers/dri/Makefile.am mesa-11.1.4/src/mesa/drivers/dri/Makefile.am
--- mesa-11.1.4-orig/src/mesa/drivers/dri/Makefile.am 2016-01-18 08:39:26.000000000 +0100
+++ mesa-11.1.4/src/mesa/drivers/dri/Makefile.am 2016-05-22 17:55:46.251244940 +0200
@@ -86,14 +86,13 @@
done;
endif

-# hardlink each megadriver instance, but don't actually have
-# mesa_dri_drivers.so in the set of final installed files.
+# symink each megadriver instance.
install-data-hook:
for i in $(MEGADRIVERS); do \
- ln -f $(DESTDIR)$(dridir)/mesa_dri_drivers.so \
+ ln -sf $(DESTDIR)$(dridir)/mesa_dri_drivers.so \
$(DESTDIR)$(dridir)/$$i; \
done;
- $(RM) $(DESTDIR)$(dridir)/mesa_dri_drivers.*
+ $(RM) $(DESTDIR)$(dridir)/mesa_dri_drivers.la

uninstall-hook:
for i in $(MEGADRIVERS); do \

2 comments on commit 1a52fdc

@vcunat
Copy link
Member

@vcunat vcunat commented on 1a52fdc May 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't check sizes for this one. It seems the size has grown on the beginning of March http://hydra.nixos.org/job/nixpkgs/trunk/mesa_drivers.x86_64-linux#tabs-charts, so we will probably want to pick to 16.03, e.g. after waiting for a while in case of problems. I wonder why they use hard links in the first place – I see no clue on the patches.

@vcunat
Copy link
Member

@vcunat vcunat commented on 1a52fdc Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Picked as 55b2e62.

Please sign in to comment.