Resolve optional libc entries at runtime, not boot load
A literal (foreign-procedure "chmod" ...) in compiled code becomes a fasl relocation resolved when the boot loads — on Windows (no chmod/sigemptyset/ sigaddset in the CRT) that killed joltc.exe before any guard could run (msvcrt abort, exit 3). jolt-foreign-proc-safe defers the lookup through eval at evaluation time, where the guard works and a missing entry just yields the fallback. chmod also skips the /bin/sh fallback on nt (execute is by extension).
This commit is contained in:
parent
225073a11b
commit
af12f77dcd
4 changed files with 26 additions and 12 deletions
|
|
@ -80,13 +80,18 @@
|
|||
;; every Chez binary) — no external toolchain. Falls back to /bin/sh chmod if the
|
||||
;; symbol can't be resolved.
|
||||
(define jolt-chmod-755
|
||||
(let ((c (guard (e (#t #f))
|
||||
(load-shared-object #f)
|
||||
(foreign-procedure "chmod" (string int) int))))
|
||||
(let ((c (jolt-foreign-proc-safe "chmod" '(string int) 'int)))
|
||||
(lambda (path)
|
||||
(if c
|
||||
(c path #o755)
|
||||
(system (string-append "chmod 755 '" path "'"))))))
|
||||
(cond
|
||||
(c (c path #o755))
|
||||
;; Windows has no chmod and needs none (execute is by extension)
|
||||
((let ((m (symbol->string (machine-type))))
|
||||
(let loop ((i 0))
|
||||
(cond ((> (+ i 2) (string-length m)) #f)
|
||||
((string=? (substring m i (+ i 2)) "nt") #t)
|
||||
(else (loop (+ i 1))))))
|
||||
0)
|
||||
(else (system (string-append "chmod 755 '" path "'")))))))
|
||||
|
||||
;; A user-facing relative path resolves against JOLT_PWD — the user's cwd before
|
||||
;; the launcher cd'd to the jolt repo root — matching the JVM, where io/file is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue