From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Sat, 11 Feb 2023 07:07:55 +0000 (+0200) Subject: Disable RTTI on Unix (#81986) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4086 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1750538a21be8b270c2c30f9762acd7689923917;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Disable RTTI on Unix (#81986) * Disable RTTI on Unix * Fix gcc build * Fix gcc 12.2 release build --- diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 34fb9a5..3c667e1 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -430,6 +430,8 @@ if (CLR_CMAKE_HOST_UNIX) # optimization in the IEEE 754 specification and is therefore considered unsafe. add_compile_options(-ffp-contract=off) + add_compile_options($<$:-fno-rtti>) + if (CMAKE_C_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-unknown-warning-option) diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index f6772eb..55331a2 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -103,7 +103,7 @@ extends: buildConfig: checked platforms: - linux_x64 - container: debian-11-gcc12-amd64-20220511124845-b7a6185 + container: debian-11-gcc12-amd64 jobParameters: testGroup: innerloop compilerName: gcc diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index a593a2f..be86161 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -23,12 +23,6 @@ if(MSVC) endif (MSVC) if(CLR_CMAKE_HOST_UNIX) - # Up for grabs to clean these warnings up - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-error) - endif() - - add_compile_options(-fno-rtti) # Native AOT runtime doesn't use RTTI add_compile_options(-fno-exceptions) # Native AOT runtime doesn't use C++ exception handling add_compile_options(-nostdlib) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h index 5c6f8ab..fbb298b 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h @@ -2624,7 +2624,7 @@ ep_rt_utf16_to_utf8_string ( // shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase // TODO: Temp implementation that is the reverse of ep_rt_utf8_to_utf16le_string size_t len_utf16 = len; - if(len_utf16 == -1) + if(len_utf16 == (size_t)-1) { len_utf16 = ep_rt_utf16_string_len (str); } diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index 790952f..85ca5a2 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -4188,7 +4188,7 @@ void DomainLocalModule::EnsureDynamicClassIndex(DWORD dwID) if (oldDynamicEntries != 0) { - memcpy(pNewDynamicClassTable, m_pDynamicClassTable, sizeof(DynamicClassInfo) * oldDynamicEntries); + memcpy((void*)pNewDynamicClassTable, m_pDynamicClassTable, sizeof(DynamicClassInfo) * oldDynamicEntries); } // Note: Memory allocated on loader heap is zero filled diff --git a/src/coreclr/vm/gdbjit.cpp b/src/coreclr/vm/gdbjit.cpp index 0f22e98..ed4d2eb 100644 --- a/src/coreclr/vm/gdbjit.cpp +++ b/src/coreclr/vm/gdbjit.cpp @@ -526,7 +526,7 @@ GetDebugInfoFromPDB(MethodDesc* methodDescPtr, locals.localsName = new NewArrayHolder[locals.size]; locals.localsScope = new LocalsInfo::Scope [locals.size]; - for (ULONG32 i = 0; i < locals.size; i++) + for (int i = 0; i < locals.size; i++) { size_t sizeRequired = WideCharToMultiByte(CP_UTF8, 0, methodDebugInfo.locals[i].name, -1, NULL, 0, NULL, NULL); locals.localsName[i] = new char[sizeRequired]; @@ -553,11 +553,11 @@ GetDebugInfoFromPDB(MethodDesc* methodDescPtr, s.source = map[j].source; s.lineNumber = 0; - for (ULONG32 i = 0; i < methodDebugInfo.size; i++) + for (int i = 0; i < methodDebugInfo.size; i++) { const SequencePointInfo& sp = methodDebugInfo.points[i]; - if (methodDebugInfo.points[i].ilOffset == map[j].ilOffset) + if ((ULONG)(methodDebugInfo.points[i].ilOffset) == map[j].ilOffset) { s.fileIndex = 0; int len = WideCharToMultiByte(CP_UTF8, 0, sp.fileName, -1, s.fileName, sizeof(s.fileName), NULL, NULL); @@ -1333,7 +1333,7 @@ bool FunctionMember::GetBlockInNativeCode(int blockILOffset, int blockILLen, TAD bool inBlock = false; - for (int i = 0; i < nlines; ++i) + for (unsigned i = 0; i < nlines; ++i) { TADDR nativeOffset = lines[i].nativeOffset + pCode; @@ -1387,20 +1387,21 @@ void FunctionMember::DumpTryCatchBlock(char* ptr, int& offset, int ilOffset, int TADDR startOffset; TADDR endOffset; - if (!GetBlockInNativeCode(ilOffset, ilLen, &startOffset, &endOffset)) - return; - - if (ptr != nullptr) + if (GetBlockInNativeCode(ilOffset, ilLen, &startOffset, &endOffset)) { - DebugInfoTryCatchSub subEntry; + if (ptr != nullptr) + { + DebugInfoTryCatchSub subEntry; - subEntry.m_sub_abbrev = abbrev; - subEntry.m_sub_low_pc = md->GetNativeCode() + startOffset; - subEntry.m_sub_high_pc = endOffset - startOffset; + subEntry.m_sub_abbrev = abbrev; + subEntry.m_sub_low_pc = md->GetNativeCode() + startOffset; + subEntry.m_sub_high_pc = endOffset - startOffset; + + memcpy(ptr + offset, &subEntry, sizeof(DebugInfoTryCatchSub)); + } - memcpy(ptr + offset, &subEntry, sizeof(DebugInfoTryCatchSub)); + offset += sizeof(DebugInfoTryCatchSub); } - offset += sizeof(DebugInfoTryCatchSub); } void FunctionMember::DumpTryCatchDebugInfo(char* ptr, int& offset) @@ -1693,7 +1694,7 @@ void ClassTypeInfo::DumpDebugInfo(char* ptr, int& offset) { DebugInfoInheritance buf; buf.m_abbrev = 18; - if (RefTypeInfo *m_p = dynamic_cast(m_parent)) + if (RefTypeInfo *m_p = (RefTypeInfo*)(m_parent)) buf.m_type = m_p->m_value_type->m_type_offset; else buf.m_type = m_parent->m_type_offset; @@ -3116,12 +3117,12 @@ public: unsigned totalSize = 0; // Compute buffer size - for (unsigned i = 0; i < m_dirs_count; ++i) + for (int i = 0; i < m_dirs_count; ++i) totalSize += strlen(m_dirs[i]) + 1; totalSize += 1; char cnv_buf[16]; - for (unsigned i = 0; i < m_files_count; ++i) + for (int i = 0; i < m_files_count; ++i) { int len = Leb128Encode(static_cast(m_files[i].dir), cnv_buf, sizeof(cnv_buf)); totalSize += strlen(m_files[i].name) + 1 + len + 2; @@ -3134,7 +3135,7 @@ public: char *ptr = buf.MemPtr; - for (unsigned i = 0; i < m_dirs_count; ++i) + for (int i = 0; i < m_dirs_count; ++i) { strcpy(ptr, m_dirs[i]); ptr += strlen(m_dirs[i]) + 1; @@ -3142,7 +3143,7 @@ public: // final zero byte for directory table *ptr++ = 0; - for (unsigned i = 0; i < m_files_count; ++i) + for (int i = 0; i < m_files_count; ++i) { strcpy(ptr, m_files[i].name); ptr += strlen(m_files[i].name) + 1; @@ -3223,7 +3224,7 @@ static void fixLineMapping(SymbolsInfo* lines, unsigned nlines) { // Fix EPILOGUE line mapping int prevLine = 0; - for (int i = 0; i < nlines; ++i) + for (unsigned i = 0; i < nlines; ++i) { if (lines[i].lineNumber == HiddenLine) continue; @@ -3255,12 +3256,12 @@ static void fixLineMapping(SymbolsInfo* lines, unsigned nlines) prevLine = lines[i].lineNumber; } // Skip HiddenLines - for (int i = 0; i < nlines; ++i) + for (unsigned i = 0; i < nlines; ++i) { if (lines[i].lineNumber == HiddenLine) { lines[i].lineNumber = 0; - if (i + 1 < nlines && lines[i + 1].ilOffset == ICorDebugInfo::NO_MAPPING) + if ((unsigned)(i + 1) < nlines && lines[i + 1].ilOffset == ICorDebugInfo::NO_MAPPING) lines[i + 1].lineNumber = 0; } } @@ -3290,7 +3291,7 @@ bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, TADDR codeSize, Symb int prevLine = 1, prevFile = 0; - for (int i = 0; i < nlines; ++i) + for (unsigned i = 0; i < nlines; ++i) { /* different source file */ if (lines[i].fileIndex != prevFile) @@ -3326,7 +3327,7 @@ bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, TADDR codeSize, Symb int lastAddr = nlines > 0 ? lines[nlines - 1].nativeOffset : 0; // Advance PC to the end of function - if (lastAddr < codeSize) { + if ((TADDR)lastAddr < codeSize) { int len = Leb128Encode(static_cast(codeSize - lastAddr), cnv_buf, sizeof(cnv_buf)); IssueParamCommand(ptr, DW_LNS_advance_pc, cnv_buf, len); } diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 632f38d..431b49a 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -11718,7 +11718,7 @@ void MethodTableBuilder::bmtMethodImplInfo::AddMethodImpl( // because this is a stacking allocator. However, the old array will get freed when all the stack allocator is freed. Entry *rgEntriesNew = new (pStackingAllocator) Entry[newEntriesCount]; if (cMaxIndex > 0) - memcpy(rgEntriesNew, rgEntries, sizeof(Entry) * cMaxIndex); + memcpy((void*)rgEntriesNew, rgEntries, sizeof(Entry) * cMaxIndex); // Start using newly allocated array. rgEntries = rgEntriesNew; diff --git a/src/coreclr/vm/syncblk.cpp b/src/coreclr/vm/syncblk.cpp index 46765ba..8be38ce 100644 --- a/src/coreclr/vm/syncblk.cpp +++ b/src/coreclr/vm/syncblk.cpp @@ -1102,7 +1102,7 @@ void SyncBlockCache::GCWeakPtrScan(HANDLESCANPROC scanProc, uintptr_t lp1, uintp syncTableShadow = new(nothrow) SyncTableEntry [m_FreeSyncTableIndex]; if (syncTableShadow) { - memcpy (syncTableShadow, SyncTableEntry::GetSyncTableEntry(), m_FreeSyncTableIndex * sizeof (SyncTableEntry)); + memcpy ((void*)syncTableShadow, SyncTableEntry::GetSyncTableEntry(), m_FreeSyncTableIndex * sizeof (SyncTableEntry)); } } #endif //VERIFY_HEAP