From dc5e4bcc054c2990817cc130a6fe0f33c7bf7a48 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:26:42 +0100 Subject: [PATCH] sbcl: ADR of a string constant's byte, so it compiles src/ A string's bytes have an address, as a ^U8 made from the string does; a typed constant's parts still don't. Built by sbcl/raz, the raz compiler passes conform/ and makes the same bytes as the native one. --- diff --git a/sbcl/README.md b/sbcl/README.md index d04b43f..286d761 100644 --- a/sbcl/README.md +++ b/sbcl/README.md @@ -123,6 +123,11 @@ ## Beyond conform/ +It compiles the raz compiler, `src/` (with `-I build/src` for its +`Version`), in about 4 seconds. That compiler, run on SBCL, passes +`conform/`, and makes executables byte for byte the same as the native +one's, its own included. + Of the reference compiler's own tests, `test/run` and `examples/`, all pass whose expected output this target can give: the rest are x86 code procedures (`Asm`, `Atomic`, `Edge`, `Results`, `Simd`, `Single`, diff --git a/sbcl/src/expr.lisp b/sbcl/src/expr.lisp index 45b512c..73b54a5 100644 --- a/sbcl/src/expr.lisp +++ b/sbcl/src/expr.lisp @@ -612,7 +612,7 @@ (when (is ty :string) ;; a string constant is indexed and sliced as an array of U8 (setf ty (make-array-type (ty-len ty) (basic "U8")) - item (make-item :mode :var :type ty :form (string-address (item-val item)) :ro :const :tok tk))) + item (make-item :mode :var :type ty :form (string-address (item-val item)) :ro :string :tok tk))) (unless (member (ty-kind ty) '(:array :slice :ptr)) (fail-tok tk "~a can't be indexed" (type-name ty))) (when (and (is ty :ptr) (is (ptr-base ty) :array)) @@ -755,6 +755,7 @@ (case (item-ro a) (:export (fail-tok tk "another module's variable can't be ~a" what)) (:const (fail-tok tk "a constant can't be ~a" what)) + (:string (fail-tok tk "a string's bytes can't be ~a" what)) (:value (fail-tok tk "a part of a value can't be ~a" what)))) (defun vararg-form (a) @@ -893,7 +894,8 @@ (arity args 1) (let ((x (arg 0))) (unless (eq (item-mode x) :var) (fail-tok tk "ADR takes a variable")) - (check-writable x tk "given to ADR") + ;; a string's bytes have an address, as a ^U8 made from it does (5.10) + (unless (eq (item-ro x) :string) (check-writable x tk "given to ADR")) (when (item-noaddr x) (fail-tok tk "a field of a packed record has no address")) (val-item (make-ptr-type (item-type x) (item-vol x)) (item-form x) tk))) ((string= name "LEN")