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

Shorten the generated code with ./release-rs.sh --features short #40

Merged
merged 61 commits into from
Dec 9, 2023

Conversation

byeongkeunahn
Copy link
Collaborator

@byeongkeunahn byeongkeunahn commented Nov 30, 2023

The newly introduced short feature enables the following during build to generate shorter outputs:

  • Omit platform-abstraction layer (PAL) routines for Windows, assuming a Linux environment
  • Omit system calls that increase the stack size to 256M or more when running natively (this prevents segmentation faults due to stack overflow in local testing environments, but not needed in online judges)
  • Omit support for running natively without loader, in the entrypoint routine (_start)
  • Use dedicated target.json to disable stack probes and read-only relocations (RELRO)
  • Use potentially slower but massively shorter I/O routines
  • Use shorter, minified template
  • Try embedding the code without compression and choose it if it is shorter (the zeros in the binary are abridged using a rudimentary run-length encoding)
  • Support for 156KB/0ms with C/C++: the thunk freeing off the .text section to reduce memory usage is adapted for the base91 setting

The following improvements benefit the generated code with or without the short feature enabled:

  • Simplify the dynamic relocation stub to generate a shorter machine code
  • Simplify the I/O routine
  • Do not pass unnecessary zeros to system calls
  • Streamline the DYNAMIC section of the generated ELF executable by removing all entries except mandatory ones related to dynamic relocation

Full command: `./release-rs.sh --features short`
This was necessary when we used a hack to support debugging; this is no longer the case since we can now run the built executable natively.
Specifically, we disable read-only relocations and stack probes.
Shorten the generated code with `./release-rs.sh --features short`
Reduces the generated code length for extremely short codes.
Shorten the generated code in short mode
Shorten the generated code in short mode
Update VS Code task + Change python -> python3
short: fix rsp alignment issue
We eliminate all entries except necessary relocation-related ones.
Enables 156KB/0ms with the shorter generation paradigm.
short: introduce shorter template for C/C++
Short: fix rsp alignment bug & add CI test
@byeongkeunahn
Copy link
Collaborator Author

The Windows CI build failure is due to a recent PR in the rust compiler. The issue was reported and subsequently fixed which is now merged in the latest nightly. The failed jobs will succeed if run again.

@kiwiyou kiwiyou merged commit fff8aa3 into boj-rs:attach-reloc Dec 9, 2023
5 checks passed
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.

2 participants