From f8bf0fcc30d2e1f606266db1b644266c7bdbf063 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Wed, 13 Jul 2022 11:40:52 -0500 Subject: [PATCH] Fix building with clang 14 (#69990) Under clang 14, building runtime on Linux with a simple ./build.sh fails with hundreds of errors that all look like this: runtime/src/libraries/Native/Unix/System.Native/pal_networking.c(2610,9): error GD58BE485: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement] [runtime/src/libraries/Native/build-native.proj] This issue is not present in the main branch. It appears to have been fixed by https://github.com/dotnet/runtime/pull/66410/ which turned off that warning. Tested with: $ clang --version clang version 14.0.0 (Fedora 14.0.0-1.fc36) Target: x86_64-redhat-linux-gnu Thread model: posix InstalledDir: /usr/bin --- src/libraries/Native/Unix/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index 6fae902369c0e8..6931f62d24c87e 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -22,7 +22,7 @@ if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS endif() set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wno-declaration-after-statement") set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.c") # We mark the function which needs exporting with PALEXPORT