This is an archive of the discontinued LLVM Phabricator instance.

Add x86 and x86_64 to the BareMetal toolchain
Needs ReviewPublic

Authored by agvallejo on Jul 4 2021, 5:15 PM.

Details

Reviewers
abidh
Summary

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

Diff Detail

Event Timeline

agvallejo created this revision.Jul 4 2021, 5:15 PM
agvallejo requested review of this revision.Jul 4 2021, 5:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2021, 5:15 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

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

abidh added a comment.Jul 5 2021, 3:17 AM

You need to add some tests that check the functionality that you are adding. Look at clang/test/Driver/baremetal.cpp for an example.

agvallejo updated this revision to Diff 357070.Jul 7 2021, 1:55 PM

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!