randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.6k stars 570 forks source link

botan/x25519.h:108:1: error: an attribute list cannot appear here #4329

Closed ni4 closed 3 months ago

ni4 commented 3 months ago

I'm attempting to update RNP oss-fuzz to Botan 3.5.0 from 3.4.0 (which works fine). However, I get the following error when oss-fuzz tries to build RNP:

In file included from /usr/include/botan-3/botan/curve25519.h:11:
/usr/include/botan-3/botan/x25519.h:108:1: error: an attribute list cannot appear here
108 | BOTAN_DEPRECATED_API("Use X25519_PrivateKey or Sodium::crypto_scalarmult_curve25519")
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/botan-3/botan/compiler.h:37:45: note: expanded from macro 'BOTAN_DEPRECATED_API'
  37 | #define BOTAN_DEPRECATED_API(msg) BOTAN_DLL BOTAN_DEPRECATED(msg)
      |                                             ^~~~~~~~~~~~~~~~~~~~~
/usr/include/botan-3/botan/compiler.h:125:34: note: expanded from macro 'BOTAN_DEPRECATED'
  125 |    #define BOTAN_DEPRECATED(msg) [[deprecated(msg)]]
      |                                  ^~~~~~~~~~~~~~~~~~~

Indeed, we still use old naming for Curve25519 and didn't migrate yet. Compiler identification is CLang 18.0.0. Just to note - we build RNP with Botan 3.5.0 and latest git commit in CI and didn't see this issue before. Do you have an idea why this may happen and how to worarkound it (except correct function naming to not yield a deprecation warning)? Thanks!

randombit commented 3 months ago

Hi! Sorry about that. This involves a macro expansion that included both [[deprecated]] and __attribute__ and for whatever reason Clang supports one ordering of these two constructs, but not the other. This is already fixed on master, next release is 3.6.0 in October. In the meantime you can work around it with #define BOTAN_NO_DEPRECATED_WARNINGS. Unfortunately just avoiding the deprecated name is not sufficient - Clang considers this a parse error so it will reject the header outright even if the function is never called.

ni4 commented 3 months ago

@randombit Thanks for the quick reply! I should take look at master before creating an issue. No problem, will update to 3.6.0 once it is ready, no rush for now.