Repository navigation
Initial embedded ELF module loader. - #5504
Merged
Merged
Conversation
benvanik
force-pushed
the
benvanik-elf
branch
2 times, most recently
from
April 18, 2021 19:31
fbf71b9 to
136e655
Compare
benvanik
marked this pull request as ready for review
April 18, 2021 22:51
stellaraccident
approved these changes
Apr 19, 2021
stellaraccident
left a comment
Collaborator
There was a problem hiding this comment.
This is really awesome (and a good walk down memory lane for me). Thanks for the side chat with clarifications on specifics.
ScottTodd
approved these changes
Apr 19, 2021
ScottTodd
left a comment
Member
There was a problem hiding this comment.
I just scanned through, did not review all files in detail. Looks good :D
| typedef uint64_t iree_elf64_addr_t; | ||
| typedef uint16_t iree_elf64_half_t; | ||
| typedef uint64_t iree_elf64_off_t; | ||
| typedef int32_t iree_elf64_sword_t; |
Enabled with `-iree-llvm-link-embedded` and
`-iree-llvm-target-triple={any}-pc-linux-elf`.
~1000x faster than the system loader on Windows (60-100ms -> 50us)
and 64b + ELF memory usage.
Imports are not supported so it fails on any executable that ends up
using -lm (floorf, etc).
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enabled with
-iree-llvm-link-embeddedand-iree-llvm-target-triple={any}-pc-linux-elf.This is still considered experimental and not enabled by default. More verification is needed across platforms and we need to make progress on #4717 before more models can run.
~1000x faster than the system loader on Windows (60-100ms -> 50us) and 64b + ELF memory usage. Most of the time spent on Windows/x64 is in applying page protections:

Though this is a massive performance win the real benefit is dramatically simplified compiler configuration and cross-platform retargetability: there's no need for the Android NDK/etc, cross-compilation (Linux->Windows->Mac->etc) is trivial, and the ELF files we generate will run anywhere C will run and we can PROT_EXEC. Users just need lld (ld may work, but eh) with the appropriate target architectures built into it and we will only need to embed one binary per architecture (vs one per architecture crossed with all platforms it may be used on). This is how we get portable AOT execution on the cheap.
Imports are not supported so it fails on any executable that ends up using -lm (floorf, etc).
The
iree-translateinvocation I'm using to produce the executables attempts to work around this in some cases withfmaf:Tentative support is in place for bare-metal targets via the new
IREE_PLATFORM_GENERICselector; it's untested but likely to be just a short iteration from working. This path requires no syscalls (file IO, dlopen, mmap, etc) and just C11's aligned_alloc/free.Fixes #5351.