diff options
Diffstat (limited to 'src/pal')
30 files changed, 298 insertions, 49 deletions
diff --git a/src/pal/inc/mbusafecrt.h b/src/pal/inc/mbusafecrt.h index 9c516e032b..abc2dca406 100644 --- a/src/pal/inc/mbusafecrt.h +++ b/src/pal/inc/mbusafecrt.h @@ -31,11 +31,13 @@ typedef int errno_t; // define the return value for success #define SAFECRT_SUCCESS 0 -#if defined(_MSC_VER) || defined(__llvm__) +#ifndef THROW_DECL +#if defined(_MSC_VER) || defined(__llvm__) || !defined(__cplusplus) #define THROW_DECL #else #define THROW_DECL throw() -#endif +#endif // !_MSC_VER +#endif // !THROW_DECL #ifdef __cplusplus extern "C" { diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 7bf34963fc..67e39ae44f 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -143,11 +143,13 @@ typedef void * NATIVE_LIBRARY_HANDLE; #define LANG_THAI 0x1e /******************* Compiler-specific glue *******************************/ -#if defined(_MSC_VER) || defined(__llvm__) +#ifndef THROW_DECL +#if defined(_MSC_VER) || defined(__llvm__) || !defined(__cplusplus) #define THROW_DECL #else #define THROW_DECL throw() -#endif +#endif // !_MSC_VER +#endif // !THROW_DECL #ifndef _MSC_VER #if defined(CORECLR) @@ -367,7 +369,7 @@ int PALAPI PAL_Initialize( int argc, - const char * const argv[]); + char * const argv[]); PALIMPORT void @@ -4316,7 +4318,7 @@ EXTERN_C PALIMPORT void *PAL_memcpy (void *dest, const void *src, size_t count); -PALIMPORT void * __cdecl memcpy(void *, const void *, size_t); +PALIMPORT void * __cdecl memcpy(void *, const void *, size_t) THROW_DECL; #define memcpy PAL_memcpy #define IS_PAL_memcpy 1 diff --git a/src/pal/inc/unixasmmacros.inc b/src/pal/inc/unixasmmacros.inc index e7a5eba898..a1f1a694ee 100644 --- a/src/pal/inc/unixasmmacros.inc +++ b/src/pal/inc/unixasmmacros.inc @@ -10,7 +10,11 @@ #define LOCAL_LABEL(name) L##name #else #define C_FUNC(name) name +#if defined(_AMD64_) || defined(_X86_) #define EXTERNAL_C_FUNC(name) C_FUNC(name)@plt +#else +#define EXTERNAL_C_FUNC(name) C_FUNC(name) +#endif #define LOCAL_LABEL(name) .L##name #endif diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index 8e69ee9ee9..be5b5bd872 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -5,7 +5,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD) set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) endif(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD) -include_directories(SYSTEM /usr/local/include) +if(NOT DEFINED ENV{ROOTFS_DIR}) + include_directories(SYSTEM /usr/local/include) +endif() add_compile_options(-fPIC) diff --git a/src/pal/src/examples/example1.cpp b/src/pal/src/examples/example1.cpp index 576e76632e..fce8c367b5 100644 --- a/src/pal/src/examples/example1.cpp +++ b/src/pal/src/examples/example1.cpp @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) HANDLE h; unsigned int b; - PAL_Initialize(argc, (const char**)argv); + PAL_Initialize(argc, argv); SetCurrentDirectoryW(dir); SetCurrentDirectoryW(dir); h = CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL); diff --git a/src/pal/src/exception/remote-unwind.cpp b/src/pal/src/exception/remote-unwind.cpp index 4934e77115..fe7a4c814f 100644 --- a/src/pal/src/exception/remote-unwind.cpp +++ b/src/pal/src/exception/remote-unwind.cpp @@ -51,10 +51,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Sub-headers included from the libunwind.h contain an empty struct // and clang issues a warning. Until the libunwind is fixed, disable // the warning. +#ifdef __llvm__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wextern-c-compat" +#endif #include <libunwind.h> +#ifdef __llvm__ #pragma clang diagnostic pop +#endif SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp index 094036189c..3f40057d88 100644 --- a/src/pal/src/exception/seh-unwind.cpp +++ b/src/pal/src/exception/seh-unwind.cpp @@ -31,10 +31,14 @@ Abstract: // Sub-headers included from the libunwind.h contain an empty struct // and clang issues a warning. Until the libunwind is fixed, disable // the warning. +#ifdef __llvm__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wextern-c-compat" +#endif #include <libunwind.h> +#ifdef __llvm__ #pragma clang diagnostic pop +#endif //---------------------------------------------------------------------- // Virtual Unwinding diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp index d683ca7345..f6bbd6a82c 100644 --- a/src/pal/src/init/pal.cpp +++ b/src/pal/src/init/pal.cpp @@ -153,7 +153,7 @@ int PALAPI PAL_Initialize( int argc, - const char *const argv[]) + char *const argv[]) { return Initialize(argc, argv, PAL_INITIALIZE); } diff --git a/src/pal/src/libunwind/src/CMakeLists.txt b/src/pal/src/libunwind/src/CMakeLists.txt index c035f64c11..98d3d3e7a9 100644 --- a/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/pal/src/libunwind/src/CMakeLists.txt @@ -7,6 +7,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) include(configure.cmake) +if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wformat=0) + add_compile_options(-Wno-unused-value) +endif() + # The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") # which is incompatible with usage of the unwind code in a shared library. add_definitions(-DHAVE___THREAD=0) @@ -19,15 +24,19 @@ add_definitions(-D_GNU_SOURCE) # Ensure that the remote and local unwind code can reside in the same binary without name clashing add_definitions("-Ddwarf_search_unwind_table_int=UNW_OBJ(dwarf_search_unwind_table_int)") -add_compile_options(-Wno-header-guard) +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-header-guard) +endif() if(CLR_CMAKE_PLATFORM_ARCH_ARM) # Ensure that the remote and local unwind code can reside in the same binary without name clashing add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") # Disable warning in asm: use of SP or PC in the list is deprecated add_compile_options(-Wno-inline-asm) - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + endif() # Disable warning due to incorrect format specifier in debugging printf via the Debug macro add_compile_options(-Wno-format) # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise @@ -41,8 +50,10 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM) # the include/tdep-arm to include directories include_directories(../include/tdep-arm) elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + endif() # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension add_definitions(-Dasm=__asm__) elseif(CLR_CMAKE_PLATFORM_ARCH_I386) diff --git a/src/pal/tests/CMakeLists.txt b/src/pal/tests/CMakeLists.txt index 39d5852889..5597922f72 100644 --- a/src/pal/tests/CMakeLists.txt +++ b/src/pal/tests/CMakeLists.txt @@ -32,7 +32,11 @@ endif() # C++ emits errors and warnings for c-string literal fed into char* parameter # this is just to take care of the warnings -add_compile_options(-Wno-writable-strings) +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-writable-strings) +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options(-Wno-write-strings) +endif() add_compile_options(-Wno-empty-body) diff --git a/src/pal/tests/palsuite/CMakeLists.txt b/src/pal/tests/palsuite/CMakeLists.txt index 6f36025d1a..38b8ed0459 100644 --- a/src/pal/tests/palsuite/CMakeLists.txt +++ b/src/pal/tests/palsuite/CMakeLists.txt @@ -14,8 +14,15 @@ endif() list(APPEND COMMON_TEST_LIBRARIES coreclrpal) -add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) -add_compile_options(-Wno-int-to-void-pointer-cast) +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) + add_compile_options(-Wno-int-to-void-pointer-cast) +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options(-Wno-sign-compare) + add_compile_options(-Wno-narrowing) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive" ) + add_compile_options(-Wno-int-to-pointer-cast) +endif() # TODO: make these tests compile # add_subdirectory(composite) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp index 81d2502cd5..93fdb012d2 100644 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp @@ -69,7 +69,7 @@ int __cdecl main(int argc, char **argv) free(PrintResult); } - memset(name, '\0', 128); + memset(name, '\0', 128 * sizeof(name[0])); } PAL_Terminate(); diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp index ba80cf222d..45c0c98505 100644 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp +++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp @@ -62,7 +62,7 @@ int __cdecl main(int argc, char *argv[]) /* Initialize the buffer. */ - memset( szDirectory, '\0', 256 ); + memset( szDirectory, '\0', 256 * sizeof(szDirectory[0]) ); /* Change the current working directory. */ diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp index 25eb10d654..baf4b344f0 100644 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp +++ b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp @@ -61,7 +61,7 @@ int __cdecl main(int argc, char *argv[]) /* Initialize the buffer. */ - memset(szDirectory, '\0', 256); + memset(szDirectory, '\0', 256 * sizeof(szDirectory[0])); /* Create the path to the next level of directory to create. */ diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp index d45dc92f04..3895b71af9 100644 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp +++ b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp @@ -25,7 +25,7 @@ int test1(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -69,7 +69,7 @@ int test2(int num, ...) va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -106,7 +106,7 @@ int test3(int num, ...) { int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ TheString, /* message source */ @@ -144,7 +144,7 @@ int test4(int num, ...) { int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ TheString, /* message source */ @@ -182,7 +182,7 @@ int test5(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -222,7 +222,7 @@ int test6(int num, ...) { int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -264,7 +264,7 @@ int test7(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -307,7 +307,7 @@ int test8(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -351,7 +351,7 @@ int test9(int num, ...) { int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ TheString, /* message source */ @@ -393,7 +393,7 @@ int test10(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ TheString, /* message source */ @@ -435,7 +435,7 @@ int test11(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ @@ -505,7 +505,7 @@ int test12(int num, ...) int ReturnResult; va_list TheList; va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); + memset( OutBuffer, 0, 1024 * sizeof(OutBuffer[0]) ); ReturnResult = FormatMessage( FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp index bddbba7940..0c753be781 100644 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp +++ b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp @@ -86,7 +86,7 @@ int __cdecl main(int argc, char *argv[]) "the variable PALTEST.\n"); } - memset(NewValue,0,BUF_SIZE); + memset(NewValue,0,BUF_SIZE * sizeof(NewValue[0])); /* Grab the Environment variable we just set */ if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) <= 0) @@ -122,7 +122,7 @@ int __cdecl main(int argc, char *argv[]) "the variable PALTEST.\n"); } - memset(NewValue,0,BUF_SIZE); + memset(NewValue,0,BUF_SIZE*sizeof(NewValue[0])); /* Grab the Environment variable we just set, ensure that it's empty now. diff --git a/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp b/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp index 1ee410a6c5..34d3afbfb6 100644 --- a/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp +++ b/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp @@ -23,9 +23,9 @@ volatile DWORD dwThreadId1[NUM_TESTS]; DWORD PALAPI Thread( LPVOID lpParameter) { - dwThreadId1[(DWORD) lpParameter] = GetCurrentThreadId(); - bResult[(DWORD) lpParameter] = TRUE; - return (DWORD) lpParameter; + dwThreadId1[(DWORD)(SIZE_T)lpParameter] = GetCurrentThreadId(); + bResult[(DWORD)(SIZE_T) lpParameter] = TRUE; + return (DWORD)(SIZE_T) lpParameter; } struct testCase diff --git a/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp index caf1409406..9477633126 100644 --- a/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp +++ b/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp @@ -22,7 +22,7 @@ DWORD PALAPI ExitThreadTestThread( LPVOID lpParameter) DWORD dwRet = 0; /* Save parameter for test */ - dwExitThreadTestParameter = (DWORD)lpParameter; + dwExitThreadTestParameter = (DWORD)(SIZE_T)lpParameter; /* Call the ExitThread function */ ExitThread(dwRet); @@ -77,7 +77,7 @@ BOOL ExitThreadTest() /* Check to ensure that the parameter set in the Thread function is correct. */ - if (dwExitThreadTestParameter != (DWORD)lpParameter) + if (dwExitThreadTestParameter != (DWORD)(SIZE_T)lpParameter) { Trace("ERROR: The paramater passed should have been " "%d but turned up as %d.", diff --git a/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp index d2be262e4d..825064e23b 100644 --- a/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp +++ b/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp @@ -25,7 +25,7 @@ DWORD PALAPI ResumeThreadTestThread( LPVOID lpParameter) properly. */ - dwResumeThreadTestParameter = (DWORD)lpParameter; + dwResumeThreadTestParameter = (DWORD)(SIZE_T)lpParameter; return dwRet; } @@ -101,7 +101,7 @@ BOOL ResumeThreadTest() /* Check the param now and it should have been set. */ - if (dwResumeThreadTestParameter != (DWORD)lpParameter) + if (dwResumeThreadTestParameter != (DWORD)(SIZE_T)lpParameter) { Trace("ResumeThreadTest:parameter error\n"); } diff --git a/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp b/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp index c2ba4e704d..690acf5ce7 100644 --- a/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp +++ b/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp @@ -152,7 +152,7 @@ DWORD PALAPI SleeperProc(LPVOID lpParameter) BOOL Alertable; DWORD ret; - Alertable = (BOOL) lpParameter; + Alertable = (BOOL)(SIZE_T) lpParameter; LARGE_INTEGER performanceFrequency; if (!QueryPerformanceFrequency(&performanceFrequency)) diff --git a/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp index 76ecdd3572..ce03021b9e 100644 --- a/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp +++ b/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp @@ -83,7 +83,7 @@ INT __cdecl main( INT argc, CHAR **argv ) void PALAPI Run_Thread (LPVOID lpParam) { int i = 0; - int Id=(int)lpParam; + int Id=(int)(SIZE_T)lpParam; for(i=0; i < REPEAT_COUNT; i++ ) { diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp index b2bc301128..ffa496dd82 100644 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp +++ b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp @@ -146,7 +146,7 @@ DWORD PALAPI WaiterProc(LPVOID lpParameter) GetLastError()); } - Alertable = (BOOL) lpParameter; + Alertable = (BOOL)(SIZE_T) lpParameter; LARGE_INTEGER performanceFrequency; if (!QueryPerformanceFrequency(&performanceFrequency)) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp index a0216494ba..9d9e75b522 100644 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp +++ b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp @@ -74,7 +74,7 @@ DWORD PALAPI WaitForProcess(LPVOID lpParameter) DWORD dwRet; HANDLE handles[MAX_HELPER_PROCESS+1]; - index = (DWORD) lpParameter; + index = (DWORD)(SIZE_T) lpParameter; /* The helper thread 0 will wait for helper process 0, helper thread 1 will wait for helper process 0 and 1, helper thread 2 will wait for helper diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp index d5e3137899..1cec3492db 100644 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp +++ b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp @@ -154,7 +154,7 @@ DWORD PALAPI TestThread(PVOID pArg) BOOL bRemoteWaitAll = g_bRemoteWaitAll; int iDesiredExitCode; - dwThreadNum = (DWORD)pArg; + dwThreadNum = (DWORD)(SIZE_T)pArg; sprintf_s (szTestName, 128, "Test6_%u", dwThreadNum); szTestName[127] = 0; diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp index 3737f9cc10..f8fd7cbccc 100644 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp +++ b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp @@ -178,7 +178,7 @@ DWORD PALAPI WaiterProc(LPVOID lpParameter) BOOL Alertable; DWORD ret; - Alertable = (BOOL) lpParameter; + Alertable = (BOOL)(SIZE_T) lpParameter; LARGE_INTEGER performanceFrequency; if (!QueryPerformanceFrequency(&performanceFrequency)) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp index 793c50995c..d8816a7b98 100644 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp +++ b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp @@ -145,7 +145,7 @@ DWORD PALAPI WaiterProc(LPVOID lpParameter) GetLastError()); } - Alertable = (BOOL) lpParameter; + Alertable = (BOOL)(SIZE_T) lpParameter; OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp index 894d2804aa..a2c8850f79 100644 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp +++ b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp @@ -153,7 +153,7 @@ satisfying any threads that were waiting on the object. "GetLastError returned %d\n", GetLastError()); } - Alertable = (BOOL) lpParameter; + Alertable = (BOOL)(SIZE_T) lpParameter; LARGE_INTEGER performanceFrequency; if (!QueryPerformanceFrequency(&performanceFrequency)) diff --git a/src/pal/tools/gcc-compiler-override.txt b/src/pal/tools/gcc-compiler-override.txt new file mode 100644 index 0000000000..337d41af16 --- /dev/null +++ b/src/pal/tools/gcc-compiler-override.txt @@ -0,0 +1,20 @@ +SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-g -O0") +SET (CLR_C_FLAGS_CHECKED_INIT "-g -O2") +# Refer to the below instruction to support __thread with -O2/-O3 on Linux/ARM +# https://github.com/dotnet/coreclr/blob/master/Documentation/building/linux-instructions.md +SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O3") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O2") + +SET (CMAKE_CXX_FLAGS_INIT "-Wall -Werror=conversion-null -std=c++11") +SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0") +SET (CLR_CXX_FLAGS_CHECKED_INIT "-g -O2") +SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O3") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O2") + +SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1) +SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1) +SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail) +SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail) + +SET (CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh index 597ae5d76d..2047b1eccf 100755 --- a/src/pal/tools/gen-buildsys-clang.sh +++ b/src/pal/tools/gen-buildsys-clang.sh @@ -162,6 +162,7 @@ cmake \ "-DCMAKE_BUILD_TYPE=$buildtype" \ "-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \ "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \ + "-DCLR_CMAKE_COMPILER=Clang" \ $cmake_extra_defines \ $__UnprocessedCMakeArgs \ "$1" diff --git a/src/pal/tools/gen-buildsys-gcc.sh b/src/pal/tools/gen-buildsys-gcc.sh new file mode 100755 index 0000000000..cc141baae9 --- /dev/null +++ b/src/pal/tools/gen-buildsys-gcc.sh @@ -0,0 +1,188 @@ +#!/usr/bin/env sh +# +# This file invokes cmake and generates the build system for Gcc. +# + +if [ $# -lt 4 ] +then + echo "Usage..." + echo "gen-buildsys-gcc.sh <path to top level CMakeLists.txt> <GccMajorVersion> <GccMinorVersion> <Architecture> [build flavor] [coverage] [ninja] [cmakeargs]" + echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP" + echo "Specify the Gcc version to use, split into major and minor version" + echo "Specify the target architecture." + echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." + echo "Optionally specify 'coverage' to enable code coverage build." + echo "Target ninja instead of make. ninja must be on the PATH." + echo "Pass additional arguments to CMake call." + exit 1 +fi + +# Locate gcc +gcc_prefix="" + +if [ "$CROSSCOMPILE" = "1" ]; then + # Locate gcc + if [ ! -z "$TOOLCHAIN" ]; then + gcc_prefix="$TOOLCHAIN-" + fi +fi + +# Set up the environment to be used for building with gcc. +if command -v "${gcc_prefix}gcc-$2.$3" > /dev/null + then + desired_gcc_version="-$2.$3" +elif command -v "${gcc_prefix}gcc$2$3" > /dev/null + then + desired_gcc_version="$2$3" +elif command -v "${gcc_prefix}gcc-$2$3" > /dev/null + then + desired_gcc_version="-$2$3" +elif command -v ${gcc_prefix}gcc > /dev/null + then + desired_gcc_version= +else + echo "Unable to find $gcc_prefixgcc Compiler" + exit 1 +fi + +if [ -z "$CC" ]; then + export CC="$(command -v ${gcc_prefix}gcc$desired_gcc_version)" +fi +if [ -z "$CXX" ]; then + export CXX="$(command -v ${gcc_prefix}g++$desired_gcc_version)" +fi + +build_arch="$4" +buildtype=DEBUG +code_coverage=OFF +generator="Unix Makefiles" +__UnprocessedCMakeArgs="" + +ITER=-1 +for i in "$@"; do + ITER=$(($ITER + 1)) + if [ $ITER -lt 5 ]; then continue; fi + upperI="$(echo $i | awk '{print toupper($0)}')" + case $upperI in + # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO, MINSIZEREL. + DEBUG | CHECKED | RELEASE | RELWITHDEBINFO | MINSIZEREL) + buildtype=$upperI + ;; + COVERAGE) + echo "Code coverage is turned on for this build." + code_coverage=ON + ;; + NINJA) + generator=Ninja + ;; + *) + __UnprocessedCMakeArgs="${__UnprocessedCMakeArgs}${__UnprocessedCMakeArgs:+ }$i" + esac +done + +OS=`uname` + +locate_gcc_exec() { + if command -v "$gcc_prefix$1$desired_gcc_version" > /dev/null 2>&1 + then + echo "$(command -v $gcc_prefix$1$desired_gcc_version)" + elif command -v "$gcc_prefix$1" > /dev/null 2>&1 + then + echo "$(command -v $gcc_prefix$1)" + else + exit 1 + fi +} + +gcc_ar="$(locate_gcc_exec ar)" +[ $? -eq 0 ] || { echo "Unable to locate gcc-ar"; exit 1; } + +if [ -z "$CC" ]; then + gcc_link="$(locate_gcc_exec gcc)" + [ $? -eq 0 ] || { echo "Unable to locate gcc-link"; exit 1; } +else + gcc_link="$CC" +fi + +if [ -z "$NM" ]; then + gcc_nm="$(locate_gcc_exec nm)" + [ $? -eq 0 ] || { echo "Unable to locate gcc-nm"; exit 1; } +else + gcc_nm="$NM" +fi + +if [ "$OS" = "Linux" ] || [ "$OS" = "FreeBSD" ] || [ "$OS" = "OpenBSD" ] || [ "$OS" = "NetBSD" ] || [ "$OS" = "SunOS" ]; then + if [ -z "$OBJDUMP" ]; then + gcc_objdump="$(locate_gcc_exec objdump)" + [ $? -eq 0 ] || { echo "Unable to locate gcc-objdump"; exit 1; } + else + gcc_objdump="$OBJDUMP" + fi +fi + +if [ -z "$OBJCOPY" ]; then + gcc_objcopy="$(locate_gcc_exec objcopy)" + [ $? -eq 0 ] || { echo "Unable to locate gcc-objcopy"; exit 1; } +else + gcc_objcopy="$OBJCOPY" +fi + +gcc_ranlib="$(locate_gcc_exec ranlib)" +[ $? -eq 0 ] || { echo "Unable to locate gcc-ranlib"; exit 1; } + +cmake_extra_defines= +if [ -n "$LLDB_LIB_DIR" ]; then + cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR" +fi +if [ -n "$LLDB_INCLUDE_DIR" ]; then + cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR" +fi +if [ "$CROSSCOMPILE" = "1" ]; then + if [ -z "$ROOTFS_DIR" ]; then + echo "ROOTFS_DIR not set for crosscompile" + exit 1 + fi + if [ -z "$CONFIG_DIR" ]; then + CONFIG_DIR="$1/cross" + fi + export TARGET_BUILD_ARCH=$build_arch + cmake_extra_defines="$cmake_extra_defines -C $CONFIG_DIR/tryrun.cmake" + cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$CONFIG_DIR/toolchain.cmake" + cmake_extra_defines="$cmake_extra_defines --sysroot=$ROOTFS_DIR" + cmake_extra_defines="$cmake_extra_defines -DCLR_UNIX_CROSS_BUILD=1" +fi +if [ "$OS" = "Linux" ]; then + linux_id_file="/etc/os-release" + if [ -n "$CROSSCOMPILE" ]; then + linux_id_file="$ROOTFS_DIR/$linux_id_file" + fi + if [ -e "$linux_id_file" ]; then + . "$linux_id_file" + cmake_extra_defines="$cmake_extra_defines -DCLR_CMAKE_LINUX_ID=$ID" + fi +fi +if [ "$build_arch" = "armel" ]; then + cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1" +fi + +overridefile=gcc-compiler-override.txt + +# Determine the current script directory +__currentScriptDir="$(cd -- "$(dirname -- "$0")" && pwd -P)" + +cmake \ + -G "$generator" \ + "-DCMAKE_USER_MAKE_RULES_OVERRIDE=${__currentScriptDir}/$overridefile" \ + "-DCMAKE_AR=$gcc_ar" \ + "-DCMAKE_LINKER=$gcc_link" \ + "-DCMAKE_NM=$gcc_nm" \ + "-DCMAKE_RANLIB=$gcc_ranlib" \ + "-DCMAKE_OBJCOPY=$gcc_objcopy" \ + "-DCMAKE_OBJDUMP=$gcc_objdump" \ + "-DCMAKE_BUILD_TYPE=$buildtype" \ + "-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \ + "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \ + "-DCLR_CMAKE_COMPILER=GNU" \ + $cmake_extra_defines \ + $__UnprocessedCMakeArgs \ + "$1" |