Skip to content

Commit

Permalink
Show how ThinLTO can be supported
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jan 27, 2018
1 parent 637a949 commit e3b4e72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/crt/c_abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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++)
Expand Down

0 comments on commit e3b4e72

Please sign in to comment.