https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116478
Bug ID: 116478 Summary: x86_64-w64-mingw32-gcc -flto should support and not warn about __attribute__ ((visibility("default"))) Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: public at timruffing dot de Target Milestone: --- We got an unexpected "visibility attribute not supported in this configuration" warning when compiling for mingw with LTO enabled. (Downstream bug: https://github.com/bitcoin-core/secp256k1/issues/1421) Here's a minimal test case: $ cat a.b __attribute__ ((visibility("default"))) void a(void) {} $ cat b.c void a(void); int main(void) { a(); } $ x86_64-w64-mingw32-gcc -flto=2 -flto-partition=max a.c b.c a.c: In function ‘a’: a.c:1:55: warning: visibility attribute not supported in this configuration; ignored [-Wattributes] 1 | __attribute__ ((visibility("default"))) void a(void) {} | I believe that the emitted warning reveals a bug. The attribute should be supported. The manual claims "Default visibility is supported everywhere.", see https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Common-Function-Attributes.html . It may be correct that the attribute has no effect, but then GCC should not warn about it. When running without -flto or with -flto-partition=1to1, the warning disappears. Note that -flto-partition=max is necessary to reproduce this in this minimal test case. When we encountered the bug in the wild, we got the warning even with the default -flto-partition=balanced, but like here, it disappeared with -flto-partition=1to1. The only other relevant bug I could find is bug 71286, but that seems to be a different issue. $ x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/lto-wrapper Target: x86_64-w64-mingw32 Configured with: /build/mingw-w64-gcc/src/gcc/configure --prefix=/usr --libexecdir=/usr/lib --target=x86_64-w64-mingw32 --with-bugurl=https://bugs.archlinux.org/ --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-shared --enable-static --enable-threads=posix --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-libstdcxx-filesystem-ts=yes --with-system-zlib --enable-cloog-backend=isl --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-sjlj-exceptions --with-dwarf2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.1.0 (GCC)