justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Fix `include` #497

Closed amirouche closed 1 year ago

amirouche commented 1 year ago

fix: https://github.com/justinethier/cyclone/issues/494 requires: https://github.com/justinethier/cyclone/pull/496

amirouche commented 1 year ago

Example run:

;; #> ./cyclone -COPT '-Iinclude' -CLNK '-L.' -A . -A ../tmp/ ../tmp/main.scm 
../tmp//foobar/base.c:112:10: fatal error: cyclone/types.h: No such file or directory
  112 | #include "cyclone/types.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
;; #> ../tmp/main 
win
;; #> cat ../tmp/main.scm ../tmp/foobar/base.sld ../tmp/foobar/body.scm 
(import (scheme base))
(import (scheme write))
(import (foobar base))

(display foobar)(newline)
(define-library (foobar base)
  (export foobar)
  (import (scheme base))

  (cond-expand
   (cyclone
    (include "body.scm"))
   (else
    (include "fuuuuu"))))
(define foobar "win")
;; #> 
amirouche commented 1 year ago

Oops! I cleaned up the ../tmp/ directory, and now the c compiler is really angry:

;; #> ./cyclone -COPT '-Iinclude' -CLNK '-L.' -A . -A ../tmp/ ../tmp/main.scm 
../tmp//foobar/base.c:112:10: fatal error: cyclone/types.h: No such file or directory
  112 | #include "cyclone/types.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
/usr/bin/ld: cannot find ../tmp//foobar/base.o: No such file or directory
collect2: error: ld returned 1 exit status
/usr/bin/ld: cannot find .//foobar/base.o: No such file or directory
collect2: error: ld returned 1 exit status
;; #> 
amirouche commented 1 year ago

After make bootstrap, then inside cyclone-bootstrap:

make clean
make 
make install

It works :grimacing:

justinethier commented 1 year ago

Merged - thanks!