Try to require C11 (in non-MSVC compilers).

MSVC is a little behind, but otherwise we should be able to assume C11
support in all our compilers. The only C99 builds should just be stale
build files. Such consumers are leaving performance on the table, by
using the worse refcounting implementation.

For now, don't require it in public headers. Android's build is still
defaulting to C99, which means requiring C11 will be disruptive. We can
try the public headers after that's fixed.

Update-Note: If the build fails with an error about C11, remove -std=c99
or -std=gnu99 from your build. Refcounting will get faster.

Change-Id: I2ec6f7d7acc026a451851d0c38f60c14bae6b00f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52247
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
fips-20220613
David Benjamin 3 years ago committed by Boringssl LUCI CQ
parent 493d5cbedd
commit f961de5c47
  1. 3
      BUILDING.md
  2. 10
      crypto/internal.h
  3. 7
      include/openssl/type_check.h

@ -30,7 +30,8 @@ most recent stable version of each tool.
by CMake, it may be configured explicitly by setting
`CMAKE_ASM_NASM_COMPILER`.
* C and C++ compilers with C++14 support are required. On Windows, MSVC from
* C and C++ compilers with C++14 support are required. If using a C compiler
other than MSVC, C11 support is also requried. On Windows, MSVC from
Visual Studio 2017 or later with Platform SDK 8.1 or later are supported,
but newer versions are recommended. Recent versions of GCC (6.1+) and Clang
should work on non-Windows platforms, and maybe on Windows too.

@ -126,10 +126,18 @@
#endif
#if !defined(__cplusplus)
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
#define alignas(x) __declspec(align(x))
#define alignof __alignof
#else
// With the exception of MSVC, we require C11 to build the library. C11 is a
// prerequisite for improved refcounting performance. All our supported C
// compilers have long implemented C11 and made it default. The most likely
// cause of pre-C11 modes is stale -std=c99 or -std=gnu99 flags in build
// configuration. Such flags can be removed.
#if __STDC_VERSION__ < 201112L
#error "BoringSSL must be built in C11 mode or higher."
#endif
#include <stdalign.h>
#endif
#endif

@ -71,7 +71,12 @@ extern "C" {
// C11 defines the |_Static_assert| keyword and the |static_assert| macro in
// assert.h. While the former is available at all versions in Clang and GCC, the
// later depends on libc and, in glibc, depends on being built in C11 mode. We
// do not require this, for now, so use |_Static_assert| directly.
// require C11 mode to build the library but, for now, do not require it in
// public headers. Use |_Static_assert| directly.
//
// TODO(davidben): In July 2022, if the C11 change has not been reverted, switch
// all uses of this macro within the library to C11 |static_assert|. This macro
// will only be necessary in public headers.
#define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
#endif

Loading…
Cancel
Save