Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fanquake opened this issue Sep 6, 2023 · 6 comments · Fixed by #1595
Closed
Labels

Comments

@fanquake
Copy link
Member

fanquake commented Sep 6, 2023

Building master (b10ddd2):

# x86_64-w64-mingw32-gcc (GCC) 12-win32
./autogen.sh
./configure --host=x86_64-w64-mingw32 CFLAGS="-flto" LDFLAGS="-flto"
make -j9
<snip>
src/secp256k1.c: In function 'secp256k1_context_create':
src/secp256k1.c:149:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  149 | }
      | ^
src/secp256k1.c: In function 'secp256k1_context_preallocated_clone':
src/secp256k1.c:160:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  160 | }
      | ^
src/secp256k1.c: In function 'secp256k1_context_clone':
src/secp256k1.c:173:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  173 | }
      | ^
src/secp256k1.c: In function 'secp256k1_context_preallocated_destroy':
src/secp256k1.c:184:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  184 | }
      | ^
src/secp256k1.c: In function 'secp256k1_context_destroy':
src/secp256k1.c:196:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  196 | }
      | ^
src/secp256k1.c: In function 'secp256k1_ec_pubkey_parse':
src/secp256k1.c:288:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  288 | }
      | ^
src/secp256k1.c: In function 'secp256k1_ec_pubkey_serialize':
src/secp256k1.c:311:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
  311 | }
      | ^
< similar output continues>

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

@real-or-random
Copy link
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:

# if defined(__GNUC__) && (__GNUC__ >= 4) && defined(SECP256K1_BUILD)
/* Building libsecp256k1 on non-Windows using GCC or compatible. */
# define SECP256K1_API extern __attribute__ ((visibility ("default")))

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

@real-or-random
Copy link
Contributor

real-or-random commented Sep 6, 2023

cc @hebasto , any further ideas here?

@hebasto
Copy link
Member

hebasto commented Sep 8, 2023

cc @hebasto , any further ideas here?

I'm looking into it.


Just a note about building with LTO using CMake:

cmake -B build -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON --toolchain cmake/x86_64-w64-mingw32.toolchain.cmake
cmake --build build

@hebasto
Copy link
Member

hebasto commented Sep 8, 2023

The -flto-partition=1to1 option helps:

$ x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc (GCC) 12-posix
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ./autogen.sh
$ ./configure --host=x86_64-w64-mingw32 CFLAGS="-flto -flto-partition=1to1" LDFLAGS="-flto=auto"
$ make -j16

From GCC docs:

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

@real-or-random
Copy link
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?

@real-or-random
Copy link
Contributor

real-or-random added a commit to real-or-random/secp256k1 that referenced this issue Aug 24, 2024
real-or-random added a commit to real-or-random/secp256k1 that referenced this issue Aug 24, 2024
real-or-random added a commit to real-or-random/secp256k1 that referenced this issue Aug 25, 2024
real-or-random added a commit that referenced this issue Oct 21, 2024
447334c include: Avoid visibility("default") on Windows (Tim Ruffing)

Pull request description:

  Fixes #1421. See code comments for rationale.

  Related meta-bug: #1181.  This reminds me that we should move forward with #1359.

ACKs for top commit:
  fanquake:
    ACK 447334c
  hebasto:
    ACK 447334c, tested on Ubuntu 24.04 using the following commands:
  theuni:
    ACK 447334c

Tree-SHA512: aaa47d88fd1b1f85c3e879a2b288c0eb3beebad0cc89e85f05d0b631f83e58d5a324fb441911970865eaa292f6820d03a1b516d6e8de37a87510e2082acc6e28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants