Disable -Os option for the latest gcc version

Signed-off-by: clover2123 <hyukwoo.park@jbnu.ac.kr>
This commit is contained in:
clover2123 2025-07-29 16:49:16 +09:00
commit adc8bbfecf
2 changed files with 8 additions and 13 deletions

View file

@ -52,7 +52,11 @@ ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
SET (ESCARGOT_CXXFLAGS_DEBUG -O0 -Wall -Wextra -Werror)
SET (ESCARGOT_CXXFLAGS_RELEASE -O2 -fno-stack-protector -fno-omit-frame-pointer)
IF (ESCARGOT_SMALL_CONFIG)
SET (ESCARGOT_CXXFLAGS_RELEASE ${ESCARGOT_CXXFLAGS_RELEASE} -Os)
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL 9)
# BUG?) -Os option has unknown memory conflicts (might be related with gcc version)
# enable this option only for old gcc version
SET (ESCARGOT_CXXFLAGS_RELEASE ${ESCARGOT_CXXFLAGS_RELEASE} -Os)
ENDIF()
ENDIF()
SET (ESCARGOT_THIRDPARTY_CFLAGS -w -g3 -fdata-sections -ffunction-sections -fno-omit-frame-pointer -fvisibility=hidden)
ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")

View file

@ -500,7 +500,7 @@ public:
void pushBack(const T& val, size_t newSize)
{
auto oldSize = newSize - 1;
expandBuffer(newSize, oldSize);
expandBuffer(newSize);
m_buffer[oldSize] = val;
}
@ -522,7 +522,7 @@ public:
void resize(size_t oldSize, size_t newSize, const T& val = T())
{
if (newSize) {
expandBuffer(newSize, oldSize);
expandBuffer(newSize);
for (size_t i = oldSize; i < newSize; i++) {
m_buffer[i] = val;
}
@ -534,7 +534,7 @@ public:
void resizeWithUninitializedValues(size_t oldSize, size_t newSize)
{
if (newSize) {
expandBuffer(newSize, oldSize);
expandBuffer(newSize);
} else {
GC_FREE(m_buffer);
m_buffer = nullptr;
@ -595,15 +595,6 @@ public:
}
protected:
void expandBuffer(size_t newSize, size_t oldSize)
{
if (m_buffer == nullptr) {
m_buffer = GCAllocator().allocate(newSize);
} else {
m_buffer = reinterpret_cast<T*>(GC_REALLOC_NO_SHRINK(m_buffer, newSize * sizeof(T)));
}
}
T* m_buffer;
};
} // namespace Escargot