[vlc-commits] [Git][videolan/vlc][master] 7 commits: configure: enable split sections + dead section stripping by default
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Oct 6 07:55:15 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
39b93e69 by Steve Lhomme at 2026-10-06T07:27:26+00:00
configure: enable split sections + dead section stripping by default
You can use --disable-split-sections to turn it of for all VLC code.
- - - - -
44b0fee6 by Steve Lhomme at 2026-10-06T07:27:26+00:00
contrib: add --enable-sections option
To turn on -fdata-sections -ffunction-sections compiler flags.
- - - - -
9c7f8aa0 by Steve Lhomme at 2026-10-06T07:27:26+00:00
contrib: gmp: disable fdata-sections/ffunction-sections in Windows builds
It fails to link with some "foo" code.
It may be a Windows-only problem so only remove the flags on Windows.
- - - - -
8983beda by Steve Lhomme at 2026-10-06T07:27:26+00:00
package/win32: add -fdata-sections -ffunction-sections to contribs
When combined with -gc-sections in the linker it can significantly reduce the
size of binaries.
- - - - -
a5036600 by Steve Lhomme at 2026-10-06T07:27:26+00:00
package/macosx: add -fdata-sections -ffunction-sections to contribs
When combined with -gc-sections in the linker it can significantly reduce the
size of binaries.
- - - - -
3d44cfaf by Steve Lhomme at 2026-10-06T07:27:26+00:00
package/snap: add -fdata-sections -ffunction-sections to contribs
When combined with -gc-sections in the linker it can significantly reduce the
size of binaries.
- - - - -
c9e59e85 by Steve Lhomme at 2026-10-06T07:27:26+00:00
meson: enable split sections + dead section stripping by default
You can use --disable-split-sections to turn it of for all VLC code.
It saves space on the binaries.
- - - - -
14 changed files:
- bin/meson.build
- configure.ac
- contrib/bootstrap
- contrib/src/gmp/rules.mak
- contrib/src/main.mak
- extras/package/macosx/build.sh
- extras/package/snap/snapcraft.yaml
- extras/package/win32/build.sh
- lib/meson.build
- meson.build
- meson_options.txt
- modules/meson.build
- modules/video_output/meson.build
- src/meson.build
Changes:
=====================================
bin/meson.build
=====================================
@@ -43,6 +43,7 @@ if build_vlc and (host_system != 'darwin' or have_osx) and not have_win_store an
executable('vlc',
vlc_sources + vlc_win_extra,
link_with: [libvlc, libvlccore],
+ link_args: gc_sections_linkargs,
include_directories: [vlc_include_dirs],
dependencies: vlc_deps,
install: true,
@@ -56,6 +57,7 @@ if build_vlc and (host_system != 'darwin' or have_osx) and not have_win_store an
executable('vlc-static',
vlc_sources,
link_with: [libvlc, libvlccore],
+ link_args: gc_sections_linkargs,
include_directories: [vlc_include_dirs],
dependencies: vlc_deps,
c_args: [vlc_top_builddir_def, vlc_top_srcdir_def],
@@ -66,6 +68,7 @@ if build_vlc and (host_system != 'darwin' or have_osx) and not have_win_store an
vlc_cache_gen_dep = executable('vlc-cache-gen',
['cachegen.c'] + vlc_win_extra,
link_with: [vlc_libcompat, libvlc],
+ link_args: gc_sections_linkargs,
include_directories: [vlc_include_dirs],
install: true,
install_dir: pkglibexecdir_path,
@@ -94,6 +97,7 @@ if build_vlc and (host_system != 'darwin' or have_osx) and not have_win_store an
executable('vlc-preparser',
vlc_preparser_sources + vlc_win_extra,
link_with: [libvlc, libvlccore, vlc_libcompat],
+ link_args: gc_sections_linkargs,
include_directories: [vlc_include_dirs],
dependencies: vlc_deps,
install: true,
@@ -104,6 +108,7 @@ if build_vlc and (host_system != 'darwin' or have_osx) and not have_win_store an
vlc_preparser_static_dep = executable('vlc-preparser-static',
vlc_preparser_sources + vlc_win_extra,
link_with: [libvlc, libvlccore, vlc_libcompat],
+ link_args: gc_sections_linkargs,
include_directories: [vlc_include_dirs],
dependencies: vlc_deps,
c_args: [vlc_top_builddir_def, vlc_top_srcdir_def],
=====================================
configure.ac
=====================================
@@ -512,6 +512,25 @@ AS_IF([test -n "${GC_SECTIONS_LDFLAGS}"],
[AC_MSG_RESULT([none])])
AC_SUBST([GC_SECTIONS_LDFLAGS])
+AC_ARG_ENABLE([split-sections],
+ AS_HELP_STRING([--split-sections],
+ [Split compiled sections and remove unused ones (default enabled)]))
+AS_IF([test "${enable_split_sections}" != "no" ], [
+ AS_IF([test -z "${GC_SECTIONS_LDFLAGS}"], [
+ AS_IF([test -n "${enable_split_sections}"], [
+ AC_MSG_ERROR([Split sections enabled but not supported by linker!])
+ ],[
+ AC_MSG_WARN([Split sections enabled but not supported by linker.])
+ ])
+ ],[
+ AX_APPEND_FLAG([${GC_SECTIONS_LDFLAGS}], [LDFLAGS])
+ AX_CHECK_COMPILE_FLAG([-fdata-sections -ffunction-sections], [
+ AX_APPEND_FLAG([-fdata-sections -ffunction-sections], [CFLAGS])
+ AX_APPEND_FLAG([-fdata-sections -ffunction-sections], [CXXFLAGS])
+ ])
+ ])
+])
+
dnl WinRT
AC_ARG_ENABLE([winstore_app],
AS_HELP_STRING([--enable-winstore-app],
=====================================
contrib/bootstrap
=====================================
@@ -38,6 +38,7 @@ usage()
echo " --enable-lto use Link Time Optimization"
echo " --enable-pdb generate debug information in PDB format"
echo " --enable-bitcode generate bitcode information"
+ echo " --enable-sections enable section splitting with compiler"
}
BUILD=
@@ -54,6 +55,7 @@ AD_CLAUSES=
WITH_OPTIMIZATION="1"
ENABLE_PDB=
ENABLE_BITCODE=
+ENABLE_SECTION_SPLIT=
while test -n "$1"
do
@@ -92,6 +94,9 @@ do
--enable-bitcode)
ENABLE_BITCODE=1
;;
+ --enable-sections)
+ ENABLE_SECTION_SPLIT=1
+ ;;
--enable-small)
ENABLE_SMALL=1
;;
@@ -264,6 +269,7 @@ test -z "$AD_CLAUSES" || add_make_enabled "AD_CLAUSES"
test -z "$WITH_OPTIMIZATION" || add_make_enabled "WITH_OPTIMIZATION"
test -z "$ENABLE_LTO" || add_make_enabled "ENABLE_LTO"
test -z "$ENABLE_PDB" || add_make_enabled "ENABLE_PDB"
+test -z "$ENABLE_SECTION_SPLIT" || add_make_enabled "ENABLE_SECTION_SPLIT"
LN_S="ln -s"
=====================================
contrib/src/gmp/rules.mak
=====================================
@@ -14,7 +14,12 @@ GMP_CONF += --disable-assembly
endif
endif
# gmp requires C99 and is _not_ forward-compatible with C23.
+ifdef HAVE_WIN32
+# disable sections splitting as it fails to link with "foo"
+GMP_CONF += CFLAGS="$(CFLAGS_NO_SECTIONS) -std=gnu99"
+else
GMP_CONF += CFLAGS="$(CFLAGS) -std=gnu99"
+endif
ifdef HAVE_WIN32
ifeq ($(ARCH),arm)
=====================================
contrib/src/main.mak
=====================================
@@ -386,6 +386,16 @@ CFLAGS := $(CFLAGS) -fembed-bitcode
CXXFLAGS := $(CXXFLAGS) -fembed-bitcode
endif
+# opt-out flags when --enable-sections is used
+CFLAGS_NO_SECTIONS := $(CFLAGS)
+CXXFLAGS_NO_SECTIONS := $(CXXFLAGS)
+
+ifdef ENABLE_SECTION_SPLIT
+CFLAGS := $(CFLAGS) -fdata-sections -ffunction-sections
+CXXFLAGS := $(CXXFLAGS) -fdata-sections -ffunction-sections
+endif
+
+
# Add these flags after CMake consumed the CFLAGS/CXXFLAGS
# CMake handles the optimization level with CMAKE_BUILD_TYPE
# CMake handles LTO flags with INTERPROCEDURAL_OPTIMIZATION
@@ -412,6 +422,9 @@ AUTOTOOLS_CFLAGS := $(AUTOTOOLS_CFLAGS) -flto
AUTOTOOLS_CXXFLAGS := $(AUTOTOOLS_CXXFLAGS) -flto
endif
+CFLAGS_NO_SECTIONS := $(CFLAGS_NO_SECTIONS) $(AUTOTOOLS_CFLAGS)
+CXXFLAGS_NO_SECTIONS := $(CXXFLAGS_NO_SECTIONS) $(AUTOTOOLS_CFLAGS)
+
HOSTVARS := $(HOSTTOOLS) \
CPPFLAGS="$(CPPFLAGS)" \
CFLAGS="$(CFLAGS) $(AUTOTOOLS_CFLAGS)" \
=====================================
extras/package/macosx/build.sh
=====================================
@@ -192,6 +192,8 @@ case $LICENSE in
;;
esac
+CONTRIBFLAGS="$CONTRIBFLAGS --enable-sections"
+
if [ "$REBUILD" = "yes" ]; then
rm -rf contrib-$HOST_TRIPLET
rm -rf $HOST_TRIPLET
=====================================
extras/package/snap/snapcraft.yaml
=====================================
@@ -82,6 +82,7 @@ parts:
cd contrib && mkdir linux && cd linux
../bootstrap \
--host=${CRAFT_ARCH_TRIPLET_BUILD_FOR} \
+ --enable-sections \
--enable-libdsm \
--enable-dvdcss
if [ -v VLC_PREBUILT_CONTRIBS_URL ]; then
=====================================
extras/package/win32/build.sh
=====================================
@@ -405,6 +405,8 @@ if [ -n "$WITH_LTO" ]; then
CONTRIBFLAGS="$CONTRIBFLAGS --enable-lto"
fi
+CONTRIBFLAGS="$CONTRIBFLAGS --enable-sections"
+
if [ "$COMPILING_WITH_CLANG" -gt 0 ]; then
# avoid using gcc-ar with the clang toolchain, if both are installed
VLC_AR="$TRIPLET-ar"
=====================================
lib/meson.build
=====================================
@@ -51,6 +51,7 @@ libvlc = library('vlc',
include_directories: [vlc_include_dirs],
c_args: libvlc_cargs,
link_with: [vlc_libcompat],
+ link_args: gc_sections_linkargs,
dependencies: [libvlccore_dep, m_lib, threads_dep],
install: true,
install_dir: libdir_path,
=====================================
meson.build
=====================================
@@ -907,11 +907,13 @@ endif
# Drops unused symbols.
# ELF linkers use --gc-sections, while Mach-O uses -dead_strip.
gc_sections_linkargs = []
+if get_option('split_sections').allowed()
if cc.has_link_argument('-Wl,--gc-sections')
gc_sections_linkargs += '-Wl,--gc-sections'
elif cc.has_link_argument('-Wl,-dead_strip')
gc_sections_linkargs += '-Wl,-dead_strip'
endif
+endif
# Check for struct sockaddr_storage type
# Define it to `sockaddr` if missing
=====================================
meson_options.txt
=====================================
@@ -95,6 +95,12 @@ option('avx',
value : 'auto',
description : 'AVX (1-2) optimizations')
+option('split_sections',
+ type : 'feature',
+ value : 'auto',
+ description : 'Split compiled sections and remove unused ones')
+
+
# TODO: Missing neon option
# TODO: Missing sve option
# TODO: Missing altivec option
=====================================
modules/meson.build
=====================================
@@ -170,6 +170,7 @@ if pipewire_dep.found()
include_directories: [include_directories('audio_output'), vlc_include_dirs],
dependencies: [libvlccore_dep, pipewire_dep],
link_with: [vlc_libcompat],
+ link_args: gc_sections_linkargs,
install: true,
install_dir: libdir_path,
)
@@ -184,6 +185,7 @@ if pulse_dep.found()
include_directories: [include_directories('audio_output'), vlc_include_dirs],
dependencies: [libvlccore_dep, pulse_dep],
link_with: [vlc_libcompat],
+ link_args: gc_sections_linkargs,
install: true,
install_dir: libdir_path,
)
@@ -387,6 +389,7 @@ if get_option('qt').allowed() and qt6_dep.found()
files('gui/qt/vlc-qt-check.cpp'),
dependencies: [qt6_dep, qt_extra_deps],
include_directories: [vlc_include_dirs],
+ link_args: gc_sections_linkargs,
build_by_default: enable_qt_check,
install: enable_qt_check,
install_dir: pkglibexecdir_path,
@@ -495,7 +498,7 @@ foreach module : vlc_modules
module['name'] + '_plugin',
module['sources'] + win_extra_sources,
link_with: [module.get('link_with', []), vlc_libcompat],
- link_args: module.get('link_args', []),
+ link_args: [module.get('link_args', []), symbolic_linkargs, gc_sections_linkargs],
link_depends: module.get('link_depends', []),
include_directories: [module.get('include_directories', []), vlc_include_dirs],
dependencies: [module.get('dependencies', []), libvlccore_dep],
=====================================
modules/video_output/meson.build
=====================================
@@ -258,6 +258,7 @@ if xcb_dep.found()
vlc_xcb_events_lib = library('vlc_xcb_events',
files('xcb/events.c'),
include_directories: [vlc_include_dirs],
+ link_args: gc_sections_linkargs,
dependencies: [xcb_dep, libvlccore_dep],
install: true,
install_dir: pkglibdir_path,
=====================================
src/meson.build
=====================================
@@ -509,6 +509,7 @@ libvlccore = library(
c_args: vlccore_cargs,
link_args: libvlccore_link_args,
link_with: [vlc_libcompat],
+ link_args: gc_sections_linkargs,
dependencies: libvlccore_deps,
install: true,
install_dir: libdir_path,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3cbd8b43a5a8760e8f1887c707b0373404ef31e1...c9e59e8575a3249ad9e13418ba06fcfd76e27eea
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3cbd8b43a5a8760e8f1887c707b0373404ef31e1...c9e59e8575a3249ad9e13418ba06fcfd76e27eea
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list