]> mj.ucw.cz Git - pciutils.git/commitdiff
libpci: Define STATIC_ALIAS for DLL Windows builds
authorPali Rohár <pali@kernel.org>
Sat, 24 Feb 2024 15:12:26 +0000 (16:12 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 24 Feb 2024 19:47:05 +0000 (20:47 +0100)
Windows builds for versioned symbols use inline asm .set directive which in
some cases makes x86-64 LTO compiler to drop the referenced value. Define
STATIC_ALIAS macro with VERSIONED_ABI (used) attribute which forces LTO
compiler to not drop the symbol from the final DLL library.

lib/internal.h

index 549f94cf0d3d3f9b44d636b7ad369bd63dff173c..68e9fa0756c66114f296d0e7e05c72da70c3190e 100644 (file)
 #define DEFINE_ALIAS(_decl, _for)
 #define SYMBOL_VERSION(_int, _ext)
 #else
-#define STATIC_ALIAS(_decl, _for)
 #define DEFINE_ALIAS(_decl, _for) extern _decl __attribute__((alias(#_for))) VERSIONED_ABI
 #ifdef _WIN32
+#define STATIC_ALIAS(_decl, _for) VERSIONED_ABI _decl { return _for; }
 /* GCC does not support asm .symver directive for Windows targets, so define new external global function symbol as alias to internal symbol */
 #define SYMBOL_VERSION(_int, _ext) asm(".globl\t" PCI_STRINGIFY(__MINGW_USYMBOL(_ext)) "\n\t" \
                                        ".def\t"   PCI_STRINGIFY(__MINGW_USYMBOL(_ext)) ";\t.scl\t2;\t.type\t32;\t.endef\n\t" \
                                        ".set\t"   PCI_STRINGIFY(__MINGW_USYMBOL(_ext)) "," PCI_STRINGIFY(__MINGW_USYMBOL(_int)))
 #else
+#define STATIC_ALIAS(_decl, _for)
 #define SYMBOL_VERSION(_int, _ext) asm(".symver " #_int "," #_ext)
 #endif
 #endif