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

Open
fanquake opened this issue Sep 6, 2023 · 5 comments
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?

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

No branches or pull requests

3 participants