Clang: patch to fix linking of shared libraries
This commit is contained in:
parent
2d0ba4b8a0
commit
5a649fc6d4
|
@ -1,5 +1,5 @@
|
||||||
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
|
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
|
||||||
index d02d9744d78..b57a7cb0507 100644
|
index d02d9744d..b57a7cb05 100644
|
||||||
--- a/include/clang/Driver/Options.td
|
--- a/include/clang/Driver/Options.td
|
||||||
+++ b/include/clang/Driver/Options.td
|
+++ b/include/clang/Driver/Options.td
|
||||||
@@ -2452,6 +2452,7 @@ def nolibc : Flag<["-"], "nolibc">;
|
@@ -2452,6 +2452,7 @@ def nolibc : Flag<["-"], "nolibc">;
|
||||||
|
@ -11,7 +11,7 @@ index d02d9744d78..b57a7cb0507 100644
|
||||||
def noseglinkedit : Flag<["-"], "noseglinkedit">;
|
def noseglinkedit : Flag<["-"], "noseglinkedit">;
|
||||||
def nostartfiles : Flag<["-"], "nostartfiles">;
|
def nostartfiles : Flag<["-"], "nostartfiles">;
|
||||||
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
|
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
|
||||||
index 3c139d72479..89d6df3f5b4 100644
|
index 3c139d724..89d6df3f5 100644
|
||||||
--- a/lib/Basic/Targets.cpp
|
--- a/lib/Basic/Targets.cpp
|
||||||
+++ b/lib/Basic/Targets.cpp
|
+++ b/lib/Basic/Targets.cpp
|
||||||
@@ -147,6 +147,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
@@ -147,6 +147,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
||||||
|
@ -42,7 +42,7 @@ index 3c139d72479..89d6df3f5b4 100644
|
||||||
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
||||||
case llvm::Triple::Solaris:
|
case llvm::Triple::Solaris:
|
||||||
diff --git a/lib/Basic/Targets/OSTargets.h b/lib/Basic/Targets/OSTargets.h
|
diff --git a/lib/Basic/Targets/OSTargets.h b/lib/Basic/Targets/OSTargets.h
|
||||||
index 09867d82c38..f67151a13e8 100644
|
index 09867d82c..f67151a13 100644
|
||||||
--- a/lib/Basic/Targets/OSTargets.h
|
--- a/lib/Basic/Targets/OSTargets.h
|
||||||
+++ b/lib/Basic/Targets/OSTargets.h
|
+++ b/lib/Basic/Targets/OSTargets.h
|
||||||
@@ -760,6 +760,26 @@ public:
|
@@ -760,6 +760,26 @@ public:
|
||||||
|
@ -73,7 +73,7 @@ index 09867d82c38..f67151a13e8 100644
|
||||||
template <typename Target>
|
template <typename Target>
|
||||||
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
|
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
|
||||||
diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
|
diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
|
||||||
index 4793a1f90b2..4691b898eb2 100644
|
index 4793a1f90..4691b898e 100644
|
||||||
--- a/lib/Driver/CMakeLists.txt
|
--- a/lib/Driver/CMakeLists.txt
|
||||||
+++ b/lib/Driver/CMakeLists.txt
|
+++ b/lib/Driver/CMakeLists.txt
|
||||||
@@ -44,6 +44,7 @@ add_clang_library(clangDriver
|
@@ -44,6 +44,7 @@ add_clang_library(clangDriver
|
||||||
|
@ -85,7 +85,7 @@ index 4793a1f90b2..4691b898eb2 100644
|
||||||
ToolChains/Haiku.cpp
|
ToolChains/Haiku.cpp
|
||||||
ToolChains/HIP.cpp
|
ToolChains/HIP.cpp
|
||||||
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
|
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
|
||||||
index a784e218f13..881b78abc4d 100644
|
index a784e218f..881b78abc 100644
|
||||||
--- a/lib/Driver/Driver.cpp
|
--- a/lib/Driver/Driver.cpp
|
||||||
+++ b/lib/Driver/Driver.cpp
|
+++ b/lib/Driver/Driver.cpp
|
||||||
@@ -22,6 +22,7 @@
|
@@ -22,6 +22,7 @@
|
||||||
|
@ -107,7 +107,7 @@ index a784e218f13..881b78abc4d 100644
|
||||||
TC = llvm::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
|
TC = llvm::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
|
||||||
break;
|
break;
|
||||||
diff --git a/lib/Driver/SanitizerArgs.cpp b/lib/Driver/SanitizerArgs.cpp
|
diff --git a/lib/Driver/SanitizerArgs.cpp b/lib/Driver/SanitizerArgs.cpp
|
||||||
index 1a46073aaa3..72b6f7389a3 100644
|
index 1a46073aa..72b6f7389 100644
|
||||||
--- a/lib/Driver/SanitizerArgs.cpp
|
--- a/lib/Driver/SanitizerArgs.cpp
|
||||||
+++ b/lib/Driver/SanitizerArgs.cpp
|
+++ b/lib/Driver/SanitizerArgs.cpp
|
||||||
@@ -693,7 +693,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
@@ -693,7 +693,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
||||||
|
@ -121,10 +121,10 @@ index 1a46073aaa3..72b6f7389a3 100644
|
||||||
StringRef S = A->getValue();
|
StringRef S = A->getValue();
|
||||||
diff --git a/lib/Driver/ToolChains/Genode.cpp b/lib/Driver/ToolChains/Genode.cpp
|
diff --git a/lib/Driver/ToolChains/Genode.cpp b/lib/Driver/ToolChains/Genode.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000000..91cb8362a14
|
index 000000000..cf87b10ba
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/Driver/ToolChains/Genode.cpp
|
+++ b/lib/Driver/ToolChains/Genode.cpp
|
||||||
@@ -0,0 +1,138 @@
|
@@ -0,0 +1,145 @@
|
||||||
+//===--- Genode.cpp - Genode ToolChain Implementations ----------*- C++ -*-===//
|
+//===--- Genode.cpp - Genode ToolChain Implementations ----------*- C++ -*-===//
|
||||||
+//
|
+//
|
||||||
+// The LLVM Compiler Infrastructure
|
+// The LLVM Compiler Infrastructure
|
||||||
|
@ -201,9 +201,14 @@ index 00000000000..91cb8362a14
|
||||||
+ if (Args.hasArg(options::OPT_static)) {
|
+ if (Args.hasArg(options::OPT_static)) {
|
||||||
+ CmdArgs.push_back("-Bstatic");
|
+ CmdArgs.push_back("-Bstatic");
|
||||||
+ } else {
|
+ } else {
|
||||||
|
+ if (Args.hasArg(options::OPT_shared)) {
|
||||||
|
+ CmdArgs.push_back(Args.MakeArgString("-shared"));
|
||||||
|
+ CmdArgs.push_back(Args.MakeArgString("-T" + D.SysRoot + "/ld/genode_rel.ld"));
|
||||||
|
+ } else {
|
||||||
+ CmdArgs.push_back(Args.MakeArgString("-T" + D.SysRoot + "/ld/genode_dyn.ld"));
|
+ CmdArgs.push_back(Args.MakeArgString("-T" + D.SysRoot + "/ld/genode_dyn.ld"));
|
||||||
+ CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + D.SysRoot + "/ld/genode_dyn.dl"));
|
+ CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + D.SysRoot + "/ld/genode_dyn.dl"));
|
||||||
+ CmdArgs.push_back("--dynamic-linker=ld.lib.so");
|
+ CmdArgs.push_back("--dynamic-linker=ld.lib.so");
|
||||||
|
+ }
|
||||||
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
||||||
+ CmdArgs.push_back("-l:ld.lib.so");
|
+ CmdArgs.push_back("-l:ld.lib.so");
|
||||||
+ }
|
+ }
|
||||||
|
@ -220,8 +225,10 @@ index 00000000000..91cb8362a14
|
||||||
+
|
+
|
||||||
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_noposix)) {
|
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_noposix)) {
|
||||||
+ CmdArgs.push_back("-lc");
|
+ CmdArgs.push_back("-lc");
|
||||||
|
+ if (!Args.hasArg(options::OPT_shared)) {
|
||||||
+ CmdArgs.push_back("-lposix");
|
+ CmdArgs.push_back("-lposix");
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
|
+ const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
|
||||||
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
|
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
|
||||||
|
@ -265,7 +272,7 @@ index 00000000000..91cb8362a14
|
||||||
+}
|
+}
|
||||||
diff --git a/lib/Driver/ToolChains/Genode.h b/lib/Driver/ToolChains/Genode.h
|
diff --git a/lib/Driver/ToolChains/Genode.h b/lib/Driver/ToolChains/Genode.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000000..144f4f99abe
|
index 000000000..144f4f99a
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/lib/Driver/ToolChains/Genode.h
|
+++ b/lib/Driver/ToolChains/Genode.h
|
||||||
@@ -0,0 +1,69 @@
|
@@ -0,0 +1,69 @@
|
||||||
|
@ -339,7 +346,7 @@ index 00000000000..144f4f99abe
|
||||||
+
|
+
|
||||||
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
|
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
|
||||||
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
|
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
|
||||||
index 67842b5dca2..26a2c65fec2 100644
|
index 67842b5dc..26a2c65fe 100644
|
||||||
--- a/lib/Frontend/InitHeaderSearch.cpp
|
--- a/lib/Frontend/InitHeaderSearch.cpp
|
||||||
+++ b/lib/Frontend/InitHeaderSearch.cpp
|
+++ b/lib/Frontend/InitHeaderSearch.cpp
|
||||||
@@ -221,6 +221,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
|
@@ -221,6 +221,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
|
||||||
|
@ -360,7 +367,7 @@ index 67842b5dca2..26a2c65fec2 100644
|
||||||
// <isysroot> gets prepended later in AddPath().
|
// <isysroot> gets prepended later in AddPath().
|
||||||
diff --git a/test/Driver/genode.c b/test/Driver/genode.c
|
diff --git a/test/Driver/genode.c b/test/Driver/genode.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000000..e69de29bb2d
|
index 000000000..e69de29bb
|
||||||
diff --git a/test/Driver/genode.cpp b/test/Driver/genode.cpp
|
diff --git a/test/Driver/genode.cpp b/test/Driver/genode.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000000..e69de29bb2d
|
index 000000000..e69de29bb
|
||||||
|
|
Loading…
Reference in New Issue
Block a user