mingw-w64: “visibility attribute not supported in this configuration; ignored” under -flto #1421

issue fanquake openend this issue on September 6, 2023
  1. fanquake commented at 1:43 pm on September 6, 2023: member

    Building master (b10ddd2bd2bdce9ca8f2d4733636a9d9e7ac3da1):

     0# x86_64-w64-mingw32-gcc (GCC) 12-win32
     1./autogen.sh
     2./configure --host=x86_64-w64-mingw32 CFLAGS="-flto" LDFLAGS="-flto"
     3make -j9
     4<snip>
     5src/secp256k1.c: In function 'secp256k1_context_create':
     6src/secp256k1.c:149:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
     7  149 | }
     8      | ^
     9src/secp256k1.c: In function 'secp256k1_context_preallocated_clone':
    10src/secp256k1.c:160:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    11  160 | }
    12      | ^
    13src/secp256k1.c: In function 'secp256k1_context_clone':
    14src/secp256k1.c:173:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    15  173 | }
    16      | ^
    17src/secp256k1.c: In function 'secp256k1_context_preallocated_destroy':
    18src/secp256k1.c:184:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    19  184 | }
    20      | ^
    21src/secp256k1.c: In function 'secp256k1_context_destroy':
    22src/secp256k1.c:196:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    23  196 | }
    24      | ^
    25src/secp256k1.c: In function 'secp256k1_ec_pubkey_parse':
    26src/secp256k1.c:288:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    27  288 | }
    28      | ^
    29src/secp256k1.c: In function 'secp256k1_ec_pubkey_serialize':
    30src/secp256k1.c:311:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    31  311 | }
    32      | ^
    33< similar output continues>
    

    Wanted to raise this, as Core may eventually go down the LTO route (https://github.com/bitcoin/bitcoin/pull/25391), and -flto will be getting passed down.

  2. real-or-random commented at 5:05 pm on September 6, 2023: contributor

    Hm, thanks. It’s a bit mysterious that this happens only with -flto and only when compiling tests or noverify_tests, but for example not in the exhaustive_tests. But okay, whatever, apparently we hit that line here, which is supposed to be active only when not on Windows: https://github.com/bitcoin-core/secp256k1/blob/b10ddd2bd2bdce9ca8f2d4733636a9d9e7ac3da1/include/secp256k1.h#L159-L161

    We should probably just have a SECP256K1_TESTS #define and if this is defined, set nothing for symbol visibility.

  3. real-or-random added the label build on Sep 6, 2023
  4. real-or-random commented at 5:05 pm on September 6, 2023: contributor
    cc @hebasto , any further ideas here?
  5. hebasto commented at 10:49 am on September 8, 2023: member

    cc @hebasto , any further ideas here?

    I’m looking into it.


    Just a note about building with LTO using CMake:

    0cmake -B build -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON --toolchain cmake/x86_64-w64-mingw32.toolchain.cmake
    1cmake --build build
    
  6. hebasto commented at 1:50 pm on September 8, 2023: member

    The -flto-partition=1to1 option helps:

    0$ x86_64-w64-mingw32-gcc --version
    1x86_64-w64-mingw32-gcc (GCC) 12-posix
    2Copyright (C) 2022 Free Software Foundation, Inc.
    3This is free software; see the source for copying conditions.  There is NO
    4warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    5
    6$ ./autogen.sh
    7$ ./configure --host=x86_64-w64-mingw32 CFLAGS="-flto -flto-partition=1to1" LDFLAGS="-flto=auto"
    8$ make -j16
    

    From GCC docs:

    …‘1to1’ can be used as an workaround for various code ordering issues…

  7. real-or-random commented at 3:07 pm on September 11, 2023: contributor

    The -flto-partition=1to1 option helps:

    Hm, interesting and good to know. I guess, we should still make sure the build is clean with just -lto. Any suggestions here?

  8. real-or-random commented at 11:33 pm on August 24, 2024: contributor
  9. real-or-random referenced this in commit a22208e1f1 on Aug 24, 2024
  10. real-or-random referenced this in commit 5eb211a924 on Aug 24, 2024
  11. real-or-random referenced this in commit 6077065aa3 on Aug 25, 2024
  12. real-or-random referenced this in commit 447334cb06 on Sep 17, 2024
  13. real-or-random closed this on Oct 21, 2024

  14. real-or-random referenced this in commit f0868a9b3d on Oct 21, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me