Skip to content

Commit 2f007ae

Browse files
authored
[release/6.0] Suppress clang-16 warnings (backport #81573) (#84443)
* Suppress clang-16 warnings (#81573) * Fix DBI loading problem on Linux (#82461)
1 parent c93a40e commit 2f007ae

File tree

7 files changed

+37
-8
lines changed

7 files changed

+37
-8
lines changed

eng/native/configurecompiler.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,15 @@ if (CLR_CMAKE_HOST_UNIX)
367367
add_compile_options(-Wno-incompatible-ms-struct)
368368

369369
add_compile_options(-Wno-reserved-identifier)
370+
371+
# clang 16.0 introduced buffer hardening https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734
372+
# which we are not conforming to yet.
373+
add_compile_options(-Wno-unsafe-buffer-usage)
374+
375+
# other clang 16.0 suppressions
376+
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
377+
add_compile_options(-Wno-cast-function-type-strict)
378+
add_compile_options(-Wno-incompatible-function-pointer-types-strict)
370379
else()
371380
add_compile_options(-Wno-unknown-pragmas)
372381
add_compile_options(-Wno-uninitialized)

eng/native/init-compiler.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ if [[ -z "$CLR_CC" ]]; then
4646
# Set default versions
4747
if [[ -z "$majorVersion" ]]; then
4848
# note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
49-
if [[ "$compiler" == "clang" ]]; then versions=( 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
50-
elif [[ "$compiler" == "gcc" ]]; then versions=( 11 10 9 8 7 6 5 4.9 ); fi
49+
if [[ "$compiler" == "clang" ]]; then versions=( 16 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
50+
elif [[ "$compiler" == "gcc" ]]; then versions=( 12 11 10 9 8 7 6 5 4.9 ); fi
5151

5252
for version in "${versions[@]}"; do
5353
parts=(${version//./ })

src/coreclr/dlls/mscordbi/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ elseif(CLR_CMAKE_HOST_UNIX)
9999
mscordaccore
100100
)
101101

102+
# Before llvm 16, lld was setting `--undefined-version` by default. The default was
103+
# flipped to `--no-undefined-version` in lld 16, so we will explicitly set it to
104+
# `--undefined-version` for our use-case.
105+
include(CheckLinkerFlag OPTIONAL)
106+
if(COMMAND check_linker_flag)
107+
check_linker_flag(CXX -Wl,--undefined-version LINKER_SUPPORTS_UNDEFINED_VERSION)
108+
if (LINKER_SUPPORTS_UNDEFINED_VERSION)
109+
add_linker_flag(-Wl,--undefined-version)
110+
endif(LINKER_SUPPORTS_UNDEFINED_VERSION)
111+
endif(COMMAND check_linker_flag)
112+
102113
# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
103114
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
104115
# find all symbols.

src/libraries/Native/Unix/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ if(CMAKE_C_COMPILER_ID STREQUAL Clang)
5151
add_compile_options(-Wthread-safety)
5252
add_compile_options(-Wno-thread-safety-analysis)
5353
add_compile_options(-Wno-reserved-identifier)
54+
55+
# clang 16.0 introduced buffer hardening https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734
56+
# which we are not conforming to yet.
57+
add_compile_options(-Wno-unsafe-buffer-usage)
58+
59+
# other clang 16.0 suppressions
60+
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
61+
add_compile_options(-Wno-cast-function-type-strict)
62+
add_compile_options(-Wno-incompatible-function-pointer-types-strict)
5463
elseif(CMAKE_C_COMPILER_ID STREQUAL GNU)
5564
add_compile_options(-Wno-stringop-truncation)
5665
endif()

src/native/corehost/apphost/static/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ if(CLR_CMAKE_TARGET_WIN32)
7373
add_linker_flag("/DEF:${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost.def")
7474

7575
else()
76-
if(CLR_CMAKE_TARGET_OSX)
77-
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_OSXexports.src)
76+
if(CLR_CMAKE_TARGET_FREEBSD)
77+
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_freebsdexports.src)
7878
else()
7979
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_unixexports.src)
8080
endif()

src/native/corehost/apphost/static/singlefilehost_OSXexports.src src/native/corehost/apphost/static/singlefilehost_freebsdexports.src

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ g_dacTable
99

1010
; Used by profilers
1111
MetaDataGetDispenser
12+
13+
; FreeBSD needs to reexport these
14+
__progname
15+
environ

src/native/corehost/apphost/static/singlefilehost_unixexports.src

-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@ g_dacTable
99

1010
; Used by profilers
1111
MetaDataGetDispenser
12-
13-
; FreeBSD needs to reexport these
14-
__progname
15-
environ

0 commit comments

Comments
 (0)