summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/clang/clang/0001-llvm-triplet-Add-musl-support.patch
blob: 9c3da683642bc50c406531a2fc5108067241068d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From ff9b9c7b143b51d9f9c203f6bc74e1f479d883b9 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 30 Mar 2016 19:55:41 -0700
Subject: [PATCH 1/4] llvm: triplet: Add musl support

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 include/llvm/ADT/Triple.h           | 13 +++++++++++++
 lib/Support/Triple.cpp              |  8 ++++++++
 lib/Target/ARM/ARMSubtarget.h       |  3 +++
 lib/Target/ARM/ARMTargetMachine.cpp |  2 ++
 4 files changed, 26 insertions(+)

diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index c89cf4d..29ec600 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -175,6 +175,10 @@ public:
     GNUEABI,
     GNUEABIHF,
     GNUX32,
+    MUSL,
+    MUSLEABI,
+    MUSLEABIHF,
+    MUSLX32,
     CODE16,
     EABI,
     EABIHF,
@@ -497,6 +501,15 @@ public:
     return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU;
   }
 
+  /// Checks if the environment is Linux with musl
+  bool isLinuxMuslEnvironment() const {
+    return isOSLinux() &&
+           (getEnvironment() == Triple::MUSL ||
+            getEnvironment() == Triple::MUSLX32 ||
+            getEnvironment() == Triple::MUSLEABI ||
+            getEnvironment() == Triple::MUSLEABIHF);
+  }
+
   /// Tests for either Cygwin or MinGW OS
   bool isOSCygMing() const {
     return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index 1967fac..f8b6236 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -201,6 +201,10 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
   case GNUEABIHF: return "gnueabihf";
   case GNUEABI: return "gnueabi";
   case GNUX32: return "gnux32";
+  case MUSL: return "musl";
+  case MUSLEABIHF: return "musleabihf";
+  case MUSLEABI: return "musleabi";
+  case MUSLX32: return "muslx32";
   case CODE16: return "code16";
   case EABI: return "eabi";
   case EABIHF: return "eabihf";
@@ -461,6 +465,10 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
     .StartsWith("gnueabihf", Triple::GNUEABIHF)
     .StartsWith("gnueabi", Triple::GNUEABI)
     .StartsWith("gnux32", Triple::GNUX32)
+    .StartsWith("musleabihf", Triple::MUSLEABIHF)
+    .StartsWith("musleabi", Triple::MUSLEABI)
+    .StartsWith("muslx32", Triple::MUSLX32)
+    .StartsWith("musl", Triple::MUSL)
     .StartsWith("code16", Triple::CODE16)
     .StartsWith("gnu", Triple::GNU)
     .StartsWith("android", Triple::Android)
diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h
index 7c9ea7d..09c4051 100644
--- a/lib/Target/ARM/ARMSubtarget.h
+++ b/lib/Target/ARM/ARMSubtarget.h
@@ -424,8 +424,10 @@ public:
   bool isTargetEHABICompatible() const {
     return (TargetTriple.getEnvironment() == Triple::EABI ||
             TargetTriple.getEnvironment() == Triple::GNUEABI ||
+            TargetTriple.getEnvironment() == Triple::MUSLEABI ||
             TargetTriple.getEnvironment() == Triple::EABIHF ||
             TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
+            TargetTriple.getEnvironment() == Triple::MUSLEABIHF ||
             isTargetAndroid()) &&
            !isTargetDarwin() && !isTargetWindows();
   }
@@ -433,6 +435,7 @@ public:
   bool isTargetHardFloat() const {
     // FIXME: this is invalid for WindowsCE
     return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
+           TargetTriple.getEnvironment() == Triple::MUSLEABIHF ||
            TargetTriple.getEnvironment() == Triple::EABIHF ||
            isTargetWindows() || isAAPCS16_ABI();
   }
diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
index 81127f7..c90ec0f 100644
--- a/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/lib/Target/ARM/ARMTargetMachine.cpp
@@ -100,6 +100,8 @@ computeTargetABI(const Triple &TT, StringRef CPU,
     case llvm::Triple::Android:
     case llvm::Triple::GNUEABI:
     case llvm::Triple::GNUEABIHF:
+    case llvm::Triple::MUSLEABI:
+    case llvm::Triple::MUSLEABIHF:
     case llvm::Triple::EABIHF:
     case llvm::Triple::EABI:
       TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS;
-- 
2.8.2