Suppress clang-16 warnings (#81573)
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>
Sat, 4 Feb 2023 20:08:12 +0000 (22:08 +0200)
committerGitHub <noreply@github.com>
Sat, 4 Feb 2023 20:08:12 +0000 (12:08 -0800)
* Suppress clang-16 warnings

* Remove a strange (one-of-a-kind) workaround

* Add thunk for PAL_{Unr,R}egisterModule

eng/common/native/init-compiler.sh
eng/native/configurecompiler.cmake
src/coreclr/dlls/mscordbi/CMakeLists.txt
src/coreclr/dlls/mscordbi/mscordbi.cpp
src/native/corehost/apphost/static/CMakeLists.txt
src/native/corehost/apphost/static/singlefilehost_freebsdexports.src [moved from src/native/corehost/apphost/static/singlefilehost_OSXexports.src with 81% similarity]
src/native/corehost/apphost/static/singlefilehost_unixexports.src

index c670cb7..7aee421 100644 (file)
@@ -63,7 +63,7 @@ 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="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"
+        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
index 867e9ea..34fb9a5 100644 (file)
@@ -453,6 +453,14 @@ 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)
   else()
     add_compile_options(-Wno-uninitialized)
     add_compile_options(-Wno-strict-aliasing)
index c24a90c..95e9203 100644 (file)
@@ -100,10 +100,7 @@ elseif(CLR_CMAKE_HOST_UNIX)
         mscordaccore
     )
 
-    # 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.
-    target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})
+    target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
 
     add_dependencies(mscordbi mscordaccore)
 
index 891c01e..109fe6a 100644 (file)
@@ -32,3 +32,18 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
        // Defer to the main debugging code.
     return DbgDllMain(hInstance, dwReason, lpReserved);
 }
+
+#if defined(HOST_LINUX) && defined(TARGET_LINUX)
+PALIMPORT HINSTANCE PALAPI DAC_PAL_RegisterModule(IN LPCSTR lpLibFileName);
+PALIMPORT VOID PALAPI DAC_PAL_UnregisterModule(IN HINSTANCE hInstance);
+
+HINSTANCE PALAPI PAL_RegisterModule(IN LPCSTR lpLibFileName)
+{
+     return DAC_PAL_RegisterModule(lpLibFileName);
+}
+
+VOID PALAPI PAL_UnregisterModule(IN HINSTANCE hInstance)
+{
+    DAC_PAL_UnregisterModule(hInstance);
+}
+#endif
index 395293a..89c51af 100644 (file)
@@ -66,8 +66,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()