Require C11 in MSVC too

BoringSSL can currently be built in C11 or pre-C11 mode in MSVC. They're
broadly the same, but do use completely different implementations of
alignas and alignof. Now that every build configuration I'm aware of has
been moved to the C11 mode, we don't even test the pre-C11 mode anymore.
Start requiring it.

Update-Note: If building with MSVC, BoringSSL now requires building with
/std:c11 or later. (On non-MSVC compilers, we have required C11 for a
while now.)

Fixed: 624
Change-Id: Ie9f66eee0bebac8143c23a7229c6854afaefea6e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/63065
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
chromium-stable
David Benjamin 1 year ago committed by Boringssl LUCI CQ
parent 558960d1e1
commit ecb7e9ae5c
  1. 10
      BUILDING.md
  2. 24
      crypto/internal.h

@ -30,11 +30,11 @@ 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. If using a C compiler
other than MSVC, C11 support is also requried. On Windows, MSVC from
Visual Studio 2019 or later with Windows 10 SDK 2104 or later are supported,
but using the latest versions is recommended. Recent versions of GCC (6.1+)
and Clang should work on non-Windows platforms, and maybe on Windows too.
* Compilers for C11 and C++14, or later, are required. On Windows, MSVC from
Visual Studio 2019 or later with Windows 10 SDK 2104 or later are
supported, but using the latest versions is recommended. Recent versions of
GCC (6.1+) and Clang should work on non-Windows platforms, and maybe on
Windows too.
* The most recent stable version of [Go](https://golang.org/dl/) is required.
Note Go is exempt from the five year support window. If not found by CMake,

@ -127,24 +127,13 @@
#endif
#if !defined(__cplusplus)
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include <stdalign.h>
#elif 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.
//
// TODO(davidben): In MSVC 2019 16.8 or higher (_MSC_VER >= 1928),
// |__STDC_VERSION__| will be 201112 when passed /std:c11 and unset otherwise.
// C11 alignas and alignof are only implemented in C11 mode. Can we mandate C11
// mode for those versions?
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
// BoringSSL requires C11 to build the library. 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 building with MSVC, build with /std:c11.
#error "BoringSSL must be built in C11 mode or higher."
#endif
#include <stdalign.h>
#endif
#if defined(OPENSSL_THREADS) && \
@ -161,8 +150,7 @@
// Determine the atomics implementation to use with C.
#if !defined(__cplusplus)
#if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \
!defined(__STDC_NO_ATOMICS__) && defined(__STDC_VERSION__) && \
__STDC_VERSION__ >= 201112L
!defined(__STDC_NO_ATOMICS__)
#define OPENSSL_C11_ATOMIC
#endif

Loading…
Cancel
Save