tools+libluna: Make new and delete weak to avoid conflicts with libstdc++
Wasn't causing problems earlier, but when trying to rebuild the toolchain, it failed because of this.
This commit is contained in:
parent
abbfd5825f
commit
0abd9153ae
@ -51,6 +51,9 @@ add_library(luna ${SOURCES})
|
||||
target_compile_options(luna PRIVATE ${COMMON_FLAGS})
|
||||
target_include_directories(luna PUBLIC include/)
|
||||
target_include_directories(luna PUBLIC ${LUNA_BASE}/usr/include)
|
||||
if(DEFINED LIBC_BOOTSTRAP)
|
||||
target_compile_definitions(luna PUBLIC LIBC_BOOTSTRAP)
|
||||
endif()
|
||||
|
||||
if("${LUNA_ARCH}" MATCHES "x86_64")
|
||||
target_compile_options(luna-freestanding PRIVATE -mno-red-zone)
|
||||
|
@ -420,35 +420,39 @@ void dump_heap_usage()
|
||||
dbgln("-- Heap memory in use: %zu bytes", alloc_used);
|
||||
}
|
||||
|
||||
// Otherwise, this is defined in libstdc++.
|
||||
#ifdef USE_FREESTANDING
|
||||
void* operator new(usize size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
return malloc_impl(size, false, false).value_or(nullptr);
|
||||
}
|
||||
|
||||
void* operator new[](usize size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
return malloc_impl(size, false, false).value_or(nullptr);
|
||||
}
|
||||
|
||||
void operator delete(void* p) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
||||
void operator delete[](void* p) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
||||
void operator delete(void* p, usize) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
||||
void operator delete[](void* p, usize) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
#if defined(USE_FREESTANDING) || defined(LIBC_BOOTSTRAP)
|
||||
#define WEAK
|
||||
#else
|
||||
#define WEAK __attribute__((weak))
|
||||
#endif
|
||||
|
||||
// If libstdc++ is linked, it should override these definitions.
|
||||
void* WEAK operator new(usize size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
return malloc_impl(size, false, false).value_or(nullptr);
|
||||
}
|
||||
|
||||
void* WEAK operator new[](usize size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
return malloc_impl(size, false, false).value_or(nullptr);
|
||||
}
|
||||
|
||||
void WEAK operator delete(void* p) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
||||
void WEAK operator delete[](void* p) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
||||
void WEAK operator delete(void* p, usize) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
||||
void WEAK operator delete[](void* p, usize) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ make install-gcc
|
||||
make install-target-libgcc
|
||||
|
||||
mkdir -p $LUNA_BUILD_DIR
|
||||
cmake -S $LUNA_ROOT -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake -S $LUNA_ROOT -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME" -DLIBC_BOOTSTRAP=1
|
||||
cmake --build $LUNA_BUILD_DIR --target libc
|
||||
|
||||
make all-target-libstdc++-v3 CXXFLAGS_FOR_TARGET="-fno-exceptions" -j$(nproc)
|
||||
|
Loading…
Reference in New Issue
Block a user