aboutsummaryrefslogtreecommitdiffstats
path: root/main/llvm/llvm-3.3-alpine-linux.patch
blob: bfb9de03286397dae1aeba25b12f13bc6d8bbcc6 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
--- llvm-3.3.src.orig/include/llvm/ADT/Triple.h
+++ llvm-3.3.src/include/llvm/ADT/Triple.h
@@ -117,7 +117,11 @@
     EABI,
     MachO,
     Android,
-    ELF
+    ELF,
+    UClibc,
+    Musl,
+    MuslEABI,
+    MuslEABIHF
   };
 
 private:
--- llvm-3.3.src.orig/lib/Support/Triple.cpp
+++ llvm-3.3.src/lib/Support/Triple.cpp
@@ -151,6 +151,10 @@
   case MachO: return "macho";
   case Android: return "android";
   case ELF: return "elf";
+  case UClibc: return "uclibc";
+  case Musl: return "musl";
+  case MuslEABI: return "muslgnueabi";
+  case MuslEABIHF: return "muslgnueabihf";
   }
 
   llvm_unreachable("Invalid EnvironmentType!");
@@ -300,6 +304,10 @@
     .StartsWith("macho", Triple::MachO)
     .StartsWith("android", Triple::Android)
     .StartsWith("elf", Triple::ELF)
+    .StartsWith("uclibc", Triple::UClibc)
+    .StartsWith("muslgnueabihf", Triple::MuslEABIHF)
+    .StartsWith("muslgnueabi", Triple::MuslEABI)
+    .StartsWith("musl", Triple::Musl)
     .Default(Triple::UnknownEnvironment);
 }
 
--- llvm-3.3.src.orig/tools/clang/lib/Driver/ToolChains.cpp
+++ llvm-3.3.src/tools/clang/lib/Driver/ToolChains.cpp
@@ -1086,7 +1086,9 @@
   };
   static const char *const ARMHFTriples[] = {
     "arm-linux-gnueabihf",
-    "armv7hl-redhat-linux-gnueabi"
+    "armv7hl-redhat-linux-gnueabi",
+    "armv6-alpine-linux-muslgnueabihf",
+    "armv7-alpine-linux-muslgnueabihf"
   };
 
   static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };
@@ -1099,7 +1101,9 @@
     "x86_64-suse-linux",
     "x86_64-manbo-linux-gnu",
     "x86_64-linux-gnu",
-    "x86_64-slackware-linux"
+    "x86_64-slackware-linux",
+    "x86_64-alpine-linux-uclibc",
+    "x86_64-alpine-linux-musl"
   };
   static const char *const X86LibDirs[] = { "/lib32", "/lib" };
   static const char *const X86Triples[] = {
@@ -1113,7 +1117,9 @@
     "i386-redhat-linux",
     "i586-suse-linux",
     "i486-slackware-linux",
-    "i686-montavista-linux"
+    "i686-montavista-linux",
+    "i486-alpine-linux-uclibc",
+    "i486-alpine-linux-musl"
   };
 
   static const char *const MIPSLibDirs[] = { "/lib" };
@@ -1980,6 +1986,7 @@
 /// Distribution (very bare-bones at the moment).
 
 enum Distro {
+  AlpineLinux,
   ArchLinux,
   DebianLenny,
   DebianSqueeze,
@@ -2108,6 +2115,9 @@
 
   if (!llvm::sys::fs::exists("/etc/arch-release", Exists) && Exists)
     return ArchLinux;
+
+  if (!llvm::sys::fs::exists("/etc/alpine-release", Exists) && Exists)
+    return AlpineLinux;
 
   return UnknownDistro;
 }
--- llvm-3.3.src.orig/tools/clang/lib/Driver/Tools.cpp
+++ llvm-3.3.src/tools/clang/lib/Driver/Tools.cpp
@@ -5983,16 +5983,37 @@
     CmdArgs.push_back("-dynamic-linker");
     if (isAndroid)
       CmdArgs.push_back("/system/bin/linker");
-    else if (ToolChain.getArch() == llvm::Triple::x86)
-      CmdArgs.push_back("/lib/ld-linux.so.2");
-    else if (ToolChain.getArch() == llvm::Triple::aarch64)
+    else if (ToolChain.getArch() == llvm::Triple::x86) {
+      switch (ToolChain.getTriple().getEnvironment()) {
+      case llvm::Triple::UClibc:
+        CmdArgs.push_back("/lib/ld-uClibc.so.0.9.32");
+        break;
+      case llvm::Triple::Musl:
+        CmdArgs.push_back("/lib/ld-musl-i386.so.1");
+        break;
+      default:
+        CmdArgs.push_back("/lib/ld-linux.so.2");
+        break;
+      }
+    } else if (ToolChain.getArch() == llvm::Triple::aarch64)
       CmdArgs.push_back("/lib/ld-linux-aarch64.so.1");
     else if (ToolChain.getArch() == llvm::Triple::arm ||
              ToolChain.getArch() == llvm::Triple::thumb) {
-      if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
+      switch (ToolChain.getTriple().getEnvironment()) {
+      case llvm::Triple::Musl:
+      case llvm::Triple::MuslEABI:
+        CmdArgs.push_back("/lib/ld-musl-arm.so.3");
+        break;
+      case llvm::Triple::MuslEABIHF:
+        CmdArgs.push_back("/lib/ld-musl-armhf.so.3");
+        break;
+      case llvm::Triple::GNUEABIHF:
         CmdArgs.push_back("/lib/ld-linux-armhf.so.3");
-      else
+        break;
+      default:
         CmdArgs.push_back("/lib/ld-linux.so.3");
+        break;
+      }
     }
     else if (ToolChain.getArch() == llvm::Triple::mips ||
              ToolChain.getArch() == llvm::Triple::mipsel)
@@ -6009,8 +6030,19 @@
     else if (ToolChain.getArch() == llvm::Triple::ppc64 ||
 	     ToolChain.getArch() == llvm::Triple::systemz)
       CmdArgs.push_back("/lib64/ld64.so.1");
-    else
-      CmdArgs.push_back("/lib64/ld-linux-x86-64.so.2");
+    else {
+      switch (ToolChain.getTriple().getEnvironment()) {
+      case llvm::Triple::Musl:
+        CmdArgs.push_back("/lib/ld-musl-x86_64.so.1");
+        break;
+      case llvm::Triple::UClibc:
+        CmdArgs.push_back("/lib/ld64-uClibc.so.0.9.32");
+        break;
+      default:
+        CmdArgs.push_back("/lib64/ld-linux-x86-64.so.2");
+        break;
+      }
+    }
   }
 
   CmdArgs.push_back("-o");