Commit graph

307 commits

Author SHA1 Message Date
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
Marius Gerbershagen
4734509f15 cmp: allow cross compiling to/from targets without shared library support 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
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
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
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
Tarn W. Burton
bc6e31f926
Add generic pathname/truename 2024-01-25 14:05:27 -05:00
Daniel Kochmański
3e37843a33 cleanup: update license to lgpl-2.1+ in both headers and text 2024-01-14 12:22:27 +01:00
Daniel Kochmański
e54b944e7a cmp: don't refer to module functions as local-funs
It is a historical baggage from before FSET. Functions stored in *local-funs*
are both local and global, so sipmly rename it to *functions*.
2023-11-25 18:48:56 +01:00
Daniel Kochmański
2304da9a83 cmpc: separate the data segment creation passes 2023-11-17 11:21:21 +01:00
Marius Gerbershagen
58c5782fe7 cmp: also perform type propagation in disassemble 2023-10-30 12:01:20 +01:00
Daniel Kochmański
29fb6009e4 cmp: disassemble: fix a regression
The function disassemble will end up in the backend too eventually, although for
now it is defined in cmpmain. Recently we've moved backend-specific variables to
the code generation pass, but disassemble still relies on that environment.
2023-06-27 09:18:02 +02:00
Daniel Kochmański
0321023572 cmp: propagate types in functions too
The propagator for FSET did not descend to the function object while the
propagator for LOCALS did (that was inconsistent). Also cmpmain called
P1PROPAGATE on *LOCAL-FUNS* before the second pass so that was no-op.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
1e9786fd0a cmp: simplify the type propagation pass
Previously we've carries the "assumption" list through all calls, but said
assumption list was never used to make any decisions (and we had numerous
assertions that it must be null at various places).

The assumption list made the code less readable because it intorduced numerous
loops and multiple-value-bind calls just to maintain it. Removal introduces no
known regressions.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
244f4e0485 cmp: separate cmpbackend from cmpmain (2)
Introduce compiler-pass/assemble-cxx.
2023-05-24 15:49:06 +02:00
Daniel Kochmański
3f3c89ddb2 cmp: separate cmpbackend from cmpmain (1)
Introduce compiler-pass/generate-cxx.
2023-05-24 15:49:03 +02:00
Marius Gerbershagen
ae19006cb8 Merge branch 'cmpwerk' into 'develop'
Separate COMPILER and EXT,FFI,MP packages

See merge request embeddable-common-lisp/ecl!285
2023-03-12 15:31:36 +00:00
Daniel Kochmański
0a3c4f53be cosmetic: fix a typo 2023-03-09 13:56:48 +01:00
Daniel Kochmański
d29a26cf8a cosmetic: cmp: declare unused variables as ignored 2023-02-21 14:34:11 +01:00
Daniel Kochmański
acd1dd3c07 cmp: don't import symbols from the SYSTEM package
Use proper package accessors instead. This was mostly already done. Removal of
package imports make it easier to tell when symbols do not belong to cmp.
2023-02-21 14:34:11 +01:00
Marius Gerbershagen
de89593216 fix typos 2023-02-18 17:30:30 +01:00
Daniel Kochmański
6d191760b3 cosmetic: cmp: rename a function guess-ld-flags to guess-ld-libs
... to better reflect what it returns.
2022-09-08 09:02:42 +02:00
Marius Gerbershagen
826cc92983 cmp: introduce new variables for linker flags
Split up the options into additional flags for the linker and
additional libraries.

Quoting from issue #636:

> Here's an example, attempting to link one object file named
  example.o into an executable named example. Libcrypto here is
  superfluous and should be removed by --as-needed:

```
LDFLAGS="-Wl,--as-needed"
LIBS="-lcrypto"
gcc ${LDFLAGS} ${LIBS} example.o -o example # doesn't link libcrypto!
gcc example.o ${LDFLAGS} ${LIBS} -o example # doesn't honor --as-needed!
gcc ${LDFLAGS} example.o ${LIBS} -o example # works great!
```

> In short, the placement of your -l<foo> flags differs from that of
  all the other linker flags. Since ECL is only providing one big
  variable ld-flags for all of the linker flags, there's no correct
  way to pass in options like --as-needed and -l<foo> at the same
  time.

Fixes #636.
2022-08-24 16:38:20 +02:00
Marius Gerbershagen
ff8cf4d3c1 pathnames: handle unicode characters
On Unix, pathnames are converted into the default encoding specified
by ext:*default-external-format* and back. On Windows, the operating
system already gives us utf16 encoded pathnames, so we use those.

ecl_namestring with ECL_NAMESTRING_FORCE_BASE_STRING encodes with the
specified encoding. Decoding is handled individually in the filesystem
functions.

Includes a minor refactor of list_directory, changing the
PARSE_DIRECTORY_ENTRY macro into an inline function.

Closes #609, #549.
2021-08-19 14:00:28 +02:00
Daniel Kochmański
7efb01d7d1 cmp: separate type propagation pass
The type propagation is invoked with a function compiler-pass/propagate-types
before the compiler-pass2. Previously the type propagation was invoked in
ctop-write.
2021-07-01 14:14:36 +02:00
Daniel Kochmański
c8c59167d0 cmp: major cleanup, separate passes
- separate passes

  The separation is not fine-grained but is a good starting point for further
  cleanup. This is a preliminary requirement for multiple backends.

