LibC: Compile with -O2 optimizations

I have no idea why libc had no optimizations enabled.

Weird thing is that memcpy optimized to infinite loop if I kept the
__restrict__ attributes in pointers. I don't think there was any ub.
This commit is contained in:
Bananymous 2023-12-14 23:40:08 +02:00
parent 1800f62de4
commit 57eea81c7b
2 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ add_custom_target(crtx-install
add_library(libc ${LIBC_SOURCES}) add_library(libc ${LIBC_SOURCES})
add_dependencies(libc headers crtx-install) add_dependencies(libc headers crtx-install)
target_compile_options(libc PRIVATE -g -Wstack-usage=512) target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512)
target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=) target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)
add_custom_target(libc-install add_custom_target(libc-install

View File

@ -17,7 +17,7 @@ int memcmp(const void* s1, const void* s2, size_t n)
return 0; return 0;
} }
void* memcpy(void* __restrict__ dstp, const void* __restrict__ srcp, size_t n) void* memcpy(void* dstp, const void* srcp, size_t n)
{ {
unsigned char* dst = static_cast<unsigned char*>(dstp); unsigned char* dst = static_cast<unsigned char*>(dstp);
const unsigned char* src = static_cast<const unsigned char*>(srcp); const unsigned char* src = static_cast<const unsigned char*>(srcp);