From 1edfe6d91bd8348cfccacd72e82d1d06ad470117 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Tue, 22 Mar 2022 05:21:47 -0400 Subject: [PATCH] cosmopolitan: 0.3 -> unstable-2022-03-22 --- .../libraries/cosmopolitan/default.nix | 64 ++++++++++--------- .../libraries/cosmopolitan/ioctl.patch | 12 ++++ 2 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 pkgs/development/libraries/cosmopolitan/ioctl.patch diff --git a/pkgs/development/libraries/cosmopolitan/default.nix b/pkgs/development/libraries/cosmopolitan/default.nix index 629e5465a044..ca303fdeaea3 100644 --- a/pkgs/development/libraries/cosmopolitan/default.nix +++ b/pkgs/development/libraries/cosmopolitan/default.nix @@ -1,68 +1,70 @@ -{ lib, gcc9Stdenv, fetchFromGitHub, runCommand, cosmopolitan }: +{ lib, stdenv, fetchFromGitHub, runCommand, unzip, cosmopolitan,bintools-unwrapped }: -gcc9Stdenv.mkDerivation rec { +stdenv.mkDerivation rec { pname = "cosmopolitan"; - version = "0.3"; + version = "unstable-2022-03-22"; src = fetchFromGitHub { owner = "jart"; repo = "cosmopolitan"; - rev = version; - sha256 = "sha256-OVdOObO82W6JN63OWKHaERS7y0uvgxt+WLp6Y0LsmJk="; + rev = "5022f9e9207ff2b79ddd6de6d792d3280e12fb3a"; + sha256 = "sha256-UjL4wR5HhuXiQXg6Orcx2fKiVGRPMJk15P779BP1fRA="; }; + patches = [ + ./ioctl.patch # required /dev/tty + ]; + postPatch = '' patchShebangs build/ - rm -r third_party/gcc ''; dontConfigure = true; dontFixup = true; enableParallelBuilding = true; - - preBuild = '' - makeFlagsArray=( - SHELL=/bin/sh - AS=${gcc9Stdenv.cc.targetPrefix}as - CC=${gcc9Stdenv.cc.targetPrefix}gcc - GCC=${gcc9Stdenv.cc.targetPrefix}gcc - CXX=${gcc9Stdenv.cc.targetPrefix}g++ - LD=${gcc9Stdenv.cc.targetPrefix}ld - OBJCOPY=${gcc9Stdenv.cc.targetPrefix}objcopy - "MKDIR=mkdir -p" - ) - ''; + nativeBuildInputs = [ bintools-unwrapped unzip ]; installPhase = '' runHook preInstall - mkdir -p $out/{bin,lib/include} - install o/cosmopolitan.h $out/lib/include + mkdir -p $out/{bin,include,lib} + install o/cosmopolitan.h $out/include install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} $out/lib + cat > $out/bin/cosmoc <hello.c - ${gcc9Stdenv.cc}/bin/gcc -g -O -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone -o hello.com.dbg hello.c \ + printf '#include "libc/stdio/stdio.h"\nmain() { printf("hello world\\n"); }\n' >hello.c + ${stdenv.cc}/bin/gcc -g -O -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone -o hello.com.dbg hello.c \ -fuse-ld=bfd -Wl,-T,${cosmopolitan}/lib/ape.lds \ - -include ${cosmopolitan}/lib/{include/cosmopolitan.h,crt.o,ape.o,cosmopolitan.a} - ${gcc9Stdenv.cc.bintools.bintools_bin}/bin/objcopy -S -O binary hello.com.dbg hello.com + -include ${cosmopolitan}/include/cosmopolitan.h \ + -I ${cosmopolitan}/include \ + ${cosmopolitan}/lib/{crt.o,ape.o,cosmopolitan.a} + ${stdenv.cc.bintools.bintools_bin}/bin/objcopy -S -O binary hello.com.dbg hello.com ./hello.com printf "test successful" > $out ''; cosmoc = runCommand "cosmoc-hello" { } '' - printf 'main() { printf("hello world\\n"); }\n' >hello.c + printf '#include "libc/stdio/stdio.h"\nmain() { printf("hello world\\n"); }\n' >hello.c ${cosmopolitan}/bin/cosmoc hello.c ./a.out printf "test successful" > $out diff --git a/pkgs/development/libraries/cosmopolitan/ioctl.patch b/pkgs/development/libraries/cosmopolitan/ioctl.patch new file mode 100644 index 000000000000..e6e7eb4fc7b0 --- /dev/null +++ b/pkgs/development/libraries/cosmopolitan/ioctl.patch @@ -0,0 +1,12 @@ +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 \