From f6c52b913b2449297c54f9ab4802812d6c3bf7eb Mon Sep 17 00:00:00 2001 From: Gleb Balykov Date: Thu, 10 Jun 2021 02:28:45 +0300 Subject: [PATCH] Fix gcc armel/arm64 build (#53220) * Fix gcc armel build Mostly signed/unsigned comparisons, etc. * Fix gcc arm64 build --- src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h | 4 ++-- src/coreclr/jit/codegenarm.cpp | 2 +- src/coreclr/jit/gentree.cpp | 4 ++-- src/coreclr/pal/src/CMakeLists.txt | 2 +- src/coreclr/pal/src/misc/jitsupport.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h b/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h index dee5d760e302e..e696f469d17df 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h @@ -319,7 +319,7 @@ class LightWeightMap : public LightWeightMapBuffer // If we have RTTI, we can make this assert report the correct type. No RTTI, though, when // built with .NET Core, especially when built against the PAL. - AssertCodeMsg((ptr - bytes) == size, EXCEPTIONCODE_LWM, "%s - Ended with unexpected sizes %p != %x", + AssertCodeMsg(ptr == (bytes + size), EXCEPTIONCODE_LWM, "%s - Ended with unexpected sizes %p != %x", "Unknown type" /*typeid(_Item).name()*/, (void*)(ptr - bytes), size); return size; } @@ -656,7 +656,7 @@ class DenseLightWeightMap : public LightWeightMapBuffer ptr += bufferLength * sizeof(unsigned char); } - AssertCodeMsg((ptr - bytes) == size, EXCEPTIONCODE_LWM, "Ended with unexpected sizes %Ix != %x", ptr - bytes, + AssertCodeMsg(ptr == (bytes + size), EXCEPTIONCODE_LWM, "Ended with unexpected sizes %Ix != %x", ptr - bytes, size); return size; } diff --git a/src/coreclr/jit/codegenarm.cpp b/src/coreclr/jit/codegenarm.cpp index cc572c663c242..5993f7015ec2b 100644 --- a/src/coreclr/jit/codegenarm.cpp +++ b/src/coreclr/jit/codegenarm.cpp @@ -460,7 +460,7 @@ void CodeGen::genLclHeap(GenTree* tree) } // regCnt will be the total number of bytes to locAlloc - genSetRegToIcon(regCnt, amount, ((int)amount == amount) ? TYP_INT : TYP_LONG); + genSetRegToIcon(regCnt, amount, TYP_INT); } else { diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index e629d1a4b83ad..3596de621d664 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -7137,8 +7137,8 @@ bool GenTreeOp::UsesDivideByConstOptimized(Compiler* comp) else { // If the divisor is greater or equal than 2^(N - 1) then the result is either 0 or 1 - if (((divType == TYP_INT) && (divisorValue > (UINT32_MAX / 2))) || - ((divType == TYP_LONG) && (divisorValue > (UINT64_MAX / 2)))) + if (((divType == TYP_INT) && ((UINT32)divisorValue > (UINT32_MAX / 2))) || + ((divType == TYP_LONG) && ((UINT64)divisorValue > (UINT64_MAX / 2)))) { return true; } diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 49c7b1ed468af..ba13ab392f0c5 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -114,7 +114,7 @@ if(CLR_CMAKE_HOST_ARCH_ARM) endif() endif(CLR_CMAKE_HOST_ARCH_ARM) -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND (CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CMAKE_HOST_ARCH_I386)) add_compile_options(-Wa,--divide) endif() diff --git a/src/coreclr/pal/src/misc/jitsupport.cpp b/src/coreclr/pal/src/misc/jitsupport.cpp index 8678a479f10dc..973de4033e3d4 100644 --- a/src/coreclr/pal/src/misc/jitsupport.cpp +++ b/src/coreclr/pal/src/misc/jitsupport.cpp @@ -82,7 +82,7 @@ static const CpuCapability CpuCapabilities[] = { // If the capability name is not recognized or unused at present, zero is returned. static unsigned long LookupCpuCapabilityFlag(const char* start, size_t length) { - for (int i = 0; i < _countof(CpuCapabilities); i++) + for (size_t i = 0; i < _countof(CpuCapabilities); i++) { const char* capabilityName = CpuCapabilities[i].name; if ((length == strlen(capabilityName)) && (memcmp(start, capabilityName, length) == 0))