From 8febd612d19484e31a89448da7a0483373039fbf Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Fri, 19 Aug 2022 10:16:49 +0200 Subject: [PATCH 1/3] cosmopolitan: unstable-2022-03-22 -> 2.0.1 --- .../libraries/cosmopolitan/default.nix | 22 ++++++++++++++----- .../libraries/cosmopolitan/fix-paths.patch | 12 ++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/libraries/cosmopolitan/fix-paths.patch diff --git a/pkgs/development/libraries/cosmopolitan/default.nix b/pkgs/development/libraries/cosmopolitan/default.nix index f58e654cbfe3..7522fe2ba2ea 100644 --- a/pkgs/development/libraries/cosmopolitan/default.nix +++ b/pkgs/development/libraries/cosmopolitan/default.nix @@ -1,16 +1,21 @@ -{ lib, stdenv, fetchFromGitHub, unzip, bintools-unwrapped }: +{ lib, stdenv, fetchFromGitHub, unzip, bintools-unwrapped, coreutils, substituteAll }: stdenv.mkDerivation rec { pname = "cosmopolitan"; - version = "unstable-2022-03-22"; + version = "2.0.1"; src = fetchFromGitHub { owner = "jart"; - repo = "cosmopolitan"; - rev = "5022f9e9207ff2b79ddd6de6d792d3280e12fb3a"; - sha256 = "sha256-UjL4wR5HhuXiQXg6Orcx2fKiVGRPMJk15P779BP1fRA="; + repo = pname; + rev = version; + sha256 = "sha256-EPye7IRMmYHF7XYdDaJdA8alCLiF7MOkU/fVAzZA794="; }; + patches = [ + # make sure tests set PATH correctly + (substituteAll { src = ./fix-paths.patch; inherit coreutils; }) + ]; + nativeBuildInputs = [ bintools-unwrapped unzip ]; outputs = [ "out" "dist" ]; @@ -24,11 +29,16 @@ stdenv.mkDerivation rec { dontConfigure = true; dontFixup = true; + preCheck = '' + # some syscall tests fail because we're in a sandbox + rm test/libc/calls/sched_setscheduler_test.c + ''; + installPhase = '' runHook preInstall mkdir -p $out/{include,lib} install o/cosmopolitan.h $out/include - install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} $out/lib + install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} o/ape/ape-no-modify-self.o $out/lib cp -RT . "$dist" runHook postInstall diff --git a/pkgs/development/libraries/cosmopolitan/fix-paths.patch b/pkgs/development/libraries/cosmopolitan/fix-paths.patch new file mode 100644 index 000000000000..85c59f3f12a3 --- /dev/null +++ b/pkgs/development/libraries/cosmopolitan/fix-paths.patch @@ -0,0 +1,12 @@ +--- a/test/tool/plinko/plinko_test.c ++++ b/test/tool/plinko/plinko_test.c +@@ -91,8 +91,8 @@ TEST(plinko, worksOrPrintsNiceError) { + sigaction(SIGQUIT, &savequit, 0); + sigaction(SIGPIPE, &savepipe, 0); + sigprocmask(SIG_SETMASK, &savemask, 0); + execve("bin/plinko.com", (char *const[]){"bin/plinko.com", 0}, +- (char *const[]){0}); ++ (char *const[]){"PATH=@coreutils@/bin", 0}); + _exit(127); + } + close(pfds[0][0]); From a7b998a0e36a56b1361a418a468ba4502b7e7c0d Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Fri, 19 Aug 2022 10:24:02 +0200 Subject: [PATCH 2/3] python-cosmopolitan: unbreak --- .../interpreters/python-cosmopolitan/default.nix | 4 ---- .../interpreters/python-cosmopolitan/ioctl.patch | 12 ------------ 2 files changed, 16 deletions(-) delete mode 100644 pkgs/development/interpreters/python-cosmopolitan/ioctl.patch diff --git a/pkgs/development/interpreters/python-cosmopolitan/default.nix b/pkgs/development/interpreters/python-cosmopolitan/default.nix index 14459a24aac2..a2a512b9cdf0 100644 --- a/pkgs/development/interpreters/python-cosmopolitan/default.nix +++ b/pkgs/development/interpreters/python-cosmopolitan/default.nix @@ -6,10 +6,6 @@ stdenv.mkDerivation rec { src = cosmopolitan.dist; - patches = [ - ./ioctl.patch # required /dev/tty - ]; - nativeBuildInputs = [ bintools-unwrapped unzip ]; # slashes are significant because upstream uses o/$(MODE)/foo.o diff --git a/pkgs/development/interpreters/python-cosmopolitan/ioctl.patch b/pkgs/development/interpreters/python-cosmopolitan/ioctl.patch deleted file mode 100644 index e6e7eb4fc7b0..000000000000 --- a/pkgs/development/interpreters/python-cosmopolitan/ioctl.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/third_party/python/python.mk b/third_party/python/python.mk -index f18c15060..b17455bca 100644 ---- a/third_party/python/python.mk -+++ b/third_party/python/python.mk -@@ -1818,7 +1818,6 @@ THIRD_PARTY_PYTHON_PYTEST_PYMAINS = \ - third_party/python/Lib/test/test_int_literal.py \ - third_party/python/Lib/test/test_bisect.py \ - third_party/python/Lib/test/test_pyexpat.py \ -- third_party/python/Lib/test/test_ioctl.py \ - third_party/python/Lib/test/test_getopt.py \ - third_party/python/Lib/test/test_sort.py \ - third_party/python/Lib/test/test_slice.py \ From 37e18a40ac8baed1a56b985859cbfaf2075a7298 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Fri, 19 Aug 2022 11:39:18 +0200 Subject: [PATCH 3/3] cosmoc: update flags --- pkgs/development/tools/cosmoc/default.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/development/tools/cosmoc/default.nix b/pkgs/development/tools/cosmoc/default.nix index f1e80d91df55..e64cf02e9f7e 100644 --- a/pkgs/development/tools/cosmoc/default.nix +++ b/pkgs/development/tools/cosmoc/default.nix @@ -8,18 +8,19 @@ stdenv.mkDerivation { dontUnpack = true; dontBuild = true; + # compiler arguments based on upstream README.md installPhase = '' runHook preInstall mkdir -p $out/bin cat <$out/bin/cosmoc #!${stdenv.shell} exec ${stdenv.cc}/bin/${stdenv.cc.targetPrefix}gcc \ - -O -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \ + -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \ + -fno-omit-frame-pointer -pg -mnop-mcount -mno-tls-direct-seg-refs \ "\$@" \ - -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 \ - -fuse-ld=bfd -Wl,-T,${cosmopolitan}/lib/ape.lds \ + -fuse-ld=bfd -Wl,-T,${cosmopolitan}/lib/ape.lds -Wl,--gc-sections \ -include ${cosmopolitan}/include/cosmopolitan.h \ - ${cosmopolitan}/lib/{crt.o,ape.o,cosmopolitan.a} + ${cosmopolitan}/lib/{crt.o,ape-no-modify-self.o,cosmopolitan.a} EOF chmod +x $out/bin/cosmoc runHook postInstall