Skip to content

Commit

Permalink
[release/6.0] Suppress clang-16 warnings (backport #81573) (#84443)
Browse files Browse the repository at this point in the history
* Suppress clang-16 warnings (#81573)

* Fix DBI loading problem on Linux (#82461)
  • Loading branch information
ayakael authored May 15, 2023
1 parent c93a40e commit 2f007ae
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
9 changes: 9 additions & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ if (CLR_CMAKE_HOST_UNIX)
add_compile_options(-Wno-incompatible-ms-struct)

add_compile_options(-Wno-reserved-identifier)

# clang 16.0 introduced buffer hardening https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734
# which we are not conforming to yet.
add_compile_options(-Wno-unsafe-buffer-usage)

# other clang 16.0 suppressions
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
add_compile_options(-Wno-cast-function-type-strict)
add_compile_options(-Wno-incompatible-function-pointer-types-strict)
else()
add_compile_options(-Wno-unknown-pragmas)
add_compile_options(-Wno-uninitialized)
Expand Down
4 changes: 2 additions & 2 deletions eng/native/init-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ if [[ -z "$CLR_CC" ]]; then
# Set default versions
if [[ -z "$majorVersion" ]]; then
# note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
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 )
elif [[ "$compiler" == "gcc" ]]; then versions=( 11 10 9 8 7 6 5 4.9 ); fi
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 )
elif [[ "$compiler" == "gcc" ]]; then versions=( 12 11 10 9 8 7 6 5 4.9 ); fi

for version in "${versions[@]}"; do
parts=(${version//./ })
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ elseif(CLR_CMAKE_HOST_UNIX)
mscordaccore
)

# Before llvm 16, lld was setting `--undefined-version` by default. The default was
# flipped to `--no-undefined-version` in lld 16, so we will explicitly set it to
# `--undefined-version` for our use-case.
include(CheckLinkerFlag OPTIONAL)
if(COMMAND check_linker_flag)
check_linker_flag(CXX -Wl,--undefined-version LINKER_SUPPORTS_UNDEFINED_VERSION)
if (LINKER_SUPPORTS_UNDEFINED_VERSION)
add_linker_flag(-Wl,--undefined-version)
endif(LINKER_SUPPORTS_UNDEFINED_VERSION)
endif(COMMAND check_linker_flag)

# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
# find all symbols.
Expand Down
9 changes: 9 additions & 0 deletions src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ if(CMAKE_C_COMPILER_ID STREQUAL Clang)
add_compile_options(-Wthread-safety)
add_compile_options(-Wno-thread-safety-analysis)
add_compile_options(-Wno-reserved-identifier)

# clang 16.0 introduced buffer hardening https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734
# which we are not conforming to yet.
add_compile_options(-Wno-unsafe-buffer-usage)

# other clang 16.0 suppressions
add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
add_compile_options(-Wno-cast-function-type-strict)
add_compile_options(-Wno-incompatible-function-pointer-types-strict)
elseif(CMAKE_C_COMPILER_ID STREQUAL GNU)
add_compile_options(-Wno-stringop-truncation)
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/native/corehost/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ if(CLR_CMAKE_TARGET_WIN32)
add_linker_flag("/DEF:${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost.def")

else()
if(CLR_CMAKE_TARGET_OSX)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_OSXexports.src)
if(CLR_CMAKE_TARGET_FREEBSD)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_freebsdexports.src)
else()
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_unixexports.src)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ g_dacTable

; Used by profilers
MetaDataGetDispenser

; FreeBSD needs to reexport these
__progname
environ
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ g_dacTable

; Used by profilers
MetaDataGetDispenser

; FreeBSD needs to reexport these
__progname
environ

0 comments on commit 2f007ae

Please sign in to comment.