From 9e9a1f737d0252a1a51424749c3949be832f47df Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Fri, 16 Aug 2024 14:21:49 -0700 Subject: [PATCH 1/2] freebsd: Add upstream patch fixing obscure c++98 interaction https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276738#c12 Using _Static_assert under -std=c++98 -pedantic-errors will fail in FreeBSD 14.1. This fixes that, allowing software like gbenchmark to run its tests against legacy c++ standards. This patch is pending for FreeBSD 14.2, and should be removed for that release. --- .../14.1/sys-cdefs-static-assert.patch | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.1/sys-cdefs-static-assert.patch diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.1/sys-cdefs-static-assert.patch b/pkgs/os-specific/bsd/freebsd/patches/14.1/sys-cdefs-static-assert.patch new file mode 100644 index 000000000000..b5a054f124d3 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.1/sys-cdefs-static-assert.patch @@ -0,0 +1,41 @@ +From 22cdafe197ac960c5ce839ef6ec699b59f4b0080 Mon Sep 17 00:00:00 2001 +From: Warner Losh +Date: Sat, 20 Jul 2024 09:57:53 -0600 +Subject: cdefs.h: Don't define fallback for _Static_assert + +Remove pre 4.6 code to define _Static_assert in terms of _COUNTER. We +no longer need to support compilers this old (in fact support for all +pre gcc 10 compilers has been removed in -current). This is a partial +MFC of that work because removing this fixes a bug that's oft reported +with -pedantic-errors and C++98 compilations. + +PR: 280382, 276738 +Sponsored by: Netflix + +This is a direct commit to stable/14. +--- + sys/sys/cdefs.h | 9 --------- + 1 file changed, 9 deletions(-) + +diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h +index 19b7d8fe427d..a52864c5db9d 100644 +--- a/sys/sys/cdefs.h ++++ b/sys/sys/cdefs.h +@@ -277,15 +277,6 @@ + #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ + __has_extension(cxx_static_assert) + #define _Static_assert(x, y) static_assert(x, y) +-#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus) +-/* Nothing, gcc 4.6 and higher has _Static_assert built-in */ +-#elif defined(__COUNTER__) +-#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) +-#define __Static_assert(x, y) ___Static_assert(x, y) +-#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \ +- __unused +-#else +-#define _Static_assert(x, y) struct __hack + #endif + #endif + +-- +cgit v1.2.3 From 2c66c45cf39a298971a6237bd818eeeec46beb97 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Fri, 16 Aug 2024 14:13:52 -0700 Subject: [PATCH 2/2] gbenchmark: mark support for FreeBSD --- pkgs/development/libraries/gbenchmark/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/gbenchmark/default.nix b/pkgs/development/libraries/gbenchmark/default.nix index d8666d92cf3e..16d4d28219db 100644 --- a/pkgs/development/libraries/gbenchmark/default.nix +++ b/pkgs/development/libraries/gbenchmark/default.nix @@ -40,7 +40,7 @@ stdenv.mkDerivation rec { description = "Microbenchmark support library"; homepage = "https://github.com/google/benchmark"; license = licenses.asl20; - platforms = platforms.linux ++ platforms.darwin; + platforms = platforms.linux ++ platforms.darwin ++ platforms.freebsd; maintainers = with maintainers; [ abbradar ]; }; }