Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #122 from ColinFinck/rust-llvm-release-7-0-0-v1
Browse files Browse the repository at this point in the history
Add support for writing HermitCore (https://hermitcore.org) ELF binaries
  • Loading branch information
alexcrichton authored Aug 30, 2018
2 parents f4130c0 + 04277e8 commit f8053e8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ class Triple {
Mesa3D,
Contiki,
AMDPAL, // AMD PAL Runtime
LastOSType = AMDPAL
HermitCore, // HermitCore Unikernel/Multikernel
LastOSType = HermitCore
};
enum EnvironmentType {
UnknownEnvironment,
Expand Down
2 changes: 2 additions & 0 deletions include/llvm/MC/MCELFObjectWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
switch (OSType) {
case Triple::CloudABI:
return ELF::ELFOSABI_CLOUDABI;
case Triple::HermitCore:
return ELF::ELFOSABI_STANDALONE;
case Triple::PS4:
case Triple::FreeBSD:
return ELF::ELFOSABI_FREEBSD;
Expand Down
2 changes: 2 additions & 0 deletions lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case Mesa3D: return "mesa3d";
case Contiki: return "contiki";
case AMDPAL: return "amdpal";
case HermitCore: return "hermit";
}

llvm_unreachable("Invalid OSType");
Expand Down Expand Up @@ -502,6 +503,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("mesa3d", Triple::Mesa3D)
.StartsWith("contiki", Triple::Contiki)
.StartsWith("amdpal", Triple::AMDPAL)
.StartsWith("hermit", Triple::HermitCore)
.Default(Triple::UnknownOS);
}

Expand Down
6 changes: 6 additions & 0 deletions unittests/ADT/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Fuchsia, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("x86_64-unknown-hermit");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::HermitCore, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("wasm32-unknown-unknown");
EXPECT_EQ(Triple::wasm32, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Expand Down

0 comments on commit f8053e8

Please sign in to comment.