[gnutls-devel] GnuTLS | fips.h: remove duplicate _gnutls_switch_lib_state declaration breaking inline linkage in clang -O0 (!1947)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Fri Apr 11 04:14:19 CEST 2025



Doekin created a merge request: https://gitlab.com/gnutls/gnutls/-/merge_requests/1947

Project:Branches: Doekin/gnutls:clean-fips to gnutls/gnutls:master
Author:   Doekin




This PR fixes linking failures that occur when building shared `gnutls-openssl` with Clang at optimization level -O0, where an undefined reference to `_gnutls_lib_state` error would appear (issue #1690).

The root cause is a duplicate `_gnutls_switch_lib_state` declaration that overrides the preceding `inline static` definition. When compiling with Clang -O0, this causes the symbol to be treated as an external reference rather than being inlined.

Reproduction case:
```c
extern int _state;
inline static void set_state(int state)
{
    _state = state;
}
/* void set_state(int state); */  /* removing this avoids the issue */
void foo(void){}
```

Compilation behavior:
1. Without the duplicate declaration:
   - Both Clang and GCC produce no undefined symbols
2. With the duplicate declaration:
   - Clang produces `U _state` in symbol table
   - GCC still produces no undefined symbols

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1947
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20250411/faf38306/attachment.html>


More information about the Gnutls-devel mailing list