- use uninternet symbol in the package definition

- remove "execute" permission from all files

- remove a few unused functions

- rearrange loaded files

- less verbose compiler

  Don't print "End of pass 1." message. This doesn't provide any valuable
  information to the programmer.
2021-07-01 14:11:33 +02:00
Marius Gerbershagen
636cb4cf60 cmp: add support for precompiled header files
Improves compilation speed for single functions by about 40-50
percent. Precompiled headers are specific to the compiler version and
options in use. Due to this, we regenerate the header whenever the
compiler configuration changes.
2020-05-16 18:53:57 +02:00
Marius Gerbershagen
c6b4296bb8 cosmetic: fix some compiler warnings 2020-04-29 20:35:37 +02:00
Yuguo Zhang
2532262c0a cmpmain: fix link(msvc) arguments bug in linker-ar 2020-02-10 13:17:18 +08:00
Marius Gerbershagen
d908394007 cmp: don't return nil in compile if compilation failed
The ansi standard states that compile has to return a compiled
function. Fixes various errors in the ansi-test suite.
2019-12-29 23:02:40 +01:00
Daniel Kochmański
69af894224 cmp: remove dynamic variable *compiler-input*
*compiler-input* was only passed to the first-pass, there is no need
for a dynamic binding.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
cab4917d86 cmp: cmpmain first pass: put the pass in a separate function
Function behaves differently for streams and for other objects. This
makes the code more consistent.
2019-12-11 16:13:31 +01:00
Marius Gerbershagen
25d8bf63ef cmp: fix linker-cc for msvc
linker-cc for other compilers includes the libpath in the linker
options, therefore for consistency we need it here too.
2019-08-20 19:52:25 +02:00
Marius Gerbershagen
24dcb778cf clean up functions creating base strings from C strings
Make functions behave as documented, remove use of legacy names.
    Fixes #462.
2019-01-07 18:43:55 +01:00
Marius Gerbershagen
9f4a5d4dd4 disassemble: display generated C source code instead of bytecodes
This behaviour makes more sense, since the ANSI standard mandates
    that disassemble should compile an interpreted function before
    displaying the output (our own documentation even says so).

    Also fixes disassemble for closures.
2018-11-24 19:20:06 +01:00
Marius Gerbershagen
71babf1f99 cmp: prevent spurious error when the compile function fails 2018-11-24 17:58:30 +01:00
ZhangYuguo
5eeae0d823 build system: suppress some logo(copyright) information for msvc toolchains. 2018-09-23 13:41:22 +00:00
Marius Gerbershagen
a3e1cf7c78 cmp: correctly restore compile-file(-pathname) in ext:install-c-compiler
After a call to ext:install-c-compiler while the bytecodes compiler
    is installed, compile-file and compile-file-pathname still point
    to bc-compile-file and bc-compile-file-pathname. Reported and
    fixed by gitlab user pouar. Fixes #444.
2018-07-08 17:33:09 +02:00
Marius Gerbershagen
d27f1494e1 cmp: fix compile call for closures
Signal an error for compilation of cclosures. Allow for
    compilation of bclosures over macros, functions and variables.
    Macros are simply added to the compiler environment. For functions
    and variables we enclose the definition of the closure in
    appropiate let/flet forms, e.g. for `(lambda () (fun var))'
    closing over the function `fun' and variable `var':
    (let ((var ...))
      (flet ((fun (x) ...))
        (lambda () (fun var))))
    Closures over tags and blocks are not implemented and will signal
    an error during compilation.
2018-06-23 21:37:26 +02:00
Daniel Kochmanski
50fb814fd1 Accept all valid function names in c::compile
Previously we accepted only symbols, now we use si:valid-funciton-name-p
predicate to allow (setf foo) as well.
2018-02-13 13:22:12 +01:00
Daniel Kochmanski
d8552498af builder: wrapper: be more explicit with warnings
Add warning that init-name will be ignored for other entities than libraries.
2017-07-21 21:20:48 +02:00
Daniel Kochmanski
bdd17142fb cosmetic: line wrap 2017-07-21 19:34:01 +02:00
Daniel Kochmanski
b15afe097c builder: wrapper: don't output unnecessary code when non needed 2017-07-21 19:33:45 +02:00
Daniel Kochmanski
5a50195666 builder: don't create wrapper when same as init-name 2017-07-21 19:33:27 +02:00
Daniel Kochmanski
5836dc8bec cmp: builder: warn ASDF that it does the wrong thing.
It shouldn't call compute-init-name.
2017-07-21 18:11:55 +02:00
Daniel Kochmanski
b4a83d2955 cmp: make init function name always unique
Add wrapper separately.
2017-07-21 18:11:13 +02:00
Daniel Kochmanski
d1be9436aa cosmetic: add informative comments 2017-07-21 18:10:03 +02:00
Daniel Kochmanski
9061653116 cosmetic: remove gross aux 2017-07-21 17:24:21 +02:00