1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

20912 commits

Author SHA1 Message Date
Ludovic Courtès
2b73fe8169
maint: Move Guix files to '.guix'.
* build-aux/guix: Rename to...
* .guix/modules: ... this.
* .guix-channel: Adjust accordingly.
* guix.scm: Likewise.
* build-aux/manifest.scm: Rename to...
* .guix/manifest.scm: ... this.
* Makefile.am (EXTRA_DIST): Adjust accordingly.
2023-06-05 09:19:59 +02:00
Ludovic Courtès
7847683d05
maint: Avoid 'specification->package' when referring to packages.
This avoids ambiguity when using channels in addition to 'guix'.

* build-aux/guix/guile-package.scm (guile): Refer to packages by their
bindings rather than using 'specification->package'.
2023-06-05 09:10:05 +02:00
Josselin Poiret
36fd2b4920
Use /dev/null in 'piped-process' if port is not backed by a fdes.
In Guile 3.0.9, 'system*' would no longer open /dev/null for file
descriptors 0, 1, and 2 when its 'current-input-port',
'current-output-port', or 'current-output-port' is not bound to a file
port.  This patch reinstates that behavior.

Fixes <https://bugs.gnu.org/63024>.

* libguile/posix.c (piped_process): Open /dev/null to use as in/out/err
if the corresponding port is not backed by a file descriptor.
* test-suite/tests/posix.test ("system*")["https://bugs.gnu.org/63024"]:
New test.
* NEWS: Update.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2023-05-08 16:06:28 +02:00
Josselin Poiret
ccd7400fdb
Add error handling for spawn's posix_spawn_file_actions_adddup2.
* libguile/posix.c (do_spawn): Add error handling if
posix_spawn_file_actions_adddup2 fails.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-05-08 15:58:57 +02:00
Andy Wingo
6efc0b8159 call-with-values builtin doesn't leave garbage on the stack
Fixes https://debbugs.gnu.org/63279.  The issue was that if the producer
thunk caused a backtrace, pretty-printing the call-with-values frame
would segfault because there was an unininitialized slot on the stack.
For functions produced by the compiler this wouldn't be a problem
because there are stack maps, but primitives require that all slots on a
pending stack frame be packed (no uninitialized values) and tagged (all
SCM values, no unboxed values).

* test-suite/tests/error-handling.test: New test.
* test-suite/Makefile.am: Add new file.
* libguile/vm.c (define_vm_builtins): Fix call-with-values to have a
more compact stack.
2023-05-07 09:50:14 +02:00
Daniel Llorens
fe6cc6d04a Use SCM_GSUBR_MAX in place of the hardcoded number
* libguile/gsubr.c (scm_apply_subr): Reference the limit.
  (get_subr_stub_code): As stated.
* libguile/jit.c (compile_subr_call): As stated.
2023-04-27 14:07:01 +02:00
Jorge Gomez
1ae50a7f80 Fix typo in append procedure documentation
Fixes <https://bugs.gnu.org/62456>.

Signed-off-by: Mikael Djurfeldt <mikael@djurfeldt.com>
2023-04-05 20:30:11 +02:00
Mikael Djurfeldt
e9c8ca341b Add missing backslash. 2023-04-04 13:33:57 +02:00
Ludovic Courtès
e93525e549
Adjust 'spawn' tests to accept 'LD_ORIGIN_PATH' on GNU/Hurd.
Fixes <https://bugs.gnu.org/62501>.

