This patch adds the `-E` flag to racket version 7.9. This change has been added upstream[1] as a restult of github issue 3717[2].
[1]: https://github.com/racket/racket/commit/fac84630825fdb3780fcd7891fb50e637eb3f910 [2]: https://github.com/racket/racket/issues/3717 --- .../patches/patch-racket_exec_flag | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 lang/racket-minimal/patches/patch-racket_exec_flag diff --git lang/racket-minimal/patches/patch-racket_exec_flag lang/racket-minimal/patches/patch-racket_exec_flag new file mode 100644 index 00000000000..f010c3f82f9 --- /dev/null +++ lang/racket-minimal/patches/patch-racket_exec_flag @@ -0,0 +1,193 @@ +diff --git src/bc/cmdline.inc src/bc/cmdline.inc +index 8632a10479..b08b4e5a24 100644 +--- src/bc/cmdline.inc ++++ src/bc/cmdline.inc +@@ -768,6 +768,8 @@ static int run_from_cmd_line(int argc, char *_argv[], + argv[0] = "-m"; + else if (!strcmp("--name", argv[0])) + argv[0] = "-N"; ++ else if (!strcmp("--exec", argv[0])) ++ argv[0] = "-E"; + else if (!strcmp("--no-compiled", argv[0])) + argv[0] = "-c"; + else if (!strcmp("--no-lib", argv[0])) +@@ -1017,6 +1019,7 @@ static int run_from_cmd_line(int argc, char *_argv[], + eval_kind[num_enl++] = mzcmd_EMBEDDED; + break; + case 'N': ++ case 'E': + if (argc < 2) { + PRINTF("%s: missing name after %s switch\n", + prog, +@@ -1025,13 +1028,16 @@ static int run_from_cmd_line(int argc, char *_argv[], + } + argv++; + --argc; +- sprog = argv[0]; +- if (!*sprog) { ++ if (!*(argv[0])) { + PRINTF("%s: empty path after %s switch\n", + prog, + real_switch); + goto show_need_help; + } ++ if (*str == 'N') ++ sprog = argv[0]; ++ else ++ prog = argv[0]; + was_config_flag = 1; + break; + case 'q': +@@ -1439,6 +1445,7 @@ static int run_from_cmd_line(int argc, char *_argv[], + " -R <paths>, --compiled <paths> : Set compiled-file search roots to <paths>\n" + " -C, --cross : Cross-build mode; save current collects and config as host\n" + " -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to <file>\n" ++ " -E <file>, --exec <file> : Sets `(find-system-path 'exec-file)' to <file>\n" + # ifdef CMDLINE_STDIO_FLAG + " -J <name>, ---wm-class <name> : Set WM_CLASS class to <name> (Unix)\n" + # endif +diff --git src/cs/c/main.c src/cs/c/main.c +index fcca0dcf0d..de5e564c91 100644 +--- src/cs/c/main.c ++++ src/cs/c/main.c +@@ -172,7 +172,7 @@ static char *get_self_path(char *exec_file) + # undef USE_GENERIC_GET_SELF_PATH + #endif + +-#if defined(__FreeBSD__) ++#if defined(__FreeBSD__) || defined(__NetBSD__) + # include <sys/sysctl.h> + # include <errno.h> + static char *get_self_path(char *exec_file) +@@ -183,9 +183,15 @@ static char *get_self_path(char *exec_file) + int r; + + mib[0] = CTL_KERN; ++#if defined(__NetBSD__) ++ mib[1] = KERN_PROC_ARGS; ++ mib[2] = getpid(); ++ mib[3] = KERN_PROC_PATHNAME; ++#else + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; ++#endif + + r = sysctl(mib, 4, NULL, &len, NULL, 0); + if (r < 0) { +diff --git src/cs/main.sps src/cs/main.sps +index d4f75b1104..8230fef269 100644 +--- src/cs/main.sps ++++ src/cs/main.sps +@@ -277,8 +277,8 @@ + [else + (values (car args) (append (reverse accum) (cdr args)))]))) + +- (define (check-path-arg what flag within-flag) +- (when (equal? what "") ++ (define (check-path-arg path what flag within-flag) ++ (when (equal? path "") + (error 'racket "empty ~a after ~a switch" what (or within-flag flag)))) + + (define (raise-bad-switch arg within-arg) +@@ -363,6 +363,7 @@ + (let-values ([(file-name rest-args) (next-arg "file name" arg within-arg args)]) + (add-namespace-require-load! `(file ,file-name) file-name) + (no-init! saw) ++ (check-path-arg file-name "file name" arg within-arg) + (set-run-file! (string->path file-name)) + (flags-loop (cons "--" rest-args) (see saw 'non-config 'lib)))] + [("-f" "--load") +@@ -374,6 +375,7 @@ + (let-values ([(file-name rest-args) (next-arg "file name" arg within-arg args)]) + (set! loads (cons (lambda () (load file-name)) + loads)) ++ (check-path-arg file-name "file name" arg within-arg) + (set-run-file! (string->path file-name)) + (flags-loop (cons "--" rest-args) (see saw 'non-config)))] + [("-e" "--eval") +@@ -458,18 +460,18 @@ + (cond + [(equal? collects-path "") + (set! init-collects-dir 'disable)] +- [else +- (check-path-arg "collects path" arg within-arg) ++ [else ++ (check-path-arg collects-path "collects path" arg within-arg) + (set! init-collects-dir (path->complete-path (->path (find-original-bytes collects-path))))]) + (loop rest-args))] + [("-S" "--search") + (let-values ([(collects-path rest-args) (next-arg "path" arg within-arg args)]) +- (check-path-arg "collects path" collects-path within-arg) ++ (check-path-arg collects-path "collects path" collects-path within-arg) + (set! rev-collects-post-extra (cons (->path (find-original-bytes collects-path)) rev-collects-post-extra)) + (loop rest-args))] + [("-G" "--config") + (let-values ([(config-path rest-args) (next-arg "config path" arg within-arg args)]) +- (check-path-arg "config path" config-path within-arg) ++ (check-path-arg config-path "config path" config-path within-arg) + (set! init-config-dir (path->complete-path (->path (find-original-bytes config-path)))) + (loop rest-args))] + [("-C" "--cross") +@@ -506,8 +508,14 @@ + (loop rest-args))] + [("-N" "--name") + (let-values ([(name rest-args) (next-arg "name" arg within-arg args)]) ++ (check-path-arg name "name" arg within-arg) + (set-run-file! (string->path name)) + (loop rest-args))] ++ [("-E" "--exec") ++ (let-values ([(name rest-args) (next-arg "name" arg within-arg args)]) ++ (check-path-arg name "name" arg within-arg) ++ (set-exec-file! (string->path name)) ++ (loop rest-args))] + [("-J") + (cond + [gracket? +diff --git src/cs/main/help.ss src/cs/main/help.ss +index 5faceffa30..20c3101c92 100644 +--- src/cs/main/help.ss ++++ src/cs/main/help.ss +@@ -51,7 +51,8 @@ + " -U, --no-user-path : Ignore user-specific collects, etc.\n" + " -R <paths>, --compiled <paths> : Set compiled-file search roots to <paths>\n" + " -C, --cross : Cross-build mode; save current collects and config as host\n" +- " -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to <file>\n")) ++ " -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to <file>\n" ++ " -E <file>, --exec <file> : Sets `(find-system-path 'exec-file)' to <file>\n")) + (when gracket? + (#%printf + " -J <name>, ---wm-class <name> : Set WM_CLASS class to <name> (Unix)\n")) +diff --git src/start/ustart.c src/start/ustart.c +index 24c480bf4b..07c2aa363f 100644 +--- src/start/ustart.c ++++ src/start/ustart.c +@@ -456,7 +456,7 @@ int main(int argc, char **argv) + } + + data = (char *)malloc(end - prog_end); +- new_argv = (char **)malloc((count + argc + (2 * collcount) + 10) * sizeof(char*)); ++ new_argv = (char **)malloc((count + argc + (2 * collcount) + 12) * sizeof(char*)); + + fd = open(me, O_RDONLY, 0); + lseek(fd, prog_end, SEEK_SET); +@@ -495,11 +495,18 @@ int main(int argc, char **argv) + putenv(dll_path); + } + +- new_argv[0] = me; ++ new_argv[0] = exe_path; + + argpos = 1; + inpos = 1; + ++ /* Add -E flag; we can't just put `me` in `argv[0]`, because some ++ OSes (well, just OpenBSD) cannot find the executable path of a ++ process, and the actual executable may be needed to find embedded ++ boot images. */ ++ new_argv[argpos++] = "-E"; ++ new_argv[argpos++] = me; ++ + /* Keep all X11 flags to the front: */ + if (x11) { + int n; -- 2.30.1
