Clang: patch to link with -lc and -lposix

Link with the libc and posix entrypoint library unless the -noposix flag
is passed. This allows the Genode Clang to be dropped into legacy build
systems.

Update the native packages using the Clang stdenv to pass -noposix.
This commit is contained in:
Ehmry - 2020-05-08 01:01:29 +05:30
parent bdcc22d5be
commit 75615fac16
4 changed files with 25 additions and 8 deletions

View File

@ -1,3 +1,15 @@
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index d02d9744d78..b57a7cb0507 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -2452,6 +2452,7 @@ def nolibc : Flag<["-"], "nolibc">;
def nomultidefs : Flag<["-"], "nomultidefs">;
def nopie : Flag<["-"], "nopie">;
def no_pie : Flag<["-"], "no-pie">, Alias<nopie>;
+def noposix : Flag<["-"], "noposix">;
def noprebind : Flag<["-"], "noprebind">;
def noseglinkedit : Flag<["-"], "noseglinkedit">;
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 3c139d72479..89d6df3f5b4 100644
--- a/lib/Basic/Targets.cpp --- a/lib/Basic/Targets.cpp
@ -109,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..9103ce2a5ee index 00000000000..91cb8362a14
--- /dev/null --- /dev/null
+++ b/lib/Driver/ToolChains/Genode.cpp +++ b/lib/Driver/ToolChains/Genode.cpp
@@ -0,0 +1,133 @@ @@ -0,0 +1,138 @@
+//===--- Genode.cpp - Genode ToolChain Implementations ----------*- C++ -*-===// +//===--- Genode.cpp - Genode ToolChain Implementations ----------*- C++ -*-===//
+// +//
+// The LLVM Compiler Infrastructure +// The LLVM Compiler Infrastructure
@ -206,6 +218,11 @@ index 00000000000..9103ce2a5ee
+ +
+ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); + AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
+ +
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_noposix)) {
+ CmdArgs.push_back("-lc");
+ 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));
+} +}

View File

@ -10,8 +10,8 @@ stdenv.mkDerivation rec {
src = fetchgit { src = fetchgit {
url = "https://git.sr.ht/~ehmry/block_router"; url = "https://git.sr.ht/~ehmry/block_router";
rev = "v" + version; rev = "d229379abd16d6b19872b83772da81a2473f18ae";
sha256 = "0vw3s4q3rp5dp1i93sq0cybfssh3gbqgyqg6k69781pjda7mzn54"; sha256 = "1wrz7r72psnxfaaj2gjp5zxy8h4k8ahbyjp8y70ghr9rm1hsdhj4";
}; };
installPhase = "install -Dm755 {.,$out}/block_router"; installPhase = "install -Dm755 {.,$out}/block_router";

View File

@ -7,8 +7,8 @@ stdenv.mkDerivation rec {
src = fetchgit { src = fetchgit {
url = "https://git.sr.ht/~ehmry/nic_bus"; url = "https://git.sr.ht/~ehmry/nic_bus";
rev = "v" + version; rev = "e4e7c5f4af7d6129f64afb019045c40508a619ee";
sha256 = "DrgZHkUEjkHmSfOqSetGqU/nLl8OqNM0zaJjOout5VY="; sha256 = "0hxzdkl1w47gha395bx8ykv8ic62chs75ccyyqq841pwghqxscj4";
}; };
nativeBuildInputs = [ tup ]; nativeBuildInputs = [ tup ];

View File

@ -10,8 +10,8 @@ stdenv.mkDerivation rec {
src = fetchgit { src = fetchgit {
url = "https://git.sr.ht/~ehmry/genode-sotest-producer"; url = "https://git.sr.ht/~ehmry/genode-sotest-producer";
rev = "v" + version; rev = "eed74df5977b01809893efaa84e7ad6d207423d2";
sha256 = "01qy86khkihj8jgvgc92w4bb3kpf640g1l2m5h5ym7s03viqinkr"; sha256 = "1cf08jk2y6advlk9hczzklc220195fj3ybjvd16y8v1sfpfg84lx";
}; };
installPhase = "install -Dm755 {.,$out/bin}/sotest-harness"; installPhase = "install -Dm755 {.,$out/bin}/sotest-harness";