fix(std regex): skip native backend probe when JERBOA_STATIC=1
ober
7711edb9559835df5026358ad510b44ccf6faa0d
--- a/lib/std/regex.ss +++ b/lib/std/regex.ss @@ -63,20 +63,29 @@ ;; 1. libjerboa_native.so / .dylib (LD_LIBRARY_PATH / DYLD_LIBRARY_PATH) ;; 2. lib/libjerboa_native.so / .dylib (relative to CWD) ;; 3. $JERBOA_HOME/lib/libjerboa_native.so / .dylib (absolute, set by Makefile) + ;; + ;; JERBOA_STATIC=1 (set by static-binary wrappers in jerboa-virus' + ;; build-virus-cross.ss and build-virus-freebsd-cross.ss) short-circuits + ;; the lookup. Those builds patch load-shared-object to a no-op so every + ;; (try ...) below would otherwise spuriously succeed, while + ;; libjerboa_native is NOT linked into the static binary — resolving + ;; foreign symbols would then fail at module-init time with + ;; "no entry for jerboa_regex_compile". (def native-available? - (let ([try (lambda (path) - (try (begin (load-shared-object path) #t) - (catch (exn) #f)))] - [home (or (getenv "JERBOA_HOME") "")]) - (or (try "libjerboa_native.so") - (try "libjerboa_native.dylib") - (try "lib/libjerboa_native.so") - (try "lib/libjerboa_native.dylib") - (and (not (string=? home "")) - (or (try (string-append home "/lib/libjerboa_native.so")) - (try (string-append home "/lib/libjerboa_native.dylib")))) - #f))) + (and (not (getenv "JERBOA_STATIC")) + (let ([try (lambda (path) + (try (begin (load-shared-object path) #t) + (catch (exn) #f)))] + [home (or (getenv "JERBOA_HOME") "")]) + (or (try "libjerboa_native.so") + (try "libjerboa_native.dylib") + (try "lib/libjerboa_native.so") + (try "lib/libjerboa_native.dylib") + (and (not (string=? home "")) + (or (try (string-append home "/lib/libjerboa_native.so")) + (try (string-append home "/lib/libjerboa_native.dylib")))) + #f)))) ;; Foreign procedures — defined conditionally. ;; (foreign-procedure ...) is evaluated eagerly in compiled/WPO code on both