By doing GC the linker removes all the symbols that are not referenced and/or used by the final library. This results in a saving of ~100K up-to ~600K per (stripped) binary (classic vs gallium drivers).
If interested one can ask the compiler to print the sections that are removed using -Wl,--print-gc-sections. Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> --- src/egl/main/Makefile.am | 1 + src/egl/wayland/wayland-egl/Makefile.am | 1 + src/gallium/Automake.inc | 4 ++++ src/gallium/targets/egl-static/Makefile.am | 1 + src/gallium/targets/gbm/Makefile.am | 1 + src/gallium/targets/libgl-xlib/Makefile.am | 1 + src/gallium/targets/opencl/Makefile.am | 1 + src/gallium/targets/osmesa/Makefile.am | 1 + src/gallium/targets/pipe-loader/Makefile.am | 1 + src/gallium/targets/xa/Makefile.am | 1 + src/gbm/Makefile.am | 1 + src/glx/Makefile.am | 1 + src/mapi/es1api/Makefile.am | 1 + src/mapi/es2api/Makefile.am | 1 + src/mapi/shared-glapi/Makefile.am | 1 + src/mapi/vgapi/Makefile.am | 1 + src/mesa/drivers/dri/Makefile.am | 1 + src/mesa/drivers/osmesa/Makefile.am | 1 + src/mesa/drivers/x11/Makefile.am | 1 + 19 files changed, 22 insertions(+) diff --git a/src/egl/main/Makefile.am b/src/egl/main/Makefile.am index 57c9ccd..fa74811 100644 --- a/src/egl/main/Makefile.am +++ b/src/egl/main/Makefile.am @@ -77,6 +77,7 @@ libEGL_la_LDFLAGS = \ -no-undefined \ -version-number 1:0 \ -Wl,-Bsymbolic \ + -Wl,--gc-sections \ -Wl,--no-undefined if HAVE_EGL_PLATFORM_X11 diff --git a/src/egl/wayland/wayland-egl/Makefile.am b/src/egl/wayland/wayland-egl/Makefile.am index 3c2673a..264537d 100644 --- a/src/egl/wayland/wayland-egl/Makefile.am +++ b/src/egl/wayland/wayland-egl/Makefile.am @@ -11,6 +11,7 @@ libwayland_egl_la_SOURCES = wayland-egl.c libwayland_egl_la_LDFLAGS = \ -no-undefined \ -version-info 1 \ + -Wl,--gc-sections \ -Wl,--no-undefined TESTS = wayland-egl-symbols-check diff --git a/src/gallium/Automake.inc b/src/gallium/Automake.inc index 1151f91..65e06a0 100644 --- a/src/gallium/Automake.inc +++ b/src/gallium/Automake.inc @@ -57,6 +57,7 @@ GALLIUM_DRI_LINKER_FLAGS = \ -shared \ -module \ -avoid-version \ + -Wl,--gc-sections \ -Wl,--version-script=$(DRI_VERSION_SCRIPT) GALLIUM_VDPAU_LINKER_FLAGS = \ @@ -65,6 +66,7 @@ GALLIUM_VDPAU_LINKER_FLAGS = \ -no-undefined \ -version-number $(VDPAU_MAJOR):$(VDPAU_MINOR) \ -export-symbols-regex $(VDPAU_EXPORTS) \ + -Wl,--gc-sections \ -Wl,--no-undefined GALLIUM_XVMC_LINKER_FLAGS = \ @@ -73,6 +75,7 @@ GALLIUM_XVMC_LINKER_FLAGS = \ -no-undefined \ -version-number $(XVMC_MAJOR):$(XVMC_MINOR) \ -export-symbols-regex '^XvMC' \ + -Wl,--gc-sections \ -Wl,--no-undefined GALLIUM_OMX_LINKER_FLAGS = \ @@ -80,6 +83,7 @@ GALLIUM_OMX_LINKER_FLAGS = \ -module \ -no-undefined \ -export-symbols-regex $(EXPORTS) \ + -Wl,--gc-sections \ -Wl,--no-undefined GALLIUM_VDPAU_LIB_DEPS = \ diff --git a/src/gallium/targets/egl-static/Makefile.am b/src/gallium/targets/egl-static/Makefile.am index 55eb3ba..f981cdc 100644 --- a/src/gallium/targets/egl-static/Makefile.am +++ b/src/gallium/targets/egl-static/Makefile.am @@ -48,6 +48,7 @@ AM_LDFLAGS = \ -module \ -no-undefined \ -avoid-version \ + -Wl,--gc-sections \ -Wl,--no-undefined \ -Wl,--version-script=$(top_srcdir)/src/gallium/targets/egl-static/egl.link diff --git a/src/gallium/targets/gbm/Makefile.am b/src/gallium/targets/gbm/Makefile.am index c109ddb..b364e60 100644 --- a/src/gallium/targets/gbm/Makefile.am +++ b/src/gallium/targets/gbm/Makefile.am @@ -70,6 +70,7 @@ gbm_gallium_drm_la_LDFLAGS = \ -module \ -no-undefined \ -avoid-version \ + -Wl,--gc-sections \ -Wl,--no-undefined if HAVE_MESA_LLVM diff --git a/src/gallium/targets/libgl-xlib/Makefile.am b/src/gallium/targets/libgl-xlib/Makefile.am index d7aec7b..a7528ae 100644 --- a/src/gallium/targets/libgl-xlib/Makefile.am +++ b/src/gallium/targets/libgl-xlib/Makefile.am @@ -47,6 +47,7 @@ libGL_la_SOURCES = xlib.c libGL_la_LDFLAGS = \ -no-undefined \ -version-number $(GL_MAJOR):$(GL_MINOR):$(GL_TINY) \ + -Wl,--gc-sections \ -Wl,--no-undefined libGL_la_LIBADD = \ diff --git a/src/gallium/targets/opencl/Makefile.am b/src/gallium/targets/opencl/Makefile.am index b401d10..58b74ac 100644 --- a/src/gallium/targets/opencl/Makefile.am +++ b/src/gallium/targets/opencl/Makefile.am @@ -6,6 +6,7 @@ lib@OPENCL_LIBNAME@_la_LDFLAGS = \ $(LLVM_LDFLAGS) \ -no-undefined \ -version-number 1:0 \ + -Wl,--gc-sections \ -Wl,--no-undefined diff --git a/src/gallium/targets/osmesa/Makefile.am b/src/gallium/targets/osmesa/Makefile.am index 651fc5d..a0dd23e 100644 --- a/src/gallium/targets/osmesa/Makefile.am +++ b/src/gallium/targets/osmesa/Makefile.am @@ -43,6 +43,7 @@ lib@OSMESA_LIB@_la_LDFLAGS = \ -module \ -no-undefined \ -version-number @OSMESA_VERSION@ \ + -Wl,--gc-sections \ -Wl,--no-undefined diff --git a/src/gallium/targets/pipe-loader/Makefile.am b/src/gallium/targets/pipe-loader/Makefile.am index 00823fe..eba5127 100644 --- a/src/gallium/targets/pipe-loader/Makefile.am +++ b/src/gallium/targets/pipe-loader/Makefile.am @@ -49,6 +49,7 @@ AM_LDFLAGS = \ -module \ -no-undefined \ -avoid-version \ + -Wl,--gc-sections \ -Wl,--no-undefined \ -Wl,--version-script=$(top_srcdir)/src/gallium/targets/pipe-loader/pipe.link diff --git a/src/gallium/targets/xa/Makefile.am b/src/gallium/targets/xa/Makefile.am index 214c51d..606a031 100644 --- a/src/gallium/targets/xa/Makefile.am +++ b/src/gallium/targets/xa/Makefile.am @@ -67,6 +67,7 @@ endif libxatracker_la_LDFLAGS = \ -no-undefined \ -version-number $(XA_MAJOR):$(XA_MINOR):$(XA_TINY) \ + -Wl,--gc-sections \ -Wl,--no-undefined if HAVE_MESA_LLVM diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am index c71a974..1598bba 100644 --- a/src/gbm/Makefile.am +++ b/src/gbm/Makefile.am @@ -22,6 +22,7 @@ libgbm_la_SOURCES = \ libgbm_la_LDFLAGS = \ -no-undefined \ -version-info 1:0 \ + -Wl,--gc-sections \ -Wl,--no-undefined libgbm_la_LIBADD = \ diff --git a/src/glx/Makefile.am b/src/glx/Makefile.am index 0c99c07..e626933 100644 --- a/src/glx/Makefile.am +++ b/src/glx/Makefile.am @@ -112,6 +112,7 @@ GL_LDFLAGS = \ -no-undefined \ -version-number 1:2 \ -Wl,-Bsymbolic \ + -Wl,--gc-sections \ -Wl,--no-undefined lib@GL_LIB@_la_SOURCES = diff --git a/src/mapi/es1api/Makefile.am b/src/mapi/es1api/Makefile.am index b958118..47f53ed 100644 --- a/src/mapi/es1api/Makefile.am +++ b/src/mapi/es1api/Makefile.am @@ -47,6 +47,7 @@ libGLESv1_CM_la_LIBADD = $(GLESv1_CM_LIB_DEPS) libGLESv1_CM_la_LDFLAGS = \ -no-undefined \ -version-number 1:1 \ + -Wl,--gc-sections \ -Wl,--no-undefined if HAVE_SHARED_GLAPI diff --git a/src/mapi/es2api/Makefile.am b/src/mapi/es2api/Makefile.am index 1fb6d7c..f2802bc 100644 --- a/src/mapi/es2api/Makefile.am +++ b/src/mapi/es2api/Makefile.am @@ -51,6 +51,7 @@ libGLESv2_la_LIBADD = $(GLESv2_LIB_DEPS) libGLESv2_la_LDFLAGS = \ -no-undefined \ -version-number 2 \ + -Wl,--gc-sections \ -Wl,--no-undefined if HAVE_SHARED_GLAPI diff --git a/src/mapi/shared-glapi/Makefile.am b/src/mapi/shared-glapi/Makefile.am index 7e1068f..1a2e883 100644 --- a/src/mapi/shared-glapi/Makefile.am +++ b/src/mapi/shared-glapi/Makefile.am @@ -11,6 +11,7 @@ libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) libglapi_la_LIBADD = $(PTHREAD_LIBS) $(SELINUX_LIBS) libglapi_la_LDFLAGS = \ -no-undefined \ + -Wl,--gc-sections \ -Wl,--no-undefined include $(GLAPI)/gen/glapi_gen.mk diff --git a/src/mapi/vgapi/Makefile.am b/src/mapi/vgapi/Makefile.am index f85addc..0431d21 100644 --- a/src/mapi/vgapi/Makefile.am +++ b/src/mapi/vgapi/Makefile.am @@ -47,6 +47,7 @@ libOpenVG_la_LIBADD = $(VG_LIB_DEPS) libOpenVG_la_LDFLAGS = \ -no-undefined \ -version-number 1 \ + -Wl,--gc-sections \ -Wl,--no-undefined vgapi_tmp.h: $(srcdir)/vgapi.csv $(top_srcdir)/src/mapi/mapi_abi.py diff --git a/src/mesa/drivers/dri/Makefile.am b/src/mesa/drivers/dri/Makefile.am index 17ac76b..a34eafe 100644 --- a/src/mesa/drivers/dri/Makefile.am +++ b/src/mesa/drivers/dri/Makefile.am @@ -53,6 +53,7 @@ mesa_dri_drivers_la_SOURCES = mesa_dri_drivers_la_LDFLAGS = \ -module -avoid-version -shared \ -Wl,-Bsymbolic \ + -Wl,--gc-sections \ $() mesa_dri_drivers_la_LIBADD = \ ../../libmesa.la \ diff --git a/src/mesa/drivers/osmesa/Makefile.am b/src/mesa/drivers/osmesa/Makefile.am index cfab702..d79c6e5 100644 --- a/src/mesa/drivers/osmesa/Makefile.am +++ b/src/mesa/drivers/osmesa/Makefile.am @@ -39,6 +39,7 @@ lib@OSMESA_LIB@_la_LDFLAGS = \ -module \ -no-undefined \ -version-number @OSMESA_VERSION@ \ + -Wl,--gc-sections \ -Wl,--no-undefined diff --git a/src/mesa/drivers/x11/Makefile.am b/src/mesa/drivers/x11/Makefile.am index 4c63d59..9b48773 100644 --- a/src/mesa/drivers/x11/Makefile.am +++ b/src/mesa/drivers/x11/Makefile.am @@ -64,6 +64,7 @@ lib@GL_LIB@_la_LIBADD = \ lib@GL_LIB@_la_LDFLAGS = \ -no-undefined \ -version-number $(GL_MAJOR):$(GL_MINOR):$(GL_PATCH) \ + -Wl,--gc-sections \ -Wl,--no-undefined include $(top_srcdir)/install-lib-links.mk -- 1.9.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev