1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-24 03:35:38 +03:00
aports/testing/dotnet31-build/corefx_fix-build-clang13.patch
2022-03-30 16:10:41 +00:00

74 lines
3.3 KiB
Diff

From 124bc55d35fd46ed165a07996cbaa9ad11a17eb5 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/corefx/pull/43104
From: Omair Majid <omajid@redhat.com>
Date: Thu, 20 Jan 2022 12:41:51 -0500
Subject: [PATCH 1/1] Fix building with clang 13
Clang 13 now enables cast-function-type warning which results in build
errors that look like this:
/corefx/src/Native/Unix/System.Native/pal_process.c(382,76): error G39B05358: cast from 'void (*)(int, siginfo_t *, void *)' to 'void (*)(int)' converts to incompatible function type [-Werror,-Wcast-function-type] [/corefx/src/Native/build-native.proj]
void (*oldhandler)(int) = (sa_old.sa_flags & SA_SIGINFO) ? (void (*)(int))sa_old.sa_sigaction : sa_old.sa_handler;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disable this warning using -Wno-cast-function-type warning. That seems
lower-risk than any functional code change.
Clang 13 also enables reserved-identifier warning which results in build errors
like this:
/corefx/src/Native/Unix/System.Native/pal_process.c(819,17): error GA61F72A6: identifier '__cpu' is reserved because it starts with '__' [-Werror,-Wreserved-identifier] [/corefx/src/Native/build-native.proj]
if (CPU_ISSET(cpu, &set))
^
/usr/include/sched.h:94:34: note: expanded from macro 'CPU_ISSET'
# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
^
This really seems like a bug in clang that it's complaining about code in
system libraries that we are using via wrapper-macros. But there are
other instances of this warning that are speciifc to our code too, such
as `__padding` in
src/Native/Unix/System.Native/pal_interfaceaddresses.h. Disable this
warning too.
Tested with Clang 13 rc1.
---
src/Native/Unix/CMakeLists.txt | 6 ++++++
src/Native/Unix/configure.cmake | 2 ++
2 files changed, 8 insertions(+)
diff --git a/src/Native/Unix/CMakeLists.txt b/src/Native/Unix/CMakeLists.txt
index c5772c7e02..005aaf1e7d 100644
--- a/src/Native/Unix/CMakeLists.txt
+++ b/src/Native/Unix/CMakeLists.txt
@@ -261,9 +261,15 @@ include(configure.cmake)
if (HAVE_WNO_ALLOCA)
add_compile_options(-Wno-alloca)
endif()
+if (HAVE_WNO_CAST_FUNCTION_TYPE)
+ add_compile_options(-Wno-cast-function-type)
+endif()
if (HAVE_WNO_IMPLICIT_INT_FLOAT_CONVERSION)
add_compile_options(-Wno-implicit-int-float-conversion)
endif()
+if (HAVE_WNO_RESERVED_IDENTIFIER)
+ add_compile_options(-Wno-reserved-identifier)
+endif()
if (NOT CLR_CMAKE_PLATFORM_WASM)
add_subdirectory(System.IO.Compression.Native)
diff --git a/src/Native/Unix/configure.cmake b/src/Native/Unix/configure.cmake
index 6756ea26a5..a01cf90760 100644
--- a/src/Native/Unix/configure.cmake
+++ b/src/Native/Unix/configure.cmake
@@ -34,6 +34,8 @@ set(CMAKE_REQUIRED_FLAGS "-Werror -Wno-error=unused-value")
check_c_compiler_flag(-Wno-alloca HAVE_WNO_ALLOCA)
check_c_compiler_flag(-Wno-implicit-int-float-conversion HAVE_WNO_IMPLICIT_INT_FLOAT_CONVERSION)
+check_c_compiler_flag(-Wno-reserved-identifier HAVE_WNO_RESERVED_IDENTIFIER)
+check_c_compiler_flag(-Wno-cast-function-type HAVE_WNO_CAST_FUNCTION_TYPE)
# in_pktinfo: Find whether this struct exists
check_include_files(
--
2.35.1