Skip to content

Commit

Permalink
compiler/driver: a couple of small fixes (#760)
Browse files Browse the repository at this point in the history
- fix the order or decls in static exe compilation; gx-gambc0 ended
  ignoring prelude declarations
- add a timestamp to modules with runtime code; this is useful for
  testing for the presence of code in static binaries.
  • Loading branch information
vyzo authored Aug 17, 2023
1 parent d108e62 commit f1a1970
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/gerbil/compiler/driver.ss
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ namespace: gxc
(let ((mod-main (find-runtime-symbol ctx 'main))
(reset-decl (reset-declare))
(user-decl (user-declare)))
(write '(##namespace (""))) (newline)
(write '(declare (optimize-dead-definitions))) (newline)
(for-each
(lambda (dep)
(write `(include ,dep))
(newline)
(write '(##namespace ("")))
(newline)
(write reset-decl)
(newline)
(when user-decl
(write user-decl))
(write user-decl)
(newline))
(write `(include ,dep))
(newline))
deps)
(write `(apply ,mod-main (cdr (command-line))))
Expand Down Expand Up @@ -411,6 +411,11 @@ namespace: gxc

(generate-loader-code ctx code rt)))

(def (context-timestamp ctx)
(string->symbol
(string-append (symbol->string (expander-context-id ctx))
"::timestamp")))

(def (generate-runtime-code ctx code)
(let* ((lifts (box []))
(runtime-code
Expand All @@ -424,6 +429,9 @@ namespace: gxc
(if (null? (unbox lifts))
runtime-code
['begin (reverse (unbox lifts)) ... runtime-code]))
(runtime-code
['begin `(define ,(context-timestamp ctx) ,(current-compile-timestamp))
runtime-code])
(scm0 (compile-output-file ctx 0 ".scm")))
(if (current-compile-static)
(let (scms (compile-static-output-file ctx))
Expand Down

0 comments on commit f1a1970

Please sign in to comment.