wingo / fibers

Concurrent ML-like concurrency for Guile
GNU Lesser General Public License v3.0
310 stars 32 forks source link

Cross-compilation broken #114

Closed civodul closed 4 hours ago

civodul commented 4 hours ago

Commit 62b2ca641ae256b79be3d6f3240a265ce1484d3e apparently fixed cross-compilation:

mkdir -p fibers
mkdir -p /tmp/guix-build-guile-fibers-git.drv-0/source/override/fibers
mkdir -p /tmp/guix-build-guile-fibers-git.drv-0/source/override/fibers
sed -e "s|@extlibdir\@|/gnu/store/q9gmvwaa25xfdfc9hxbwyify6v9whmhc-guile-fibers-git/lib/guile/3.0/extensions|" \
    ./fibers/config.scm.in > fibers/config.scm
cp -f /tmp/guix-build-guile-fibers-git.drv-0/source/fibers/epoll.scm /tmp/guix-build-guile-fibers-git.drv-0/source/override/fibers/events-impl.scm
cp -f /tmp/guix-build-guile-fibers-git.drv-0/source/fibers/posix-clocks-generic.scm /tmp/guix-build-guile-fibers-git.drv-0/source/override/fibers/posix-clocks.scm
make  all-am

[...]

GUILE_AUTO_COMPILE=0 ./env      \
  /gnu/store/mfkz7fvlfpv3ppwbkv0imb19nrf95akf-guile-3.0.9/bin/guild compile --target=aarch64-linux-gnu -L "/tmp/guix-build-guile-fibers-git.drv-0/source"   \
  -Wunbound-variable -Warity-mismatch -Wformat -o "fibers/io-wakeup.go" "fibers/io-wakeup.scm"
wrote `fibers/counter.go'
GUILE_AUTO_COMPILE=0 ./env      \
  /gnu/store/mfkz7fvlfpv3ppwbkv0imb19nrf95akf-guile-3.0.9/bin/guild compile --target=aarch64-linux-gnu -L "/tmp/guix-build-guile-fibers-git.drv-0/source"   \
  -Wunbound-variable -Warity-mismatch -Wformat -o "fibers/nameset.go" "fibers/nameset.scm"
Backtrace:
In ice-9/psyntax.scm:
   259:10 19 (parse _ (("placeholder" placeholder)) (()) _ c&e (eval) …)
In ice-9/eval.scm:
   293:34 18 (_ #<module (#{ g107}#) 7ffff78291e0>)
In ice-9/boot-9.scm:
   3411:4 17 (define-module* _ #:filename _ #:pure _ #:version _ # _ …)
  3424:24 16 (_)
   222:29 15 (map1 (((srfi srfi-9)) ((srfi srfi-9 gnu)) ((# #)) (#) …))
   222:29 14 (map1 (((srfi srfi-9 gnu)) ((fibers events-impl)) (#) …))
   222:17 13 (map1 (((fibers events-impl)) ((fibers stack)) ((# …)) …))
  3327:17 12 (resolve-interface (fibers events-impl) #:select _ # _ # …)
In ice-9/threads.scm:
    390:8 11 (_ _)
In ice-9/boot-9.scm:
  3253:13 10 (_)
In ice-9/threads.scm:
    390:8  9 (_ _)
In ice-9/boot-9.scm:
  3544:20  8 (_)
   2836:4  7 (save-module-excursion #<procedure 7ffff34d0f30 at ice-…>)
  3564:26  6 (_)
In unknown file:
           5 (primitive-load-path "fibers/events-impl" #<procedure 7…>)
In override/fibers/events-impl.scm:
    41:15  4 (_)
In unknown file:
           3 (dynamic-link "/tmp/guix-build-guile-fibers-git.drv-0/s…")
In system/foreign-library.scm:
   190:25  2 (load-foreign-library _ #:extensions _ # _ #:search-path …)
In unknown file:
           1 (dlopen "/tmp/guix-build-guile-fibers-git.drv-0/source…" …)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure dlopen: file "/tmp/guix-build-guile-fibers-git.drv-0/source/.libs/fibers-epoll.so", message "/tmp/guix-build-guile-fibers-git.drv-0/source/.libs/fibers-epoll.so: cannot open shared object file: No such file or directory"
make[1]: *** [Makefile:1600: fibers/io-wakeup.go] Error 1
make[1]: *** Waiting for unfinished jobs....
wrote `fibers/interrupts.go'
wrote `fibers/deque.go'
wrote `fibers/nameset.go'
make[1]: Leaving directory '/tmp/guix-build-guile-fibers-git.drv-0/source'
make: *** [Makefile:594: all] Error 2

The comment in events-impl.scm reads:

;; When cross-compiling, the cross-compiled 'fibers-libevent.so' cannot be loaded
;; by the 'guild compile' process, so during the compilation of Guile-Fibers
;; this 'fake' fibers/events-impl.scm / fibers/events-impl.go module is loaded,
;; which doesn't link to the library.

However this is not the case since (1) fibers/epoll.scm is copied to override/fibers/events-impl.scm upfront (as can be seen in the log above), and (2) override is added to GUILE_LOAD_PATH in ./env. (Guix carries a patch that removes ./env from the .scm.go command line when cross-compiling, as a workaround.)

My preference would be to go back to the FIBERS_CROSS_COMPILING environment variable trick that was used prior to 62b2ca641ae256b79be3d6f3240a265ce1484d3e (I use the same trick in most projects), but I'm open to other solutions.

Thoughts?

Cc: @emixa-d

civodul commented 4 hours ago

This change was proposed in #77. It seems to me that a simpler solution to the "problem" mentioned in events-impl.scm would have been to set FIBERS_CROSS_COMPILING in Makefile.am instead of setting it in ./env, for instance.

emixa-d commented 4 hours ago

Duplicate of https://github.com/wingo/fibers/issues/111, closing.