Hello,
No worries at all for the delay. I've been looking over csm for the past
few days myself and I managed to fix it up enough to work on both my
Windows and OpenBSD machines. Below I've attached a patch in case it
helps you in your efforts to fix the bug. I haven't tested it enough to
claim that it works on all machines for all use cases, but it works
perfectly fine for mine.
The solutions are taken from the csc source nearly verbatim--especially
the change for it to use 'process-run' rather than 'system' as is the
case in csc. This fixed the shell syntax issues for me. The rest of the
changes are to make it use the Windows-specific file extensions for the
outputs on Windows. The biggest disadvantage to my approach is that it
doesn't support cross compilation, which is not a problem for me, but
certainly could be for others.
Thanks again for the response,
Quinn
On 8/26/2026 4:33 AM, Felix Winkelmann wrote:
> On Sat Aug 22, 2026 at 11:59 PM CEST, Quinn Van De Keere via Chicken-users
> wrote:
>> Hi all,
>>
>> I'm trying to compile a simple project via CSM consisting of just one
>> .scm file (for now) and it refuses to work on Windows.
>
> Hi! Sorry for the long delay. The problem here is Windows' shell syntax
> (again), I think. I still haven't found a proper solution for this,
> but in the meantime you could at least try to go on using the "-g"
> option to csm, which will create a makefile. This seems to work for me
> so far. I pushed a new version of csm (0.93, available any time now)
> that drops windows-specific slashification, which should at least
> produce a makefile the w64devkit can run.
>
>
> cheers,
> felix
>
Index: csm.scm
===================================================================
--- csm.scm (revision 46092)
+++ csm.scm (working copy)
@@ -120,6 +120,17 @@
(normalize-pathname
(make-pathname default-bindir (foreign-value "C_CSI_PROGRAM"
c-string))))))
+(cond-expand
+ (windows
+ (define object-extension "obj")
+ (define load-library-extension "dll")
+ (define executable-extension "exe"))
+ (else
+ (define object-extension "o")
+ (define load-library-extension "so")
+ (define executable-extension "")))
+(define static-object-extension (string-append "static." object-extension))
+
(define (read-source fname prefix r7rs)
(fluid-let ((*mod* #f)
(*functor-params* '())
@@ -511,7 +522,7 @@
(printf "# GENERATED BY csm ~a\n\n.SUFFIXES:\n.PHONY: all clean\n\nall:
~a\n"
version
(join (map (lambda (m) (program-info-name m)) programs)))
- (print "\nclean:\n\trm -f *.import.scm *.so")
+ (printf "\nclean:\n\trm -f *.import.scm *.~a" load-library-extension)
(for-each
(lambda (prg)
(let* ((main (program-info-main prg))
@@ -550,7 +561,7 @@
csc
(build-cmd (module-build-options m)))
(when compile-import-libs
- (printf "\n~a.import.so: ~a.import.scm\n" name name)
+ (printf "\n~a.import.~a: ~a.import.scm\n" name
load-library-extension name)
(printf "\t~a ~a\n"
csc
(build-cmd (module-import-build-options m)))))))
@@ -573,8 +584,10 @@
(printf "# GENERATED BY csm\n\n.SUFFIXES:\n.PHONY: all clean\n\nall:
~a\n"
(join
(map (lambda (m) (program-info-name m)) programs)))
- (printf "\nclean:\n\trm -f ~a *.import.scm *.o *.so\n"
- (join (map program-info-name programs)))
+ (printf "\nclean:\n\trm -f ~a *.import.scm *.~a *.~a\n"
+ (join (map program-info-name programs))
+ object-extension
+ load-library-extension)
(for-each
(lambda (prg)
(let* ((main (program-info-main prg))
@@ -612,8 +625,9 @@
csc
(build-cmd (module-build-options m)))
(when compile-import-libs
- (printf "\n~a.import.so: ~a ~a.import.scm\n"
+ (printf "\n~a.import.~a: ~a ~a.import.scm\n"
name
+ load-library-extension
(target-name m)
name)
(printf "\t~a ~a\n"
@@ -639,7 +653,7 @@
deps))
(define (c-object-name cm)
- (string-append (pathname-file (c-module-info-filename cm)) ".o"))
+ (make-pathname #f (pathname-file (c-module-info-filename cm))
object-extension))
(define (find-module name)
(find (lambda (m) (string=? name (module-info-name m))) modules))
@@ -664,7 +678,7 @@
(odeps (module-info-option-dependencies mm))
(pdeps (program-info-dependencies prg))
(podeps (program-info-option-dependencies prg))
- (ideps (map (cut string-append <> ".o") (program-imports main)))
+ (ideps (map (cut make-pathname #f <> object-extension)
(program-imports main)))
(options '()))
(explain "checking program ~a" name)
(when (check-rebuild name (append deps odeps ideps podeps pdeps))
@@ -686,7 +700,7 @@
(deps (cons src (c-module-info-dependencies m)))
(odeps (c-module-info-option-dependencies m))
(options (c-module-info-options m))
- (target (string-append (pathname-file src) ".o")))
+ (target (make-pathname #f (pathname-file src) object-extension)))
(explain "checking C module ~a" target)
(dribble " ~a -> ~a" target (join deps))
(when (or (and (not (file-exists? target))
@@ -776,7 +790,7 @@
(compile mo)
(when compile-import-libs
(let* ((implib (string-append name ".import.scm"))
- (implibc (string-append name ".import.so")))
+ (implibc (string-append name ".import." load-library-extension)))
(when (or (not (file-exists? implibc))
(> (file-modification-time implib)
(file-modification-time implibc)))
@@ -832,7 +846,7 @@
(push! "-c++" options))
(if *static*
`(-c "-I" ,root "-C" "-I" "-C" ,root
- ,src -o ,(string-append (pathname-file src) ".o")
+ ,src -o ,(make-pathname #f (pathname-file src) object-extension)
,@options)
`(-c -s "-I" ,root "-C" "-I" "-C" ,root
,src -o ,(c-object-name m) ,@options))))
@@ -840,7 +854,7 @@
(define (module-import-build-options m)
(let* ((name (module-info-name m))
(implib (string-append name ".import.scm"))
- (implibc (string-append name ".import.so")))
+ (implibc (string-append name ".import." load-library-extension)))
`(-s -O3 -d0 ,implib -o ,implibc)))
(define (program-build-options prg)
@@ -848,7 +862,7 @@
(main (program-info-main prg))
(pdeps (program-info-dependencies prg))
(mm (find-module main)))
- `(-o ,name
+ `(-o ,(make-pathname #f name executable-extension)
"-I" ,root "-C" "-I" "-C" ,root
,@(if *static* '(-static) '())
,@(filter-map
@@ -880,17 +894,20 @@
(define (target-name m)
(if (or (static-module? m) (module-info-program-dependency m))
- (string-append (module-info-name m) ".static.o")
- (string-append (module-info-name m) ".so")))
+ (make-pathname #f (module-info-name m) static-object-extension)
+ (make-pathname #f (module-info-name m) load-library-extension)))
(define (qss x) (qs (->string x)))
(define (compile args)
- (let ((cmd (build-cmd (cons csc args))))
- (print " " cmd)
+ (let ((cmdline (string-intersperse (map qss (cons csc args)) " ")))
+ (print cmdline)
(unless dry-run
- (unless (zero? (system cmd))
- (fail "command failed with non-zero exit status: ~a" cmd)))))
+ (let*-values (((pid) (process-run csc (map ->string args)))
+ ((pid success? exit-code) (process-wait pid)))
+ (when (or (not success?) (not (zero? exit-code)))
+ (printf "\nError: shell command terminated with non-zero exit status
~S: ~A~%" exit-code cmdline)
+ (exit exit-code))))))
(define (clean-files)
(let ((files '()))
@@ -899,18 +916,18 @@
(let ((name (module-info-name m)))
(push! (target-name m) files)
(push! (string-append name ".import.scm") files)
- (push! (string-append name ".import.so") files)
+ (push! (string-append name ".import." load-library-extension) files)
(push! (string-append name ".link") files)))
modules)
(for-each
(lambda (m)
(let ((name (c-module-info-filename m)))
- (push! (string-append (pathname-file name) ".o") files)))
+ (push! (make-pathname #f (pathname-file name) object-extension)
files)))
c-modules)
(for-each
(lambda (prg)
(let ((name (program-info-name prg)))
- (push! (program-info-name prg) files)
+ (push! (make-pathname #f (program-info-name prg)
executable-extension) files)
(when *static* (push! (string-append name ".link") files))))
programs)
(let ((xfiles (directory ".")))
@@ -932,8 +949,9 @@
modules)
(for-each
(lambda (m)
- (printf "~a.o: ~a ~a\n"
+ (printf "~a.~a: ~a ~a\n"
(pathname-file (c-module-info-filename m))
+ object-extension
(join (c-module-info-dependencies m))
(join (c-module-info-option-dependencies m))))
c-modules)