This reduces the amount of memory that needs to be allocated while
writing the ELF file to disk.
Note: We're abusing #:page-aligned? in 'link-elf' to choose whether to
return a bytevector or a procedure.
* module/system/vm/linker.scm (process-reloc): Subtract SECTION-OFFSET
when writing to BV.
(write-linker-object): Pass BV directly to the linker object writer.
(link-elf): When PAGE-ALIGNED? is false, call 'bytevector-slice' from
here. When it is true, return a procedure that takes a port and writes
to it, without having to allocate a bytevector for the whole ELF
container.
* module/language/bytecode/spec.scm (bytecode->value): Handle X being a
procedure instead of a bytevector.
(bytecode) <#:printer>: Likewise.
* test-suite/tests/linker.test (link-elf-with-one-main-section): Pass
#:page-aligned? #f.
This reduces the amount of memory used during linking and reduces the
number of copies to be done between bytevectors.
* module/system/vm/linker.scm (<linker-object>): Remove 'bv' field and
add 'size' and 'writer'.
(make-linker-object): Adjust accordingly.
(string-table-size): New procedure.
(link-string-table!): Remove.
(string-table-writer): New procedure.
(allocate-segment): Adjust 'make-linker-object' call.
(find-shstrndx): Call the 'linker-object-writer' of O.
(add-elf-objects): Adjust 'make-linker-object' call. Remove
'make-bytevector' allocations and move serialization to lazy 'writer'
procedures. Define 'segments' and 'add-header-segment!'. Return the
latter as the first value.
* module/system/vm/assembler.scm (make-object): Remove 'bv' parameter
and add 'size' and 'writer'.
(link-data): Remove 'make-bytevector' call and move serialization to
a lazy 'writer' procedure.
(link-text-object): Likewise.
(link-frame-maps): Likewise.
(link-dynamic-section): Likewise.
(link-shstrtab): Likewise.
(link-symtab): Likewise.
(link-arities): Likewise, and remove 'bytevector-append'.
(link-docstrs): Likewise.
(link-procprops): Likewise.
(link-debug): Likewise, and define 'copy-writer'.
* test-suite/tests/linker.test (link-elf-with-one-main-section): Adjust
accordingly.
* module/system/vm/assembler.scm (process-relocs): Remove 'buf'
parameter and turn into a pure function.
(patch-relocs!): New procedure. Perform the side effects previously
done in 'process-relocs'.
(link-text-object): Adjust accordingly.
Fixes <https://bugs.gnu.org/60522>.
Reported by Sascha Ziemann <ceving@gmail.com>.
* module/language/tree-il/primitives.scm (make-vector): Return #f when
passed an incorrect number of arguments.
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/rnrs/bytevectors/gnu.scm: New file.
* am/bootstrap.am (SOURCES): Add it.
* libguile/bytevectors.c (scm_bytevector_slice): New function.
* libguile/bytevectors.h (scm_bytevector_slice): New declaration.
* test-suite/tests/bytevectors.test ("bytevector-slice"): New tests.
* doc/ref/api-data.texi (Bytevector Slices): New node.
* module/language/tree-il/peval.scm
(augment-var-table-with-externally-introduced-lexicals): New helper.
* module/language/tree-il/peval.scm (peval): Augment store with any
lexicals introduced by expand-primitives.
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/language/tree-il/primitives.scm (bind-lexicals): New helper.
(expand-eq, expand-chained-comparisons): Ensure all arguments are
eagerly evaluated. Previously an intermediate #f result would shortcut
the evaluation.
* test-suite/tests/compiler.test ("size effects in multi-arg eq / <"):
Add test.
Workaround for <https://bugs.gnu.org/57948>.
* module/system/vm/frame.scm (frame-call-representation): Treat a
binding as "unspecified" if its slot exceeds 'frame-num-locals'.
* module/srfi/srfi-35.scm (condition): Use 'make-exception' instead of
'make-compound-condition', which is unbound in this module.
* test-suite/tests/srfi-35.test ("syntax")["compound condition,
hygienic macro expansion"]: New test.
This makes the docstring attached to the curried function being defined
rather than the result of its application until a function that runs the
body is obtained, fixing
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50068
Locations are stored in tree-il records in "source vector" form, but
`location-string' was rendering these as <unknown-location>.
* module/system/base/message.scm (location-string): Support locations
passed as a file/line/column vector.
Fixes <https://bugs.gnu.org/49223>.
Reported by Domagoj Stolfa <ds815@gmx.com>.
Backport of Guix commit b36267b1d96ac344d2b42c9822ce04b4c3117f85.
* guix/build/download.scm (tls-wrap): Retry up to 5 times when
'handshake' throws a non-fatal error.
The custom input/output port wrapping the TLS session record port would
introduce overhead, and it would also prevent its uses in a non-blocking
context--e.g., with Fibers. The port close mechanism added in GnuTLS
3.7.7 allows us to get rid of that wrapper.
Backported from Guix commit dd573ceea73295c7a872088ecd91e5f0fd74bf2b.
* web/client.scm (wrap-record-port-for-gnutls<3.7.7): New procedure,
with code formerly in 'tls-wrap'.
(tls-wrap): Check for 'set-session-record-port-close!' and use it when
available; otherwise call 'wrap-record-port-for-gnutls<3.7.7'.
This port is of limited use if it cannot be used reliably. Rather than
behaving as if the input has finished when it ends unexpectedly, instead
raise an exception.
* module/web/http.scm (make-chunked-input-port): Raise an exception on
premature termination.
(&chunked-input-ended-prematurely): New exception type.
(chunked-input-ended-prematurely-error?): New procedure.
* test-suite/tests/web-http.test (pass-if-named-exception): Rename to
pass-if-named-exception.
(pass-if-named-exception): New syntax.
("Exception on premature chunk end"): New test for this behaviour.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
The chunked transfer encoding specifies the chunked body ends with
CRLF. This is in addition to the CRLF at the end of the last chunk, so
there should be CRLF twice at the end of the chunked body:
https://datatracker.ietf.org/doc/html/rfc2616#section-3.6.1
* module/web/http.scm (make-chunked-input-port): Read two extra bytes at
the end of the chunked input.
(make-chunked-output-port): Write the missing \r\n when closing the
port.
* test-suite/tests/web-http.test (chunked encoding): Add missing \r\n to
test data.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* module/web/http.scm (write-credentials): capitalize authorization
header scheme. The standard allows the scheme to be case-insensitive,
however most libraries out there expect the scheme to be capitalized,
which is what it is actually used in RFC
docs (e.g. https://datatracker.ietf.org/doc/html/rfc7617#section-2). Some
libraries even reject lowercase scheme making Guile incompatible.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
The code coverage function `coverage-data->lcov` has a documented
`modules` argument, however that was missing from the source. I have
added it so when supplied it only converts the coverage data for the
supplied modules. If not supplied it defaults the old behavour of
including all the modules currently loaded.
* module/system/vm/coverage.scm (coverage-data->lcov): Add #:modules
parameter and honor it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
NetBSD and pkgsrc have been using an empty vendor string since the
mid-'90s, such as x86_64--netbsd. pkgsrc has been carrying around a
workaround just the guile build for a long time. (Before that,
NetBSD omitted the vendor altogether, so if x86_64 existed then it
might have been `x86_64-netbsd', but that caused more problems.)
This change makes Guile accept an empty vendor string so workarounds
are no longer necessary.
* module/system/base/target.scm (validate-target): Allow empty vendor
string in GNU target triplets.
* test-suite/tests/cross-compilation.test ("cross-compilation"): Add
tests for "x86_64--netbsd".
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Guile (3.0.8) reports a compilation error when cond-expand tries to
check existence of a missing library:
scheme@(guile-user)> (define-library (test)
(cond-expand
((library (scheme sort))
(import (scheme sort)))))
While compiling expression:
no code for module (scheme sort)
It looks like bug #40252 was not fully eliminated.
Also, (library ...) cannot handle module names like (srfi 1), though
(import (srfi 1)) works fine. For example, this code fails:
scheme@(guile-user)> (define-library (test)
(cond-expand
((library (srfi 1))
(import (srfi 1)))))
While compiling expression:
In procedure symbol->string: Wrong type argument in position 1
(expecting symbol): 1
There are probably other cases when (library ...) and (import ...) does
not work identically: (library ...) uses resolve-interface while
(import ...) uses resolve-r6rs-interface.
This patch fixes both issues.
* module/ice-9/r7rs-libraries.scm (define-library): Replace
'resolve-interface' call by 'resolve-r6rs-interface', wrapped in
'cond-expand'.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Commit 54bbe0b284 inadvertently led
psyntax to dismiss source location info for data returned by read hash
extensions, because read hash extensions return plain data with
associated source properties, even when called from 'read-syntax'.
This change reverts part of this commit to restore that behavior.
Fixes <https://issues.guix.gnu.org/54003>.
* module/ice-9/psyntax.scm (datum-sourcev): New procedure.
(source-annotation): Fall back to 'datum-sourcev'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/compiler.test ("psyntax")["syntax-source with
read-hash-extend"]: New test.
Avoiding systematic conversion from source vectors to property alists
saves 20% on the final heap size of a process doing:
(compile-file FILE #:optimization-level 1)
where FILE is large.
* module/language/tree-il.scm (tree-il-src/ensure-alist): New procedure
with setter. Export as 'tree-il-src'.
* module/ice-9/psyntax.scm (build-void, build-call)
(build-conditional, build-lexical-reference, build-lexical-assignment)
(build-global-reference, build-global-assignment)
(build-global-definition, build-simple-lambda, build-case-lambda)
(build-lambda-case, build-primcall, build-primref)
(build-data, build-sequence, build-let, build-named-let)
(build-letrec, expand-body): Remove (sourcev->alist src) calls.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): Use
'tree-il-src' instead of accessing the 'src' slot directly.
* module/system/vm/assembler.scm (link-debug): Adjust so PC can be
followed by a vector or an alist.
* module/ice-9/psyntax.scm (source-annotation): Only return source
properties from syntax objects.
(source-wrap): Don't look for source properties.
(expand-macro): Rebuild source properties on macro output via
source-wrap, not source properties. Only annotate head of a chain of
pairs.
(strip): Here's the only use of set-source-properties!: when stripping
a syntax object to a datum.
(macroexpand): If the input expression is not a syntax object, eagerly
extract its source properties.
(datum->syntax): Fix case in which source is given as an alist.
* module/ice-9/psyntax-pp.scm: Regenerate.
* configure.ac:
* Makefile.am (SUBDIRS): Replace bootstrap/ with stage0, stage1, and
stage2.
* am/bootstrap.am: Include all files and all rules.
* meta/build-env.in (GUILE_AUTO_COMPILE): Always turn off
auto-compilation. Take a GUILE_BOOTSTRAP_STAGE argument, which can be
stage0, stage1, stage2, or unset. Adapt the load-compiled path
accordingly.
* meta/uninstalled-env.in: Include .go files from stage2.
* module/Makefile.am: Rework to use boostrap.am.
* module/system/base/optimize.scm (available-optimizations): Punt the
inlinable-exports machinery to -O2.
* stage0/Makefile.am:
* stage1/Makefile.am:
* stage2/Makefile.am: New files.
* module/language/tree-il/peval.scm (peval): The intention was for
resolve-interface to return an interface only if it exists, but actually
it throws if the interface isn't know. Fix to do what we intended to
do.
* module/language/tree-il/inlinable-exports.scm (compute-decoder): Fix
bug in which inlinable exports in a pure module would have a missing
make-struct/no-tail binding.
Calling out to Scheme was a performance regression.
* libguile/integers.h:
* libguile/integers.c (scm_integer_expt_ii, scm_integer_expt_zi): New
internal functions.
* libguile/numbers.c (scm_integer_expt): Go back to C. But, include
fast cases for inums and doubles.
* module/ice-9/boot-9.scm: Revert addition of integer-expt.
* libguile/numbers.c (integer_expt_var): New static variable.
(init_integer_expt_var): New helper.
(scm_integer_expt): Delegate to Scheme.
* module/ice-9/boot-9.scm (integer-expt): Reimplement in Scheme. Misses
some optimizations for fractions but that is probably OK!
This patch removes the undocumented function make-srfi-4-vector from
(guile). That function is still exported from (srfi srfi-4 gnu).
* libguile/srfi-4.h (scm_init_srfi_4): Split into scm_bootstrap_srfi_4()
and scm_init_srfi_4(), after the pattern of scm_init_bytevectors() and
scm_bootstrap_bytevectors().
* libguile/init.c: Replace scm_init_srfi_4() call by scm_bootstrap_srfi_4().
* module/srfi/srfi-4.scm: Load newly defined srfi-4 extension. This
provides undocumented make-srfi-4-vector.
* module/srfi/srfi-4/gnu.scm: Export srfi-4-vector-type-size.
* doc/ref/srfi-modules.texi: Document srfi-4-vector-type-size.
496f69dba2 introduced C99 complex types in
libguile/foreign.h and (system foreign). Since these types are provided
conditionally in foreign.h based on autoconf tests they need to be used
conditionally in (system foreign) based on their presence.
* module/language/cps/return-types.scm: New file.
* module/Makefile.am (SOURCES):
* am/bootstrap.am (SOURCES): Add new file.
* module/language/tree-il/compile-cps.scm (sanitize-meta): Strip
"noreturn" and "return-type" properties -- these should only be
computed by Guile.