* test-suite/tests/posix.test ("spawn")["env with #:environment
and #:output"]: Add workaround for GNU/Hurd.
* NEWS: Update.
2023-04-02 15:39:57 +02:00
Ludovic Courtès
9cc85a4f52
Use 'posix_spawn_file_actions_addclosefrom_np' where available.
* configure.ac: Check for 'posix_spawn_file_actions_addclosefrom_np'.
* libguile/posix.c (HAVE_ADDCLOSEFROM): New macro.
(close_inherited_fds): Wrap in #ifdef HAVE_ADDCLOSEFROM.
(do_spawn) [HAVE_ADDCLOSEFROM]: Use 'posix_spawn_file_actions_addclosefrom_np'.
2023-04-02 15:36:33 +02:00
Ludovic Courtès
7d7067fe15
Remove racy optimized file descriptor closing loop in 'spawn'.
This reverts 9332b63240, thereby
reinstating the performance issue in <https://bugs.gnu.org/59321>.

This optimization was subject to race conditions in multi-threaded code:
new file descriptors could pop up at any time and thus leak in the
child.

* libguile/posix.c (close_inherited_fds): Remove.
(close_inherited_fds_slow): Rename to...
(close_inherited_fds): ... this.
2023-04-02 15:36:33 +02:00
Ludovic Courtès
21ad54b694
'spawn' closes only open file descriptors on non-GNU/Linux systems.
Fixes <https://bugs.gnu.org/61095>.
Reported by Omar Polo <op@omarpolo.com>.

* libguile/posix.c (close_inherited_fds_slow): On systems other than
GNU/Linux, call 'addclose' only when 'fcntl' succeeds on MAX_FD.
* NEWS: Update.
2023-04-02 15:36:25 +02:00
Ludovic Courtès
e334e59589
Update NEWS. 2023-03-20 23:25:01 +01:00
Christopher Baines
cba2e7e3fe
Fix some invalid unicode handling issues with suspendable ports.
Fixes <https://bugs.gnu.org/62290>.

Based on the implementation in ports.c.  I don't understand what this
code is really doing, but the suspendable ports implementation differs
from the similar C code for a couple of inequalities.

* module/ice-9/suspendable-ports.scm (decode-utf8, bad-utf8-len): Flip a
couple of inequalities.
* test-suite/tests/ports.test ("string ports"): Add additional invalid
UTF-8 test case.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-03-20 23:23:29 +01:00
Rob Browning
ffb95239aa scm_i_utf8_string_hash: compute u8 chars not bytes
Noticed while investigating a migration to utf-8 strings.  After making
changes that routed non-ascii symbol hashing through this function,
encoding-iso88597.test began intermittently failing because it would
traverse trailing garbage when u8_strnlen reported 8 chars instead of 4.

Change the scm_i_str2symbol and scm_i_str2uninterned_symbol internal
hash type to unsigned long to explicitly match the scm_i_string_hash
result type.

* libguile/hash.c (scm_i_utf8_string_hash): Call u8_mbsnlen not u8_strnlen.
* libguile/symbols.c (scm_i_str2symbol, scm_i_str2uninterned_symbol):
Use unsigned long for scm_i_string_hash result.
* test-suite/standalone/.gitignore: Add test-hashing.
* test-suite/standalone/Makefile.am: Add test-hashing.
* test-suite/standalone/test-hashing.c: Add.
2023-03-18 13:24:43 -05:00
Daniel Llorens
f0df1ed0fd Fix no-clause case-lambda in peval
This is checked by optargs.test, which 3b47f87618
broke.

* module/language/tree-il/peval.scm (peval): Account for no clause (= no body)
  case-lambda.
2023-03-17 21:17:10 +01:00
Daniel Llorens
3b47f87618 peval reduces some inlined case-lambda calls
* module/language/tree-il/peval.scm (peval): Reduce multiple case lambda
  in <call> trees according to the number of arguments. Do not try to
  reduce case-lambda using keyword arguments.
* test-suite/tests/peval.test: Tests.
2023-02-27 11:53:48 +01:00
Ludovic Courtès
e2ed33ef04
Remove unnecessary module imports.
These were found with:

  make GUILE_WARNINGS='-W1 -Wunused-module'

* module/ice-9/copy-tree.scm:
* module/ice-9/eval-string.scm:
* module/ice-9/getopt-long.scm:
* module/ice-9/poll.scm:
* module/ice-9/popen.scm:
* module/ice-9/sandbox.scm:
* module/ice-9/threads.scm:
* module/sxml/apply-templates.scm:
* module/sxml/simple.scm:
* module/system/base/types.scm:
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/repl/coop-server.scm:
* module/system/repl/debug.scm:
* module/system/repl/error-handling.scm:
* module/system/repl/repl.scm:
* module/system/repl/server.scm:
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/dwarf.scm:
* module/system/vm/elf.scm:
* module/system/vm/frame.scm:
* module/system/vm/inspect.scm:
* module/system/vm/linker.scm:
* module/system/vm/program.scm:
* module/system/vm/trace.scm:
* module/system/vm/trap-state.scm:
* module/system/vm/traps.scm:
* module/system/xref.scm:
* module/texinfo/indexing.scm:
* module/texinfo/plain-text.scm:
* module/texinfo/reflection.scm:
* module/texinfo/string-utils.scm:
* module/web/client.scm:
* module/web/http.scm:
* module/web/request.scm:
* module/web/response.scm: Remove imports of unused modules.
2023-02-24 16:49:00 +01:00
Ludovic Courtès
89c3bae3cf
Add -Wunused-module.
* module/language/tree-il/analyze.scm (<module-info>): New record type.
(unused-module-analysis): New variable.
(make-unused-module-analysis): New analysis.
(make-analyzer): Add it.
* module/system/base/message.scm (%warning-types): Add 'unused-module'.
* test-suite/tests/tree-il.test (%opts-w-unused-module): New variable.
("warnings")["unused-module"]: New test prefix.
* NEWS: Update.
2023-02-24 16:49:00 +01:00
Ludovic Courtès
821e0f9cd5
Add 'record-case' to '.dir-locals.el'.
* module/language/tree-il/fix-letrec.scm (fix-letrec): Remove "Local
Variables" bit.
* .dir-locals.el (scheme-mode): Add 'record-case'.
2023-02-24 16:49:00 +01:00
Daniel Llorens
52465f0ce7 Fix typo in raise-exception documentation
* doc/ref/api-control.texi (Raising and Handling Exceptions): Fix typo,
  h/t gtz on #guile.
2023-02-24 16:05:18 +01:00
Ludovic Courtès
9d339ea1a9
README: Update Git URLs.
* README: Update Git URLs.
2023-02-06 16:51:02 +01:00
Ludovic Courtès
32f33756d0
maint: Add variants of the default package for Guix.
* build-aux/guix/guile-package.scm (package-with-configure-flags): New
procedure.
(guile-without-threads, guile-without-networking)
(guile-debug, guile-strict-typing): New variables.
* build-aux/manifest.scm: Use (guile-package) module instead of 'load'.
(native-builds): Add the variants above + "guile-clang".
2023-02-06 16:51:02 +01:00
Ludovic Courtès
a211c8aaff
maint: Masquerade as a Guix channel.
By pretending to be a Guix channel, this repository can be consumed
seamlessly by tools such as Cuirass.

* .guix-channel: New file.
* guix.scm: Turn into a symlink to...
* build-aux/guix/guile-package.scm: ... this.  New file.
* Makefile.am (EXTRA_DIST): Add them, except '.guix-channel'.
2023-02-06 16:51:02 +01:00
Ludovic Courtès
c617f4e04f
maint: Add Guix build files.
* guix.scm, build-aux/manifest.scm: New files.
* Makefile.am (EXTRA_DIST): Add them.
* README: Mention it.
2023-02-06 16:51:00 +01:00
Ludovic Courtès
5b42f8c154 'spawn' ensures it is passed open file ports.
Fixes <https://bugs.gnu.org/61073>.

* libguile/posix.c (FDES_FROM_PORT_OR_INTEGER): When OBJ is not an
integer, use 'SCM_VALIDATE_OPFPORT' before using 'SCM_FPORT_FDES'.
* test-suite/tests/posix.test ("spawn")["non-file port argument"]: New
test.
2023-01-26 09:42:46 +01:00
Daniel Llorens
35566ea585 Document multiple-value returns in forms taking a let-expression body
* doc/ref/api-binding.texi (Local Bindings): Document multiple-value
  returns for let.
* doc/ref/api-control.texi (begin): Document multiple-value returns for
  begin.
  (Conditionals): Document multiple-value returns and use 'body' in the
  syntax description of when, unless, cond, case.
  (Multiple values): Document multiple-value returns and use 'body' in
  the syntax description of SRFI-8 receive.
  (Fluids and Dynamic States): Use 'body' in the syntax description of
  'with-fluids'.
2023-01-25 12:52:29 +01:00
Linus
764e3614b8 Add internal definitions to derived forms
This commit adds internal definitions to the following derived
forms: when, unless, cond, case, with-fluids, and and-let*.

 * doc/ref/api-control.texi (Conditionals): Update the syntax and docs
   of when, unless, cond, and case.
 * module/ice-9/and-let-star.scm (and-let*): Changed begins to let.
 * module/ice-9/boot-9.scm (cond, case, when, unless, with-fluids):
   Changed begins to let.
2023-01-24 17:11:38 +01:00
Ludovic Courtès
9b20ca275d Verify 'W_EXITCODE' only when we provide our own definition.
Fixes <https://bugs.gnu.org/60971>.
Reported by lloda <lloda@sarc.name> and Greg Troxel <gdt@lexort.com>.

On macOS and NetBSD, 'WEXITSTATUS' expects an lvalue so the expression
passed to 'verify' would be invalid.

* libguile/posix.c: Move 'verify' assertion within #ifdef.
2023-01-23 22:52:47 +01:00
Ludovic Courtès
2e1ba78c30 maint: Abort 'make dist' when Readline support is missing.
Reported by Greg Troxel <gdt@lexort.com>.

* Makefile.am (ensure-guile-readline): New target.
(dist-hook): Depend on it.
2023-01-23 12:00:40 +01:00
Ludovic Courtès
181f7ee4a7 Update NEWS. 2023-01-23 11:56:12 +01:00
Ludovic Courtès
80bf3f48b4 Remove 'extern' from 'scm_i_current_thread' definition, except on macOS.
This is a followup to f859e0f58b, which
led to warnings on GNU/Linux:

  threads.c:358:43: warning: 'scm_i_current_thread' initialized and declared 'extern'

* libguile/threads.c (scm_i_current_thread): Make 'SCM_INTERNAL'
conditional.
2023-01-20 10:04:48 +01:00
Ludovic Courtès
f57f931e6a build: Use '--enable-mini-gmp' for "make distcheck".
* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Add '--enable-mini-gmp'.
2023-01-20 09:46:07 +01:00
Ludovic Courtès
479b7388e9 GNU Guile 3.0.9.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_CURRENT): Increment, to account for the new
'scm_*at' procedures, 'scm_bytevector_slice', etc.
(LIBGUILE_INTERFACE_AGE): Increment.
2023-01-19 22:16:15 +01:00
Ludovic Courtès
2ace7a5312 doc: Mention URL of Guile-GnuTLS.
* doc/ref/web.texi (Web Client): Mention new URL of Guile-GnuTLS.
2023-01-19 15:48:47 +01:00
Ludovic Courtès
616c217409 Add Gnulib 'sys_select' module, needed for MinGW.
This is again from Gnulib v0.1-5703-g356a414e8c.

