Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Link Time Optimization (LTO) #714

Open
wants to merge 3 commits into
base: develop-pros-4
Choose a base branch
from

Conversation

SizzinSeal
Copy link

Summary:

Use Link Time Optimization (LTO) when building templates. Closes #660

Motivation:

Significantly reduced binary size. This means:

  • less storage used on V5
  • faster upload times
  • faster template download times
  • less RAM used on V5

this applies to both the PROS kernel, and all PROS templates

Implementation

If IS_LIBRARY is equal to 1, then -flto is added to GCCFLAGS. This is done so LTO is not used for user projects, where LTO would have minimal effect yet build time is noticeably increased.

Since LTO can break when compiling code that does not follow strict aliasing rules, some code in PROS had to be modified. While one could just use -fno-strict-aliasing and -Wno-lto-type-mismatch, the benefits of LTO would be reduced, so instead these issues have been fixed.

Binary Size

(pending build by PROS)

Build times

(pending build by PROS)

Test Plan:

  • compiles
  • user code compiles
  • linker does not use excessive resources (<50mb RAM)
  • hot/cold linking works
  • stack traces work
  • tasks work
  • linker scripts still work

@SizzinSeal
Copy link
Author

I'm having some trouble with linker errors when compiling the cold package in a user project:

Creating cold package with libc,libm,libpros [ERRORS]
C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/13.3 rel1/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\LIAMTE~1\AppData\Local\Temp\ccQ6AcFr.ltrans0.ltrans.o:(.ARM.extab.text._ZNSt12system_errorC2ESt10error_codePKc+0x0): undefined reference to `__gcc_personality_v0'
C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/13.3 rel1/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\LIAMTE~1\AppData\Local\Temp\ccQ6AcFr.ltrans0.ltrans.o: in function `DataAbortInterrupt':
C:\Users\Liam Teale\Documents\Code\PROS\lto-test/../pros/src/system/unwind.c:70:(.text.DataAbortInterrupt+0x140): undefined reference to `putchar'
C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/13.3 rel1/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\LIAMTE~1\AppData\Local\Temp\ccQ6AcFr.ltrans0.ltrans.o: in function `main':
C:\Users\Liam Teale\Documents\Code\PROS\lto-test/../pros/src/system/startup.c:61:(.text.startup.main+0x21c): undefined reference to `puts'
collect2.exe: error: ld returned 1 exit status
make: *** [common.mk:242: bin/cold.package.elf] Error 1

I'm stumped by this one. It links fine as a kernel project, but not as a user project. Need some help with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant