[gcc r17-3292] gcc/mingw32: Do not export `HOST_EXTRA_OBJS_SYMBOL`

Jonathan Yong via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:c7282ce59753dd809ca567d045dc356d56b88fe2

commit r17-3292-gc7282ce59753dd809ca567d045dc356d56b88fe2
Author: LIU Hao <[email protected]>
Date:   Mon Aug 10 13:56:09 2026 +0800

    gcc/mingw32: Do not export `HOST_EXTRA_OBJS_SYMBOL`
    
    When building with `--enable-plugin`, the linker is passed `--export-all-symbols`
    so it attempts to export `HOST_EXTRA_OBJS_SYMBOL` which is an artificial symbol
    and is not prefixed with an underscore. For i686, the convention is that if the
    linker is told to export `foo`, it looks for `_foo`. Therefore in this case it
    attempts to export `_HOST_EXTRA_OBJS_SYMBOL` which isn't defined:
    
       ld.exe: cannot export HOST_EXTRA_OBJS_SYMBOL: symbol not found
       collect2.exe: error: ld returned 1 exit status
    
    Since this symbol is only used to create a reference to pull in the manifest
    resource for an image, the fix is to mark it as `visibility("hidden")` so it
    will not be exported, despite `--export-all-symbols`.
    
    In addition, since this is a C++ file, `extern "C"` is added for correctness.
    
    gcc/ChangeLog:
    
            * config/i386/sym-mingw32.cc: Add `extern "C"` and `visibility("hidden")`.
    
    Signed-off-by: Jonathan Yong <[email protected]>

Diff:
---
 gcc/config/i386/sym-mingw32.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/config/i386/sym-mingw32.cc b/gcc/config/i386/sym-mingw32.cc
index 2f8dee6c1ecd..5403dd2cfe98 100644
--- a/gcc/config/i386/sym-mingw32.cc
+++ b/gcc/config/i386/sym-mingw32.cc
@@ -1,3 +1,4 @@
 /* Prevent any name mangling to make sure that the linker
    will always find the symbol. */
+extern "C" __attribute__ ((visibility ("hidden")))
 char HOST_EXTRA_OBJS_SYMBOL asm ("HOST_EXTRA_OBJS_SYMBOL");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.