minimal-bootstrap.gnumake: init at 4.4.1

+325
+2
pkgs/os-specific/linux/minimal-bootstrap/default.nix
··· 24 25 gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; }; 26 27 })
··· 24 25 gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; }; 26 27 + gnumake = callPackage ./gnumake { tinycc = tinycc-mes; }; 28 + 29 })
+35
pkgs/os-specific/linux/minimal-bootstrap/gnumake/0001-No-impure-bin-sh.patch
···
··· 1 + From e00a5257a6ca5fedbf68b09eee7df3502971a057 Mon Sep 17 00:00:00 2001 2 + From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io> 3 + Date: Sat, 24 Apr 2021 10:11:40 +0200 4 + Subject: [PATCH 1/2] No impure bin sh 5 + 6 + default_shell is used to populuate default shell used to execute jobs. 7 + Unless SHELL is set to a different value this would be /bin/sh. 8 + Our stdenv provides sh in form of bash anyway. Having this value not 9 + hard-coded has some advantages: 10 + 11 + - It would ensure that on all systems it uses sh from its PATH rather 12 + than /bin/sh, which helps as different systems might have different 13 + shells there (bash vs. dash) 14 + - In the past I had issues with LD_PRELOAD with BEAR, where /bin/sh 15 + used a different glibc than BEAR which came from my development shell. 16 + --- 17 + src/job.c | 2 +- 18 + 1 file changed, 1 insertion(+), 1 deletion(-) 19 + 20 + diff --git a/src/job.c b/src/job.c 21 + index ae1f18b..6b4ddb3 100644 22 + --- a/src/job.c 23 + +++ b/src/job.c 24 + @@ -77,7 +77,7 @@ char * vms_strsignal (int status); 25 + 26 + #else 27 + 28 + -const char *default_shell = "/bin/sh"; 29 + +const char *default_shell = "sh"; 30 + int batch_mode_shell = 0; 31 + 32 + #endif 33 + -- 34 + 2.31.1 35 +
+40
pkgs/os-specific/linux/minimal-bootstrap/gnumake/0002-remove-impure-dirs.patch
···
··· 1 + From 795d63d3c8b5c0dbb7e544954f75507b371b7228 Mon Sep 17 00:00:00 2001 2 + From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io> 3 + Date: Sat, 24 Apr 2021 10:20:16 +0200 4 + Subject: [PATCH 2/2] remove impure dirs 5 + 6 + --- 7 + src/read.c | 3 --- 8 + src/remake.c | 2 -- 9 + 2 files changed, 5 deletions(-) 10 + 11 + diff --git a/src/read.c b/src/read.c 12 + index fa197fb..defacfb 100644 13 + --- a/src/read.c 14 + +++ b/src/read.c 15 + @@ -109,9 +109,6 @@ static const char *default_include_directories[] = 16 + #endif 17 + INCLUDEDIR, 18 + #ifndef _AMIGA 19 + - "/usr/gnu/include", 20 + - "/usr/local/include", 21 + - "/usr/include", 22 + #endif 23 + 0 24 + }; 25 + diff --git a/src/remake.c b/src/remake.c 26 + index fb237c5..94bff7d 100644 27 + --- a/src/remake.c 28 + +++ b/src/remake.c 29 + @@ -1601,8 +1601,6 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) 30 + static const char *dirs[] = 31 + { 32 + #ifndef _AMIGA 33 + - "/lib", 34 + - "/usr/lib", 35 + #endif 36 + #if defined(WINDOWS32) && !defined(LIBDIR) 37 + /* 38 + -- 39 + 2.31.1 40 +
+58
pkgs/os-specific/linux/minimal-bootstrap/gnumake/0003-tinycc-support.patch
···
··· 1 + diff --git a/src/dir.c b/src/dir.c 2 + index 3e94b98..cfaa6a2 100644 3 + --- a/src/dir.c 4 + +++ b/src/dir.c 5 + @@ -1331,10 +1331,9 @@ local_stat (const char *path, struct stat *buf) 6 + 7 + /* Similarly for lstat. */ 8 + #if !defined(lstat) && !defined(WINDOWS32) || defined(VMS) 9 + -# ifndef VMS 10 + -# ifndef HAVE_SYS_STAT_H 11 + +// mes-libc implements but does not declare lstat 12 + +# if (!defined(VMS) && !defined(HAVE_SYS_STAT_H)) || defined(__TINYC__) 13 + int lstat (const char *path, struct stat *sbuf); 14 + -# endif 15 + # else 16 + /* We are done with the fake lstat. Go back to the real lstat */ 17 + # ifdef lstat 18 + diff --git a/src/job.c b/src/job.c 19 + index ea88561..8388a82 100644 20 + --- a/src/job.c 21 + +++ b/src/job.c 22 + @@ -2052,7 +2052,8 @@ job_next_command (struct child *child) 23 + static int 24 + load_too_high (void) 25 + { 26 + -#if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__) 27 + +// mes-libc does not support getloadavg 28 + +#if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__) || defined (__TINYC__) 29 + return 1; 30 + #else 31 + static double last_sec; 32 + diff --git a/src/main.c b/src/main.c 33 + index a9d3a64..664d40f 100644 34 + --- a/src/main.c 35 + +++ b/src/main.c 36 + @@ -2770,7 +2770,7 @@ main (int argc, char **argv, char **envp) 37 + char *b = alloca (40); 38 + sprintf (b, "MAKE_RESTARTS=%s%u", 39 + OUTPUT_IS_TRACED () ? "-" : "", restarts); 40 + - putenv (b); 41 + + // mes-libc does not support putenv 42 + } 43 + 44 + fflush (stdout); 45 + diff --git a/src/misc.c b/src/misc.c 46 + index eb14f40..bffca82 100644 47 + --- a/src/misc.c 48 + +++ b/src/misc.c 49 + @@ -653,7 +653,8 @@ get_tmppath () 50 + 51 + # ifdef HAVE_MKTEMP 52 + path = get_tmptemplate (); 53 + - if (*mktemp (path) == '\0') 54 + + // tinycc: "src/misc.c:656: error: pointer expected" 55 + + if (!strcmp(mktemp (path), "")) 56 + { 57 + OSS (error, NILF, 58 + _("cannot generate temp path from %s: %s"), path, strerror (errno));
+190
pkgs/os-specific/linux/minimal-bootstrap/gnumake/default.nix
···
··· 1 + { lib 2 + , runCommand 3 + , fetchurl 4 + , tinycc 5 + , gnupatch 6 + }: 7 + let 8 + pname = "gnumake"; 9 + version = "4.4.1"; 10 + 11 + src = fetchurl { 12 + url = "mirror://gnu/make/make-${version}.tar.gz"; 13 + sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx"; 14 + }; 15 + 16 + patches = [ 17 + # Replaces /bin/sh with sh, see patch file for reasoning 18 + ./0001-No-impure-bin-sh.patch 19 + # Purity: don't look for library dependencies (of the form `-lfoo') in /lib 20 + # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for 21 + # included Makefiles, don't look in /usr/include and friends. 22 + ./0002-remove-impure-dirs.patch 23 + # Fixes for tinycc. See comments in patch file for reasoning 24 + ./0003-tinycc-support.patch 25 + ]; 26 + 27 + CFLAGS = [ 28 + "-I./src" 29 + "-I./lib" 30 + "-DHAVE_CONFIG_H" 31 + "-DMAKE_MAINTAINER_MODE" 32 + "-DLIBDIR=\\\"${placeholder "out"}/lib\\\"" 33 + "-DLOCALEDIR=\\\"/fake-locale\\\"" 34 + "-DPOSIX=1" 35 + # mes-libc doesn't implement osync_* methods 36 + "-DNO_OUTPUT_SYNC=1" 37 + # mes-libc doesn't define O_TMPFILE 38 + "-DO_TMPFILE=020000000" 39 + ] ++ config; 40 + 41 + /* 42 + Maintenance notes: 43 + 44 + Generated by 45 + ./configure \ 46 + --build i686-pc-linux-gnu \ 47 + --host i686-pc-linux-gnu \ 48 + CC="${tinycc-mes}/bin/tcc -static" \ 49 + ac_cv_func_dup=no 50 + - `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile() 51 + 52 + The output src/config.h was then manually filtered, removing definitions that 53 + didn't have uses in the source code 54 + */ 55 + config = [ 56 + "-DFILE_TIMESTAMP_HI_RES=0" 57 + "-DHAVE_ALLOCA" 58 + "-DHAVE_ALLOCA_H" 59 + "-DHAVE_ATEXIT" 60 + "-DHAVE_DECL_BSD_SIGNAL=0" 61 + "-DHAVE_DECL_GETLOADAVG=0" 62 + "-DHAVE_DECL_SYS_SIGLIST=0" 63 + "-DHAVE_DECL__SYS_SIGLIST=0" 64 + "-DHAVE_DECL___SYS_SIGLIST=0" 65 + "-DHAVE_DIRENT_H" 66 + "-DHAVE_DUP2" 67 + "-DHAVE_FCNTL_H" 68 + "-DHAVE_FDOPEN" 69 + "-DHAVE_GETCWD" 70 + "-DHAVE_GETTIMEOFDAY" 71 + "-DHAVE_INTTYPES_H" 72 + "-DHAVE_ISATTY" 73 + "-DHAVE_LIMITS_H" 74 + "-DHAVE_LOCALE_H" 75 + "-DHAVE_MEMORY_H" 76 + "-DHAVE_MKTEMP" 77 + "-DHAVE_SA_RESTART" 78 + "-DHAVE_SETVBUF" 79 + "-DHAVE_SIGACTION" 80 + "-DHAVE_SIGSETMASK" 81 + "-DHAVE_STDINT_H" 82 + "-DHAVE_STDLIB_H" 83 + "-DHAVE_STRDUP" 84 + "-DHAVE_STRERROR" 85 + "-DHAVE_STRINGS_H" 86 + "-DHAVE_STRING_H" 87 + "-DHAVE_STRTOLL" 88 + "-DHAVE_SYS_FILE_H" 89 + "-DHAVE_SYS_PARAM_H" 90 + "-DHAVE_SYS_RESOURCE_H" 91 + "-DHAVE_SYS_SELECT_H" 92 + "-DHAVE_SYS_STAT_H" 93 + "-DHAVE_SYS_TIMEB_H" 94 + "-DHAVE_SYS_TIME_H" 95 + "-DHAVE_SYS_WAIT_H" 96 + "-DHAVE_TTYNAME" 97 + "-DHAVE_UMASK" 98 + "-DHAVE_UNISTD_H" 99 + "-DHAVE_WAITPID" 100 + "-DMAKE_JOBSERVER" 101 + "-DMAKE_SYMLINKS" 102 + "-DPATH_SEPARATOR_CHAR=':'" 103 + "-DSCCS_GET=\\\"get\\\"" 104 + "-DSTDC_HEADERS" 105 + "-Dsig_atomic_t=int" 106 + "-Dvfork=fork" 107 + ]; 108 + 109 + # Maintenance note: list of source files derived from Basic.mk 110 + make_SOURCES = [ 111 + "src/ar.c" 112 + "src/arscan.c" 113 + "src/commands.c" 114 + "src/default.c" 115 + "src/dir.c" 116 + "src/expand.c" 117 + "src/file.c" 118 + "src/function.c" 119 + "src/getopt.c" 120 + "src/getopt1.c" 121 + "src/guile.c" 122 + "src/hash.c" 123 + "src/implicit.c" 124 + "src/job.c" 125 + "src/load.c" 126 + "src/loadapi.c" 127 + "src/main.c" 128 + "src/misc.c" 129 + "src/output.c" 130 + "src/read.c" 131 + "src/remake.c" 132 + "src/rule.c" 133 + "src/shuffle.c" 134 + "src/signame.c" 135 + "src/strcache.c" 136 + "src/variable.c" 137 + "src/version.c" 138 + "src/vpath.c" 139 + ]; 140 + glob_SOURCES = [ "lib/fnmatch.c" "lib/glob.c" ]; 141 + remote_SOURCES = [ "src/remote-stub.c" ]; 142 + sources = make_SOURCES ++ glob_SOURCES ++ remote_SOURCES ++ [ 143 + "src/posixos.c" 144 + ]; 145 + 146 + objects = map (x: lib.replaceStrings [".c"] [".o"] (builtins.baseNameOf x)) sources; 147 + in 148 + runCommand "${pname}-${version}" { 149 + inherit pname version; 150 + 151 + nativeBuildInputs = [ tinycc gnupatch ]; 152 + 153 + meta = with lib; { 154 + description = "A tool to control the generation of non-source files from sources"; 155 + homepage = "https://www.gnu.org/software/make"; 156 + license = licenses.gpl3Plus; 157 + maintainers = with maintainers; [ emilytrau ]; 158 + mainProgram = "make"; 159 + platforms = platforms.unix; 160 + }; 161 + } '' 162 + # Unpack 163 + ungz --file ${src} --output make.tar 164 + untar --file make.tar 165 + rm make.tar 166 + cd make-${version} 167 + 168 + # Patch 169 + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} 170 + 171 + # Configure 172 + catm src/config.h src/mkconfig.h src/mkcustom.h 173 + cp lib/glob.in.h lib/glob.h 174 + cp lib/fnmatch.in.h lib/fnmatch.h 175 + 176 + # Compile 177 + alias CC="tcc ${lib.concatStringsSep " " CFLAGS}" 178 + ${lib.concatMapStringsSep "\n" (f: "CC -c ${f}") sources} 179 + 180 + # Link 181 + CC -static -o make ${lib.concatStringsSep " " objects} 182 + 183 + # Check 184 + ./make --version 185 + 186 + # Install 187 + mkdir -p ''${out}/bin 188 + cp ./make ''${out}/bin 189 + chmod 555 ''${out}/bin/make 190 + ''