x86_64-unknown-elf should provide an freestanding environment usable
in kernel development. Currently it defaults to Generic_ELF, which
inherits from Generic_GCC, which is tied to the host platform. The
Baremetal toolchain seems like a better choice to add support for
x86 kernel cross-compilation without adding a lot of overrides on
the command line
Details
- Reviewers
abidh
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I'm still testing this patch, but so far it seems to do the trick. I'm able to compile with clang, link with lld and the resulting ELF file appears to be correctly free from host dependencies. The command lines (seen with clang -v) don't throw the host include paths, host libraries or a dynamic linker into the mix, so that's also good. I'm new to the LLVM codebase, so please bear with me if this has unintended side-effects
You need to add some tests that check the functionality that you are adding. Look at clang/test/Driver/baremetal.cpp for an example.
Fulfill merge requirements
-Fixed clang-format complaint
-Added CLI processing tests for i686 and x86_64
(freestanding+nostdlib only)
It took me a while to get the gist of FileCheck, but it finally clicked.
@abidh: Thanks for the pointer!