* m4/gnulib-cache.m4: Add 'sys_select'.
* libguile/threads.c: Include <sys/select.h>.
2023-01-19 15:48:41 +01:00
Ludovic Courtès
a43a8fd8ba Add Gnulib 'gethostname' module, needed for MinGW.
This is again from Gnulib v0.1-5703-g356a414e8c.

* m4/gnulib-cache.m4: Add 'gethostname'.
2023-01-19 09:58:01 +01:00
Ludovic Courtès
3bb08542d2 Add Gnulib modules for 'posix_spawn' file operations.
This is again from Gnulib v0.1-5703-g356a414e8c.

* m4/gnulib-cache.m4: Add 'posix_spawn_file_actions_addclose',
'posix_spawn_file_actions_adddup2',
'posix_spawn_file_actions_addopen', and
'posix_spawn_file_actions_init'.
2023-01-19 00:32:12 +01:00
Ludovic Courtès
d98888290b Remove more Gnulib generated files. 2023-01-18 22:50:23 +01:00
Ludovic Courtès
aeb22f4861 Update Gnulib to v0.1-5703-g356a414e8c and add 'posix_spawn' module.
This is a followup to edfca3b7e5, which
added the 'posix_spawnp' module but not 'posix_spawn'.

* m4/gnulib-cache.m4: Add 'posix_spawn' module.
* gnulib-local/m4/clock_time.m4.diff: Adjust.
* configure.ac: Move 'gl_EARLY' use right after 'AC_PROG_CC'.
2023-01-18 22:50:18 +01:00
Ludovic Courtès
4404b553a5 Adjust 'W_EXITCODE' for Windows.
* libguile/posix.c (W_EXITCODE) [_WIN32]: New specialized definition.
2023-01-18 18:24:11 +01:00
Ludovic Courtès
cd7475541a Fix argument number in 'spawn' type check.
* libguile/posix.c (scm_spawn_process): Fix argument number in
'SCM_VALIDATE_NONEMPTYLIST'.
2023-01-18 12:13:55 +01:00
Ludovic Courtès
9a004606e0 Update NEWS.
* NEWS: Update.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
3cd64feb2e linker: Do not store entire ELF in memory when writing to a file.
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.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
4ab71e1f0d linker: Linker object writer takes a single argument.
* module/system/vm/linker.scm (write-linker-object): Pass the
'linker-object-writer' a single argument.
(string-table-writer, add-elf-objects): Adjust writers accordingly.
(string-table-writer):
(add-elf-objects):
* module/system/vm/assembler.scm (link-data, link-text-object)
(link-frame-maps, link-dynamic-section)
(link-symtab, link-arities, link-docstrs)
(link-procprops, link-debug): Likewise.
* test-suite/tests/linker.test (link-elf-with-one-main-section):
Likewise.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
041f11b353 linker, assembler: Avoid intermediate bytevectors.
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.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
d0d9743607 linker: Separate effectful part of 'add-elf-objects'.
* module/system/vm/linker.scm (add-elf-objects)[write-and-reloc]: Split
into...
[compute-reloc, write-object-elf-header!]: ... this.
Adjust accordingly.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
d439a3f671 assembler: Separate effectful part of 'link-docstrs'.
* module/system/vm/assembler.scm (link-docstrs): Define
'write-docstrings!' and use it.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
13e2d5b66b assembler: Separate effectful part of 'link-frame-maps'.
* module/system/vm/assembler.scm (link-frame-maps)[make-frame-maps]:
Define 'write!' and use it.
2023-01-17 17:49:05 +01:00
Ludovic Courtès
dc0c4ccb1f assembler: Separate effectful part of 'link-procprops'.
* module/system/vm/assembler.scm (link-procprops): Define
'write-procprops!' and use it.
2023-01-17 17:49:05 +01:00