Commit graph

9065 commits

Author SHA1 Message Date
Daniel Kochmański
944d5ef3b1 Merge branch 'cmp-base-string-coercion' into 'develop'
Fix incorrect coercion of base strings to extended strings during compilation

See merge request embeddable-common-lisp/ecl!363
2026-02-23 10:26:10 +00:00
Daniel Kochmański
1b97477d6b cross-compilation: add instructions and configs for mingw 2026-02-16 13:22:31 +01:00
Marius Gerbershagen
08dae53ebc remove unused function declaration 2026-02-14 21:33:29 +01:00
Marius Gerbershagen
d4994b33f0 cmp: fix incorrect coercion of base strings to extended strings
The compiler was coercing base strings to extended strings when
encountering them as literal objects in compiled files. According to
CLHS 3.2.4.2.2, we need to preserve the actual element type (after
upgrading) of arrays during compilation. For ECL, the actual array
element type of a base-string is base-char and therefore we can't
change this to an extended string.

Actually fixing this requires some work since we use the reader to
store a printed representation of the string in the compiled file. The
reader string syntax always returns an extended string (There is a
comment in the code which claims that this is implied by CLHS 2.4.5. I
am not quite sure if that is really true but for backwards
compatibility I don't want to change this). We thus introduce a new
syntax #"..." for base strings which is used when reading objects from
compiled files. To prevent the new syntax from leaking outside of this
context, we also introduce a new readtable.
2026-02-14 20:36:49 +01:00
Marius Gerbershagen
3842c579d4 read.d: replace dead link in comment by explanation in words
The contents of the message can still be found on the internet archive
by browsing http://sourceforge.net/p/ecls/mailman/.
2026-02-14 19:06:36 +01:00
Marius Gerbershagen
44b439135a cmp: fix some compile time type checks
We can't pass compound function types (i.e. function types which
include argument and return types) to TYPEP. At some places, this was
already handled but not everywhere. A new function CMP-TYPEP is
introduced to handle this. At any place where a user-supplied type is
checked at compile time, we need to use CMP-TYPEP instead of TYPEP.
2026-02-13 19:39:20 +01:00
Marius Gerbershagen
93aa909c84 cmp: don't emit style-warnings for dead code elimination
Dead code eliminiation often happens for automatically generated code,
so this leads to many false positives for code that doesn't have any
style issues.

Moreover, the combination of compiler-note and style-warning is
handled badly by asdf. By default, we don't display compiler-notes but
asdf catches style-warnings to display a notice that a style-warning
has been emitted which is confusing since no warning has been printed.
2026-02-13 19:00:48 +01:00
Marius Gerbershagen
33aa5a3941 fix bug in finalizer implementation
We need to save and restore the reference to the current function in
the environment before calling any finalizers. Otherwise, it can
happen that this is overwritten after we have set it but before
actually calling the function. This can lead to all sorts of issues
because closure environments are wrong or variadic dispatch doesn't
work correctly.

The bug appeared intermittently when compiling maxima from a version
of ECL compiled with CFLAGS="-DECL_C_COMPATIBLE_VARIADIC_DISPATCH" and
--disable-threads.
2026-01-31 20:25:49 +01:00
Daniel Kochmański
9cf33d51bb serialize: fix typos introduced in bignum serialization 2026-01-19 10:02:19 +01:00
Daniel Kochmański
c329fc12da Merge branch 'fix-804' into 'develop'
Fix #804

Closes #804

See merge request embeddable-common-lisp/ecl!361
2026-01-09 19:19:21 +00:00
Marius Gerbershagen
3a591d1588 fix build with --with-bytecmp=builtin and --with-cmp=no
Installing autoloads for the Lisp to C compiler can't work since there
is no Lisp to C compiler in this configuration.
2026-01-03 14:20:42 +01:00
Marius Gerbershagen
411723aa95 cmp: fix inline expansion for ABS function 2025-12-13 19:51:53 +01:00
Marius Gerbershagen
cae32c08bc cmp: fix inline expansions for EXPT function
Floating point contagion rules and the special case (expt 0 0) were
not handled correctly.
2025-12-13 19:51:53 +01:00
Marius Gerbershagen
c6488fa1c1 cmp: fix type propagator for EXPT
There were a number of bugs here:
- REAL was returned even for complex exponents
- The special case of exponent=0 wasn't handled correctly
- In some cases, EXPT could return integer or rational results but the
  type propagator would always assume that coercion to floating point
  was happening.
