From 4e06af5256928863447691afd9678bfb24d6edc3 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Wed, 18 Oct 2023 12:39:34 -0300 Subject: [PATCH] build: disable `restrict` warning when using GCC 12.1-12.3 Prevents warning raised by a compiler bug when using GCC 12.1-12.3 with C++20 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105545 --- CHANGES.md | 1 + build-support/macros-and-definitions.cmake | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 4f897f354..f49cff082 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,6 +30,7 @@ Changes from ns-3.40 to ns-3-dev * In preparation to enable C++20, the following actions have been taken due to compiler issues: * Precompiled headers have been disabled in GCC versions >= 12.2. + * The `restrict` warning has been disabled in GCC versions 12.1-12.3.1. ### Changed behavior diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index ca4974c4b..e09d634ec 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -251,6 +251,13 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") CACHE BOOL "Precompile module headers to speed up compilation" FORCE ) endif() + if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1.0") + AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.3.2") + ) + # Disable warnings-as-errors for certain versions of GCC when C++20 is + # enabled https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105545 + add_compile_options(-Wno-restrict) + endif() set(GCC TRUE) add_definitions(-fno-semantic-interposition) if(${NS3_COLORED_OUTPUT} OR "$ENV{CLICOLOR}")