Subject: Re: bug#66046: Relative includes in R7RS define-library seem broken

From: Maxim Cournoyer <[email-masked]>
Date: Sat, 18 Nov 2023 17:56:48 -0500

Hello,

I've just found a cross-compilation buggy interaction with my fix:

--8<---------------cut here---------------start------------->8---
$ touch ./module/srfi/srfi-151.scm 
maxim@hurd ~/src/guile [env]$ touch ./module/srfi/srfi-160/base.sld 
maxim@hurd ~/src/guile [env]$ m
make  all-recursive
make[1]: Entering directory '/home/maxim/src/guile'
Making all in lib
make[2]: Entering directory '/home/maxim/src/guile/lib'
make  all-recursive
make[3]: Entering directory '/home/maxim/src/guile/lib'
make[4]: Entering directory '/home/maxim/src/guile/lib'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/home/maxim/src/guile/lib'
make[3]: Leaving directory '/home/maxim/src/guile/lib'
make[2]: Leaving directory '/home/maxim/src/guile/lib'
Making all in meta
make[2]: Entering directory '/home/maxim/src/guile/meta'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/maxim/src/guile/meta'
Making all in libguile
make[2]: Entering directory '/home/maxim/src/guile/libguile'
make  all-am
make[3]: Entering directory '/home/maxim/src/guile/libguile'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/maxim/src/guile/libguile'
make[2]: Leaving directory '/home/maxim/src/guile/libguile'
Making all in module
make[2]: Entering directory '/home/maxim/src/guile/module'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/maxim/src/guile/module'
Making all in stage0
make[2]: Entering directory '/home/maxim/src/guile/stage0'
  BOOTSTRAP(stage0) GUILEC srfi/srfi-151.go
  BOOTSTRAP(stage0) GUILEC srfi/srfi-160/base.go
;;; note: source file /home/maxim/src/guile/module/srfi/srfi-151.scm
;;;       newer than compiled /home/maxim/src/guile/stage0/srfi/srfi-151.go
;;; note: source file /home/maxim/src/guile/module/srfi/srfi-151.scm
;;;       newer than compiled /home/maxim/src/guile/cache/guile/ccache/3.0-LE-8-4.6/home/maxim/src/guile/module/srfi/srfi-151.scm.go
Backtrace:
In ice-9/r6rs-libraries.scm:
   113:17 19 (_ #<syntax:base.sld:5:16 (#<syntax:base.sld:5:17 srfi?> ?)
In ice-9/boot-9.scm:
  3355:17 18 (resolve-interface (srfi srfi-151) #:select _ #:hide _ # ?)
In ice-9/threads.scm:
    397:8 17 (_ #<procedure 7f94a9df2a00 at ice-9/boot-9.scm:3269:7 ?>)
In ice-9/boot-9.scm:
  3281:13 16 (_)
In ice-9/threads.scm:
    397:8 15 (_ #<procedure 7f94a9d7a180 at ice-9/boot-9.scm:3565:5 ?>)
In ice-9/boot-9.scm:
  3572:20 14 (_)
   2864:4 13 (save-module-excursion #<procedure 7f94a6d85b10 at ice-?>)
  3592:26 12 (_)
In unknown file:
          11 (primitive-load-path "srfi/srfi-151" #<procedure 7f94a9?>)
In ice-9/eval.scm:
   721:20 10 (primitive-eval (define-library (srfi srfi-151) (# #) ?))
wrote `srfi/srfi-151.go'
In ice-9/psyntax.scm:
  1229:36  9 (expand-top-sequence (#<syntax:srfi-151.scm:23:0 (def?>) ?)
  1123:16  8 (lp (#<syntax:srfi-151.scm:23:0 (define-library #<syn?>) ?)
  1123:16  7 (lp (#<syntax:srfi-151.scm:23:0 (#<syntax:r6rs-libr?> ?) ?)
  1123:16  6 (lp (#<syntax:srfi-151.scm:23:0 (#<syntax:r7rs-librar?>) ?)
  1121:20  5 (lp (#<syntax:srfi-151.scm:23:0 (#<syntax:base.scm:30?>) ?)
  1342:32  4 (syntax-type (#<syntax:base.scm:301:10 include> #<sy?>) ?)
  1562:32  3 (expand-macro #<procedure 7f94a9c0ed98 at ice-9/psynta?> ?)
  3278:16  2 (_ #<syntax:srfi-151.scm:54:11 "srfi-151/bitwise-33.sc?> ?)
In unknown file:
           1 (open-file "../module/srfi/srfi-160/srfi-151/bitwise-3?" ?)
In ice-9/boot-9.scm:
  1682:22  0 (lp 0)

ice-9/boot-9.scm:1682:22: In procedure lp:
In procedure open-file: No such file or directory: "../module/srfi/srfi-160/srfi-151/bitwise-33.scm"
make[2]: *** [Makefile:2562: srfi/srfi-160/base.go] Error 1
make[2]: Leaving directory '/home/maxim/src/guile/stage0'
make[1]: *** [Makefile:2203: all-recursive] Error 1
make[1]: Leaving directory '/home/maxim/src/guile'
make: *** [Makefile:2088 : all] Erreur 2
--8<---------------cut here---------------end--------------->8---

I'll try to come up with a test case, then a fix.

-- 
Thanks,
Maxim