2025-12-13 19:51:53 +01:00
Marius Gerbershagen
f1091f4cd6 expt: fix floating point contagion
Examples of the bug

(expt -1.4d0 #C(1 2)) -> #C(-0.0020444484 -0.0016295447)
(expt #C(1.0 3.0) 0.0d0) -> #C(1.0 0.0)

These return a (complex single-float), should be (complex double-float).

The code incorrectly assumed that the numbers associated to the types
tx and ty were ordered such that long floats and complex long floats
have higher numbers than double floats and complex double floats.
2025-12-12 23:02:31 +01:00
Marius Gerbershagen
95566d1380 config-internal.h.in: add missing parameter definition for configure script
Fixes #803.

Bug introduced in commit d51ce511f6
2025-12-12 19:52:49 +01:00
Marius Gerbershagen
855f93431b Merge branch 'fix-799' into 'develop'
Fix :variables command in top-level env

Closes #799

See merge request embeddable-common-lisp/ecl!359
2025-11-30 14:52:28 +00:00
Daniel Kochmański
9f9c9a8037 cmp: assign _ecl_debug_env to lcl_env (not lex_env) 2025-11-29 22:22:41 +01:00
Daniel Kochmański
dfb691ede8 top: add captured records to the local environment
We include captured functions, blocks and variables along with local
variables. This fixes #799.

Moreover DECODE-IHS-ENV is deperacated and more DWIM:
- calls DECODE-IHS-LOCALS for old arguments
- appends DECODE-IHS-LOCALS and DECODE-IHS-LEXENV for ihs index

DECODE-IHS-LOCALS and DECODE-IHS-LEXENV are responsible for decoding appropriate
environments.
2025-11-28 13:13:04 +01:00
Daniel Kochmański
e6ae6146a4 ihs/swank: make si_ihs_env return the local environment (not lexical)
We deprecate the function si_ihs_env in favor of more explicit si_ihs_lex and
si_ihs_lcl, but the former is left for backward compatibility with SLIME/SLYNK
because they call it to query the environment to add locals to the backtrace.
2025-11-28 11:57:09 +01:00
Daniel Kochmański
8a5007fd4a top: separate correctly lexenv from lclenv in break environment
Fixes #799.
2025-11-28 11:57:09 +01:00
Daniel Kochmański
ed5471169e ihs: store locals and lexical environment in separate slots
Since ~recently we store local variables in the bytevm on the stack.  Also, the
native comipler under specified debug options, stores locals in ihs, but it has
nothing to do with the lexical environment. So it feels justified to push both
to a separate field.
2025-11-28 11:57:09 +01:00
Daniel Kochmański
3c4c1639c5 proclamations: fix an invalid proclamation for SI:IHS-ENV
It may seem like this proclamation is invalid sincd !346, but the divergence
happens much earlier. 8c0314022c introduces a
feature where c-compiled code can also add debug information, and in that case
the environment is a vector, so the proclamation back then should be:

  (proclamation si:ihs-env (si::index) (or list vector))

Later when we've changed the representation, it should be changed to

  (proclamation si:ihs-env (si::index) (or null vector))

Where NULL denotes "no lexical environment".
2025-11-28 11:57:09 +01:00
Daniel Kochmański
34afd9a6d3 compile-file: allow :LOAD T :SYSTEM-P T when cross-compiling
We don't need to load the compilation artifact, so there is no reason to error.
2025-11-24 14:47:53 +01:00
Daniel Kochmański
e09f0d9742 cmpdefs: fix builds for CC [dlopen host -> no-dlopen target]
(DEFCONFIG *LD-SHARED-FLAGS*) was called without a value when dlopen was not
defined, that lead to error when destructuring. We put there "" instead now.
2025-11-24 10:58:15 +01:00
Marius Gerbershagen
2279b78514 cmp: fix typos 2025-11-23 17:45:10 +01:00
Daniel Kochmański
7933468deb Merge branch 'cross-compilation' into 'develop'
Cross-compilation of user code

See merge request embeddable-common-lisp/ecl!358
2025-11-22 20:39:50 +00:00
Marius Gerbershagen
4734509f15 cmp: allow cross compiling to/from targets without shared library support 2025-11-22 16:25:42 +01:00
Marius Gerbershagen
0baa1290e6 cmp: fix constant folding for target dependent constants
Register these constants as symbol macros in the lexical environment.
Maybe not the cleanest solution, but it works.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
7a1bd96eb7 cmp: make sure COMPILE works during cross compilation
Previously, calling COMPILE during cross compilation always failed due
to trying to load a shared object compiled for the wrong architecture.
We now temporarily switch back to the host configuration, compile and
load our shared object, and then go on with the target config.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
7932ffb1be fix cross compilation to a Windows target
Cross compilation of ECL itself:

- The windres program comes with the usual cross compilation target
  prefixes, use AC_CHECK_TOOL to select the right one.
- For c::update-compiler-features, we need to check the features of the
  host system instead of the target because that determines the
  executable prefix of the ecl_min stub.

Cross compilation of user code: We just have to replace some read time
conditionals by runtime checks.

Further notes on Windows cross compilation using mingw:

- Our old copy of libgmp doesn't work, one needs to update that before
  compiling.
- ASDF fails to compile unless XDG_CACHE_HOME is set (it tries and
  fails to find a Windows cache directory if XDG_CACHE_HOME is empty).
- The `windres` program may be located in a separate package from the
  mingw compiler. On debian, I had to install binutils-mingw-w64 and
  gcc-mingw-w64.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
9365e7abe7 loop macro: fix expansion for cross compilation targets
Check for types in the target environment.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
4271c7594d cmp: handle subtypep for cross compilation with mismatching complex float features
This is a bit tricky to solve since UPGRADED-COMPLEX-PART-TYPE and
SUBTYPEP behave differently depending on whether we have complex float
support or not and the behaviour is a special case compared to other
types due to the upgrading of part types that is happening.

What we do now is to add a custom declaration in the environment and
select the behaviour based on a runtime check.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
f099a9082a cmp: move proclamations from system-properties into a compiler specific storage
This allows us to switch out the proclamations when cross-compiling so
that target specific functions are declared correctly.

This was a problem for cross compilation with mismatching thread
support, so we can now allow that.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
c5f6cd0246 cmp: change handling of *cmp-env-root*
Due to the recent introduction of cross compilation features,
*cmp-env* has to contain type information throughout the entire
compilation (not only while we are compiling a form) so that (typep x
type *cmp-env*) works correctly. Therefore, we can't set *cmp-env* to
nil initially as we did previously. Instead, we set *cmp-env*
to *cmp-env-root* initially.
2025-11-22 16:25:42 +01:00
Marius Gerbershagen
79d33bdd83 cmp: fix typo 2025-11-22 16:25:42 +01:00
Marius Gerbershagen
872622bd0c doc: document the cross compilation feature 2025-11-22 16:25:42 +01:00
Marius Gerbershagen
e30c37691b tests: implement tests for cross compilation of user code
We start a remote ECL host and replace COMPILE-FILE and COMPILE by a
stub which shells out compile commands to this remote ECL. Moreover, a
few commands defining types, special variables and proclamations are
mirrored in the remote ECL as well. This of course is not a complete
synchronization mechanism and thus the state of the remote ECL will
not be 100% the same as that of the host which means that the COMPILE
stub is not an entirely correct implementation of the ANSI standard.
But it works well enough to run the test suite which is all we need.
2025-11-21 19:08:14 +01:00
Marius Gerbershagen
ee60bffaf0 cmp: allow cross compiling to/from targets with complex float support
A host compiler without complex float support still needs to be able
to emit C instructions for complex float. In this case, the host
doesn't define si::complex-{single/double/long}-float types, so we
need to replace those by types which all variants of ECL understand.
Moreover, functions for emitting C code dealing with complex floats
must be present even if the host doesn't support complex floats
natively.

Deciding whether to emit these instructions is implemented either by
explicit checks for *complex-float* or automatically as the compiler
will not create :c{s/d/l}float locations for a target without complex
float support (this is decided at runtime based on the contents
of *machine*).
2025-11-21 19:08:14 +01:00
Marius Gerbershagen
deec67aa57 cmp: allow for cross compiling to/from targets with C compatible variadic dispatch 2025-11-21 19:08:14 +01:00
Marius Gerbershagen
02415a4008 cmp: warn for unsupported cross compilation configurations 2025-11-21 19:08:14 +01:00
Marius Gerbershagen
fb321885db cmp: easier cross-compilation of user code
The procedure works as follows. First, cross compile ECL itself. In
this step, we dump the configuration of the compiler. This
configuration can then be later restored to put the host compiler into
cross compilation mode using a new option to WITH-COMPILATION-UNIT.

The following changes to the public interface are introduced:

- WITH-COMPILATION-UNIT now takes a new :target keyword
- New functions C:WRITE-TARGET-INFO, C:READ-TARGET-INFO to dump and
  restore the config
- The environment parameters to TYPEP and SUBTYPEP are no longer
  unused. User macros can query type relationships in the target
  environment using these parameters.

Internal changes in the compiler include:

- Target dependent variables in the compiler are defined using a new
  DEFCONFIG macro. C:WRITE-TARGET-INFO simply writes the value of
  these variables to a file.
- The distinction between target types and host types already exists
  in the compiler. In this commit, we just register the target types in
  the compiler environment when we change the compiler configuration.
2025-11-21 19:08:14 +01:00
Daniel Kochmański
bd64c52d7e Merge branch 'fix-802' into develop 2025-11-17 10:42:22 +01:00
Daniel Kochmański
7c5471947d c2tagbody-body: fix a regression when processing intermediate tag
In 521e815158 I've introduced a regression where
we did not bind the destination and exit label for intermediate forms.

Fixes #802.
2025-11-17 10:39:45 +01:00
Daniel Kochmański
1e10761593 tests: add a test for the recent regression 2025-11-16 11:03:48 +01:00
Marius Gerbershagen
b8bd5f4026 cmp: fix constant folding
Fixes a regression introduced in commit
816c08340b. After the changes in that
commit, c1forms of name variable can denote constants as well.

Since we are now more aggressive with inlining constant access, we
have to fix a bad defconstant definition in clos/boot.lsp as well (the
new definition makes sure that the compile-time and load-time
evaluations of the constant are eql).
2025-11-15 16:52:31 +01:00
Marius Gerbershagen
294da20f38 Merge branch 'cons-kingdom' into 'develop'
Cleanups and fixes for SUBTYPEP

See merge request embeddable-common-lisp/ecl!357
2025-09-14 12:15:28 +00:00
Daniel Kochmański
dceff25679 predlib: fix a braino in one of the clauses of CANONICAL-TYPE
Instead of returning the registered tag (when found), we've returned NIL.
2025-09-08 09:16:27 +02:00
Daniel Kochmański
47c17cbfa2 predlib: add accessors for *elementary-types* and *member-types*
Previously elementary types were considered to be (CONS SPECC TAG), but I want to
introduce additional slot information to them, so we define a structure for that
type. The representation a is list because MAYBE-SAVE-TYPES calls COPY-TREE. Also
DEFSTRUCT is not available yet.

Rename PUSH-TYPE to PUSH-NEW-TYPE and move it to a correct section in the file.
2025-09-08 09:16:25 +02:00
Daniel Kochmański
783289c629 predlib: assert n important property when adding a new type
The property in question is a strict total order within the kingdom.
2025-08-27 10:46:58 +02:00