[vlc-commits] [Git][videolan/vlc][master] extras/tools: libtool: reference MAGIC_EXE in the main

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jun 16 08:34:29 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
3c4953e7 by Steve Lhomme at 2026-06-16T08:06:36+00:00
extras/tools: libtool: reference MAGIC_EXE in the main

It fixes .exe detection with LLVM-mingw when -flto is used.

"__attribute__((externally_visible)) volatile" doesn't seem to be enough.
The symbol is stripped anyway.
It's also stripped during linking when __attribute__((visibility("default"))) is used.

Referencing the string in the main() seems to do the trick, even when compiled
with -O2 or -Os.

Fixes #29922

- - - - -


3 changed files:

- Makefile.am
- + extras/tools/libtool-2.5.4-ltmain.in-reference-MAGIC_EXE-in-the-main.patch
- extras/tools/tools.mak


Changes:

=====================================
Makefile.am
=====================================
@@ -68,6 +68,7 @@ EXTRA_DIST += \
 	extras/tools/libtool-2.5.4-clang-libs.patch \
 	extras/tools/libtool-2.4.7-lpthread.patch \
 	extras/tools/libtool-2.5.4-embed-bitcode.patch \
+	extras/tools/libtool-2.5.4-ltmain.in-reference-MAGIC_EXE-in-the-main.patch \
 	extras/tools/ninja-1.11.1-replace-pipes-quote-with-shlex-quote.patch \
 	extras/tools/0001-CanonicalizePath-Remove-kMaxComponents-limit.patch \
 	extras/tools/0002-CanonicalizePath-fix-a-b-._foo-a-replacement.patch \
@@ -230,4 +231,3 @@ dist-hook:
 		"$(distdir)/configure" "$(distdir)/configure.ac"
 	touch -r "$mtime_ref" "$(distdir)/configure.ac"
 	rm "$mtime_ref"
-


=====================================
extras/tools/libtool-2.5.4-ltmain.in-reference-MAGIC_EXE-in-the-main.patch
=====================================
@@ -0,0 +1,32 @@
+From a7108558f5c05ae7fb4ac0d49f68d03ee43446f2 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 15 Jun 2026 09:03:12 +0200
+Subject: [PATCH] ltmain.in: reference MAGIC_EXE in the main
+
+It fixes .exe detection with LLVM-mingw when -flto is used.
+
+"__attribute__((externally_visible)) volatile" doesn't seem to be enough.
+The symbol is stripped anyway.
+It's also stripped during linking when __attribute__((visibility("default"))) is used.
+
+Referencing the string in the main() seems to do the trick, even when compiled with -O2 or -Os.
+---
+ build-aux/ltmain.in | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
+index ffd4c716..bf927f0c 100644
+--- a/build-aux/ltmain.in
++++ b/build-aux/ltmain.in
+@@ -3994,6 +3994,8 @@ main (int argc, char *argv[])
+ 
+   int i;
+ 
++  (void) MAGIC_EXE;
++
+   program_name = (char *) xstrdup (base_name (argv[0]));
+   newargz = XMALLOC (char *, (size_t) argc + 1);
+ 
+-- 
+2.52.0.windows.1
+


=====================================
extras/tools/tools.mak
=====================================
@@ -132,6 +132,7 @@ libtool: libtool-$(LIBTOOL_VERSION).tar.gz
 	$(APPLY) $(TOOLS)/libtool-2.5.4-embed-bitcode.patch
 
 	$(APPLY) $(TOOLS)/libtool-2.5.4-unarchive-old-libraries.patch
+	$(APPLY) $(TOOLS)/libtool-2.5.4-ltmain.in-reference-MAGIC_EXE-in-the-main.patch
 	$(MOVE)
 
 .buildlibtool: libtool .automake .help2man



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3c4953e746e19df5df04e4af36ebd17b2b73ce94

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3c4953e746e19df5df04e4af36ebd17b2b73ce94
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