From 6addc35b71608cf997b6aa036122a0794a715a5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=98=95=EC=A3=BC/MDE=20Lab=28SR=29/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 15 Feb 2024 19:34:24 +0900 Subject: [PATCH] [Tizen] Fix build error for Clang-16+ (#399) This commit is a mix of upstream commits specific to tizen unified. * [release/7.0] Suppress clang-16 warnings (backport #81573) (#84444) Fix DBI loading problem on Linux (#82461) * Use logical and for boolean operation in bstr (#67858) This seems like a mistake and recent versions of clang even complain about it: /runtime/src/coreclr/palrt/bstr.cpp:50:13: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical] if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) & ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ && /runtime/src/coreclr/pal/inc/pal.h:5144:27: note: expanded from macro 'SUCCEEDED' #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) ^ /runtime/src/coreclr/palrt/bstr.cpp:50:13: note: cast one or both operands to int to silence this warning /runtime/src/coreclr/pal/inc/pal.h:5144:27: note: expanded from macro 'SUCCEEDED' #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) ^ 1 error generated. * Fix Wunqualified-std-cast-call in singlefilehost (#72305) Modified by hand due to mingling w/ other commits --------- Co-authored-by: Antoine Martin Co-authored-by: Omair Majid --- eng/native/configurecompiler.cmake | 9 +++++++++ src/coreclr/dlls/mscordbi/CMakeLists.txt | 11 +++++++++++ src/coreclr/palrt/bstr.cpp | 2 +- src/libraries/Native/Unix/CMakeLists.txt | 9 +++++++++ src/native/corehost/apphost/static/CMakeLists.txt | 4 ++-- ...ehost_OSXexports.src => singlefilehost_freebsdexports.src} | 4 ++++ .../corehost/apphost/static/singlefilehost_unixexports.src | 4 ---- src/native/corehost/fxr/sdk_resolver.cpp | 8 ++++---- 8 files changed, 40 insertions(+), 11 deletions(-) rename src/native/corehost/apphost/static/{singlefilehost_OSXexports.src => singlefilehost_freebsdexports.src} (81%) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 974d944..c1fbbe2 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -378,6 +378,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) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index c7a23c9..b7618b3 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -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. diff --git a/src/coreclr/palrt/bstr.cpp b/src/coreclr/palrt/bstr.cpp index 2f5ccd9..93c1da7 100644 --- a/src/coreclr/palrt/bstr.cpp +++ b/src/coreclr/palrt/bstr.cpp @@ -47,7 +47,7 @@ inline HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result) else { ULONG temp = 0; // should not use in-place addition in ULongAdd - if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) & + if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) && SUCCEEDED(ULongAdd(temp, constant, result))) { *result = *result & ~WIN32_ALLOC_ALIGN; diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index 6931f62..d59ec3b 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -28,6 +28,15 @@ set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.c") # We mark the function which needs exporting with PALEXPORT add_compile_options(-fvisibility=hidden) +# 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) + add_compile_options(-Wno-format-nonliteral) add_compile_options(-Wno-disabled-macro-expansion) add_compile_options(-Wno-padded) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index a00c791..6d491c0 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -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() diff --git a/src/native/corehost/apphost/static/singlefilehost_OSXexports.src b/src/native/corehost/apphost/static/singlefilehost_freebsdexports.src similarity index 81% rename from src/native/corehost/apphost/static/singlefilehost_OSXexports.src rename to src/native/corehost/apphost/static/singlefilehost_freebsdexports.src index 18d5697..1f9c517 100644 --- a/src/native/corehost/apphost/static/singlefilehost_OSXexports.src +++ b/src/native/corehost/apphost/static/singlefilehost_freebsdexports.src @@ -9,3 +9,7 @@ g_dacTable ; Used by profilers MetaDataGetDispenser + +; FreeBSD needs to reexport these +__progname +environ diff --git a/src/native/corehost/apphost/static/singlefilehost_unixexports.src b/src/native/corehost/apphost/static/singlefilehost_unixexports.src index 1f9c517..18d5697 100644 --- a/src/native/corehost/apphost/static/singlefilehost_unixexports.src +++ b/src/native/corehost/apphost/static/singlefilehost_unixexports.src @@ -9,7 +9,3 @@ g_dacTable ; Used by profilers MetaDataGetDispenser - -; FreeBSD needs to reexport these -__progname -environ diff --git a/src/native/corehost/fxr/sdk_resolver.cpp b/src/native/corehost/fxr/sdk_resolver.cpp index a004e7f..e8006f7 100644 --- a/src/native/corehost/fxr/sdk_resolver.cpp +++ b/src/native/corehost/fxr/sdk_resolver.cpp @@ -34,7 +34,7 @@ sdk_resolver::sdk_resolver(bool allow_prerelease) : } sdk_resolver::sdk_resolver(fx_ver_t version, sdk_roll_forward_policy roll_forward, bool allow_prerelease) : - version(move(version)), + version(std::move(version)), roll_forward(roll_forward), allow_prerelease(allow_prerelease) { @@ -357,7 +357,7 @@ bool sdk_resolver::parse_global_file(pal::string_t global_file_path) } } - global_file = move(global_file_path); + global_file = std::move(global_file_path); return true; } @@ -471,7 +471,7 @@ bool sdk_resolver::resolve_sdk_path_and_version(const pal::string_t& dir, pal::s if (pal::directory_exists(probe_path)) { trace::verbose(_X("Found requested SDK directory [%s]"), probe_path.c_str()); - sdk_path = move(probe_path); + sdk_path = std::move(probe_path); resolved_version = version; // The SDK path has been resolved @@ -523,7 +523,7 @@ bool sdk_resolver::resolve_sdk_path_and_version(const pal::string_t& dir, pal::s changed = true; resolved_version = ver; - resolved_version_str = move(version); + resolved_version_str = std::move(version); } if (changed) -- 2.7.4