From 09a6f2a6f1e7e18fe7e32a7fd9d396afe32965ed Mon Sep 17 00:00:00 2001 From: Hyungju Lee Date: Mon, 10 Jun 2024 20:13:26 +0900 Subject: [PATCH] [Tizen] Fix build issues with clang18 --- eng/native/configurecompiler.cmake | 8 ++++++++ src/shared/minipal/getexepath.h | 2 +- src/shared/pal/src/file/path.cpp | 6 +++--- src/shared/pal/src/include/pal/palinternal.h | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 0be4937c7..e4d96c1e6 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -549,6 +549,11 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wimplicit-fallthrough) endif() + # VLAs are non standard in C++, aren't available on Windows and + # are a warning by default since clang 18. + # For consistency, enable warnings for all compiler versions. + add_compile_options($<$:-Wvla>) + #These seem to indicate real issues add_compile_options($<$:-Wno-invalid-offsetof>) @@ -591,6 +596,9 @@ if (CLR_CMAKE_HOST_UNIX) # other clang 16.0 suppressions add_compile_options(-Wno-single-bit-bitfield-constant-conversion) add_compile_options(-Wno-cast-function-type-strict) + + # clang 18.1 supressions + add_compile_options(-Wno-switch-default) else() add_compile_options(-Wno-uninitialized) add_compile_options(-Wno-strict-aliasing) diff --git a/src/shared/minipal/getexepath.h b/src/shared/minipal/getexepath.h index a5e12e08a..3c9ad5368 100644 --- a/src/shared/minipal/getexepath.h +++ b/src/shared/minipal/getexepath.h @@ -37,7 +37,7 @@ static inline char* minipal_getexepath(void) return NULL; } - char path_buf[path_length]; + char* path_buf = (char*)alloca(path_length); if (_NSGetExecutablePath(path_buf, &path_length) != 0) { errno = EINVAL; diff --git a/src/shared/pal/src/file/path.cpp b/src/shared/pal/src/file/path.cpp index edc9c6c0a..469756e6c 100644 --- a/src/shared/pal/src/file/path.cpp +++ b/src/shared/pal/src/file/path.cpp @@ -401,8 +401,8 @@ GetTempPathW( return 0; } - char TempBuffer[nBufferLength > 0 ? nBufferLength : 1]; - DWORD dwRetVal = GetTempPathA( nBufferLength, TempBuffer ); + char* tempBuffer = (char*)alloca(nBufferLength > 0 ? nBufferLength : 1); + DWORD dwRetVal = GetTempPathA( nBufferLength, tempBuffer ); if ( dwRetVal >= nBufferLength ) { @@ -413,7 +413,7 @@ GetTempPathW( else if ( dwRetVal != 0 ) { /* Convert to wide. */ - if ( 0 == MultiByteToWideChar( CP_ACP, 0, TempBuffer, -1, + if ( 0 == MultiByteToWideChar( CP_ACP, 0, tempBuffer, -1, lpBuffer, dwRetVal + 1 ) ) { ASSERT( "An error occurred while converting the string to wide.\n" ); diff --git a/src/shared/pal/src/include/pal/palinternal.h b/src/shared/pal/src/include/pal/palinternal.h index 6b2622455..0078c1c44 100644 --- a/src/shared/pal/src/include/pal/palinternal.h +++ b/src/shared/pal/src/include/pal/palinternal.h @@ -431,6 +431,7 @@ function_name() to call the system's implementation #undef va_start #undef va_end #undef va_copy +#undef va_arg #undef stdin #undef stdout #undef stderr -- 2.34.1