From 75615fac16a134375cd482ad73aa81bbcfb2e4d9 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 8 May 2020 01:01:29 +0530 Subject: [PATCH] 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. --- overlay/llvm-8/clang/genode.patch | 21 +++++++++++++++++++-- packages/block_router/default.nix | 4 ++-- packages/nic_bus/default.nix | 4 ++-- packages/sotest-producer/default.nix | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/overlay/llvm-8/clang/genode.patch b/overlay/llvm-8/clang/genode.patch index 1b5b76f..140ec68 100644 --- a/overlay/llvm-8/clang/genode.patch +++ b/overlay/llvm-8/clang/genode.patch @@ -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; ++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 index 3c139d72479..89d6df3f5b4 100644 --- a/lib/Basic/Targets.cpp @@ -109,10 +121,10 @@ index 1a46073aaa3..72b6f7389a3 100644 StringRef S = A->getValue(); diff --git a/lib/Driver/ToolChains/Genode.cpp b/lib/Driver/ToolChains/Genode.cpp new file mode 100644 -index 00000000000..9103ce2a5ee +index 00000000000..91cb8362a14 --- /dev/null +++ b/lib/Driver/ToolChains/Genode.cpp -@@ -0,0 +1,133 @@ +@@ -0,0 +1,138 @@ +//===--- Genode.cpp - Genode ToolChain Implementations ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure @@ -206,6 +218,11 @@ index 00000000000..9103ce2a5ee + + 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()); + C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); +} diff --git a/packages/block_router/default.nix b/packages/block_router/default.nix index 540e204..816d453 100644 --- a/packages/block_router/default.nix +++ b/packages/block_router/default.nix @@ -10,8 +10,8 @@ stdenv.mkDerivation rec { src = fetchgit { url = "https://git.sr.ht/~ehmry/block_router"; - rev = "v" + version; - sha256 = "0vw3s4q3rp5dp1i93sq0cybfssh3gbqgyqg6k69781pjda7mzn54"; + rev = "d229379abd16d6b19872b83772da81a2473f18ae"; + sha256 = "1wrz7r72psnxfaaj2gjp5zxy8h4k8ahbyjp8y70ghr9rm1hsdhj4"; }; installPhase = "install -Dm755 {.,$out}/block_router"; diff --git a/packages/nic_bus/default.nix b/packages/nic_bus/default.nix index 5b5d653..88217ee 100644 --- a/packages/nic_bus/default.nix +++ b/packages/nic_bus/default.nix @@ -7,8 +7,8 @@ stdenv.mkDerivation rec { src = fetchgit { url = "https://git.sr.ht/~ehmry/nic_bus"; - rev = "v" + version; - sha256 = "DrgZHkUEjkHmSfOqSetGqU/nLl8OqNM0zaJjOout5VY="; + rev = "e4e7c5f4af7d6129f64afb019045c40508a619ee"; + sha256 = "0hxzdkl1w47gha395bx8ykv8ic62chs75ccyyqq841pwghqxscj4"; }; nativeBuildInputs = [ tup ]; diff --git a/packages/sotest-producer/default.nix b/packages/sotest-producer/default.nix index 61f4999..0028c07 100644 --- a/packages/sotest-producer/default.nix +++ b/packages/sotest-producer/default.nix @@ -10,8 +10,8 @@ stdenv.mkDerivation rec { src = fetchgit { url = "https://git.sr.ht/~ehmry/genode-sotest-producer"; - rev = "v" + version; - sha256 = "01qy86khkihj8jgvgc92w4bb3kpf640g1l2m5h5ym7s03viqinkr"; + rev = "eed74df5977b01809893efaa84e7ad6d207423d2"; + sha256 = "1cf08jk2y6advlk9hczzklc220195fj3ybjvd16y8v1sfpfg84lx"; }; installPhase = "install -Dm755 {.,$out/bin}/sotest-harness";