diff --git a/Makefile b/Makefile index 728fa0f..94ddd54 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,16 @@ CPP_FILES += ext/EASTL/source/allocator_eastl.cpp ext/EASTL/source/assert.cpp \ ext/EASTL/source/intrusive_list.cpp ext/EASTL/source/numeric_limits.cpp \ ext/EASTL/source/red_black_tree.cpp ext/EASTL/source/string.cpp -GDEFS = -DEASTL_SIZE_T_32BIT=1 +GDEFS = +OPTIMIZE = -O2 -OPTIONS=-m32 -msse3 $(INCLUDE) $(GDEFS) +## to enable ThinLTO use these ## +#CC=.../clang-trunk/bin/clang-5.0 +#CXX=.../clang-trunk/bin/clang++-5.0 +#LD=ld.lld-5.0 +#LTO_DEFS=-flto=thin + +OPTIONS=-m32 -msse3 $(INCLUDE) $(GDEFS) $(OPTIMIZE) $(LTO_DEFS) WARNS=-Wall -Wextra -pedantic COMMON=-ffreestanding -nostdlib -MMD -fstack-protector-strong $(OPTIONS) $(WARNS) LDFLAGS=-static -nostdlib -melf_i386 --strip-all --script=src/linker.ld diff --git a/README.md b/README.md index 330643d..26e0124 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ - Stack protector support - EASTL C++ support, which has many useful containers - Entire machine image is 32kb (8k without EASTL) +- ThinLTO support if you build your own clang toolchain from trunk + - Machine image goes from 32kb to 11kb with LTO ## Goal diff --git a/src/crt/c_abi.c b/src/crt/c_abi.c index 21057a3..ee2917b 100644 --- a/src/crt/c_abi.c +++ b/src/crt/c_abi.c @@ -30,6 +30,7 @@ void __stack_chk_fail_local() panic("Stack protector: Canary modified"); __builtin_unreachable(); } +__attribute__((used)) void __stack_chk_fail() { panic("Stack protector: Canary modified"); @@ -65,6 +66,7 @@ void panic(const char* why) __builtin_unreachable(); } +__attribute__((used)) void* memset(char* dest, int ch, size_t size) { for (size_t i = 0; i < size; i++)