GCC MinGW32: Do not export HOST_EXTRA_OBJS_SYMBOL
Prevents linker errors by hiding an artificial symbol in MinGW32 builds.
GCC MinGW32 builds with --enable-plugin encountered linker errors because HOST_EXTRA_OBJS_SYMBOL, an artificial symbol, was being exported. The linker, expecting symbols prefixed with an underscore for the i686 architecture, tried to export _HOST_EXTRA_OBJS_SYMBOL which was undefined. This change marks the symbol with visibility("hidden") to prevent its export, resolving the build failures. extern "C" was also added for C++ correctness.
In Details
The HOST_EXTRA_OBJS_SYMBOL in sym-mingw32.cc is used to implicitly pull in the manifest resource for an image. When --export-all-symbols is enabled during the build, the linker attempts to export all symbols. For i686, ld.exe expects a leading underscore for exported symbols, leading to a lookup for _HOST_EXTRA_OBJS_SYMBOL. Since this symbol is artificial and not intended for export, marking it with visibility("hidden") prevents it from being included in the export list, thus avoiding the linker error.
- MinGW32
- A software development environment which provides a Microsoft Windows API-compatible set of libraries and header files. It allows C, C++, and other programming languages to be used to develop native Windows applications.
- HOST_EXTRA_OBJS_SYMBOL
- An artificial symbol used in GCC's MinGW32 configuration to ensure that a manifest resource is linked into the final executable. It's not a regular code symbol and should not be exported.
- visibility("hidden")
- A symbol attribute that specifies the symbol should not be exported from a shared library or executable, making it internal to the compilation unit. This is used to control symbol visibility and prevent name mangling conflicts or unintended exports.
- extern "C"
- A linkage specification in C++ that tells the compiler to use C linkage conventions for the declared functions or variables. This is necessary when interfacing C++ code with C code or when dealing with symbols that should not be name-mangled by the C++ compiler.