diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f010da8..08c46d2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Features Bug Fixes +- Fix a regression where `c-compiler-options` was not recognized as a top level form by programs. - Enforce a maximum recursion depth when printing an object via `display` and `write`, and when comparing objects via `equal?`. This prevents segmentation faults when working with circular data structures. ## 0.34.0 - January 2, 2022 diff --git a/cyclone.scm b/cyclone.scm index c9220735..d0465f39 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -723,7 +723,7 @@ in-prog)) ;; Compile and emit: -(define (run-compiler args append-dirs prepend-dirs) +(define (run-compiler args append-dirs prepend-dirs change-cc-opts!) (let* ((in-file (car args)) (expander (base-expander)) (in-prog-raw (read-file in-file)) @@ -745,6 +745,20 @@ (not (null? (car program:imports/code)))) (lib:get-all-import-deps (car program:imports/code) append-dirs prepend-dirs expander) '())) + ;; Read C compiler options + (cc-opts + (cond + (program? + (let ((opts (program-c-compiler-opts! in-prog))) + (when (not (null? opts)) + (change-cc-opts! opts)) + (string-join ;; Check current program for options + opts + " "))) + (else + (string-join + (lib:c-compiler-options (car in-prog)) + " ")))) ;; Read all linker options from dependent libs (c-linker-options (let ((lib-options (lib:get-all-c-linker-options lib-deps append-dirs prepend-dirs expander))) @@ -1132,13 +1146,18 @@ Debug options: (cond (run-scm-compiler? ;; Compile Scheme code into a C file - (run-compiler non-opts append-dirs prepend-dirs)) + (run-compiler non-opts append-dirs prepend-dirs + (lambda (opts) + (set! cc-opts opts)))) (else ;; Generate the C file (cond (no-compiler-subprocess ;; Special case, we can generate .C file within this process - (run-compiler non-opts append-dirs prepend-dirs)) + (run-compiler non-opts append-dirs prepend-dirs + (lambda (opts) (set! cc-opts opts))) + + ) (else ;; Normal path is to run another instance of cyclone to generate ;; the .C file. This lets us immediately free those resources once