aboutsummaryrefslogtreecommitdiffstats
path: root/main/llvm/llvm-3.3-alpine-linux.patch
blob: 49649732717d1a3b7d822fc40d435297ec4ecbd5 (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
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index 3a72e87..ac4c3ea 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -117,7 +117,8 @@ public:
     EABI,
     MachO,
     Android,
-    ELF
+    ELF,
+    UClibc
   };
 
 private:
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index 412e34c..64dfce8 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -151,6 +151,7 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
   case MachO: return "macho";
   case Android: return "android";
   case ELF: return "elf";
+  case UClibc: return "uclibc";
   }
 
   llvm_unreachable("Invalid EnvironmentType!");
@@ -300,6 +301,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
     .StartsWith("macho", Triple::MachO)
     .StartsWith("android", Triple::Android)
     .StartsWith("elf", Triple::ELF)
+    .StartsWith("uclibc", Triple::UClibc)
     .Default(Triple::UnknownEnvironment);
 }
 
diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
index fffba0e..797d0c1 100644
--- a/tools/clang/lib/Driver/ToolChains.cpp
+++ b/tools/clang/lib/Driver/ToolChains.cpp
@@ -1099,7 +1099,8 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
     "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"
   };
   static const char *const X86LibDirs[] = { "/lib32", "/lib" };
   static const char *const X86Triples[] = {
@@ -1113,7 +1114,8 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
     "i386-redhat-linux",
     "i586-suse-linux",
     "i486-slackware-linux",
-    "i686-montavista-linux"
+    "i686-montavista-linux",
+    "i486-alpine-linux-uclibc"
   };
 
   static const char *const MIPSLibDirs[] = { "/lib" };
@@ -1980,6 +1982,7 @@ Tool *Solaris::buildLinker() const {
 /// Distribution (very bare-bones at the moment).
 
 enum Distro {
+  AlpineLinux,
   ArchLinux,
   DebianLenny,
   DebianSqueeze,
@@ -2109,6 +2112,9 @@ static Distro DetectDistro(llvm::Triple::ArchType Arch) {
   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;
 }
 
diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
index aba1fe4..cc8e9c9 100644
--- a/tools/clang/lib/Driver/Tools.cpp
+++ b/tools/clang/lib/Driver/Tools.cpp
@@ -5983,9 +5983,12 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
     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) {
+      if (ToolChain.getTriple().getEnvironment() == llvm::Triple::UClibc)
+        CmdArgs.push_back("/lib/ld-uClibc.so.0.9.32");
+      else
+        CmdArgs.push_back("/lib/ld-linux.so.2");
+    } 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) {
@@ -6009,6 +6012,8 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
     else if (ToolChain.getArch() == llvm::Triple::ppc64 ||
 	     ToolChain.getArch() == llvm::Triple::systemz)
       CmdArgs.push_back("/lib64/ld64.so.1");
+    else if (ToolChain.getTriple().getEnvironment() == llvm::Triple::UClibc)
+      CmdArgs.push_back("/lib/ld64-uClibc.so.0.9.32");
     else
       CmdArgs.push_back("/lib64/ld-linux-x86-64.so.2");
   }