Without -ffat-lto-objects libguile.a ends up with no symbols, visible
via "nm t libguile.a".
cf. https://lintian.debian.org/tags/no-code-sections.html
* configure.ac: enable -ffat-lto-objects with -flto when available.
When passed a port, `readlink' relies on the Linux specific behavior of
empty c_path meaning "the fd itself". That does not work on Darwin.
Since there is no branch that would yield both fd and c_path, fallback
to freadlink when __APPLE__ is defined.
* libguile/filesys.c (do_readlink): Call freadlink for !__APPLE__.
* configure.ac (AC_CHECK_FUNCS): Add freadlink.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: when -fexcess-precision=standard is available and we're
building for i[3456]86, use it. This fixes floating point precision
problems caused by x87 (80-bit) floating point, and detected by
numbers.test.
Closes: 43262
Have .version depend on the Makefile, and move our
CONFIG_STATUS_DEPENDENCIES setting to an AC_SUBST, as recommended by the
automake info pages "Rebuilding Makefiles" section, so that changes to
GUILE-VERSION will update the VERSION, etc. in the generated Makefiles.
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): drop.
($(top_srcdir/.version)): depend on Makefile.
* configure: add GUILE-VERSION to CONFIG_STATUS_DEPENDENCIES via
AC_SUBST.
Automake "strongly discourages" use of the serial driver, and switching
to the preferred parallel driver allows make -j4 check to run in about
half the time on a four core (not thread) host.
* Makefile.am (TESTS, TESTS_ENVIRONMENT): run ./check-guile from
test-suite/, not here.
* check-guile.in: let test harness handle progress output.
* configure.ac (AM_INIT_AUTOMAKE): allow parallel testing.
* test-suite/Makefile.am (SCM_TESTS): remove non-tests.
(EXTRA_DIST): move non-tests here.
(TESTS): include SCM_TESTS (now driven from here).
(TEST_EXTENSIONS): allow customization for .scm and .test.
(TESTS_ENVIRONMENT): stop defining (user only).
(AM_TESTS_ENVIRONMENT): replaces TESTS_ENVIRONMENT; drop guile.
(SCM_LOG_COMPILER): run .scm tests via meta/guile.
(AM_SCM_LOG_FLAGS): keep --no-auto-compile for .scm tests.
(TEST_LOG_DRIVER): run .test tests via custom automake ./driver.
* test-suite/driver: add automake test driver.
This allows users to adjust their pkg-config install location.
* configure.ac: Call PKG_INSTALLDIR.
* meta/Makefile.am (pkgconfigdir): Remove. It will be defined
automatically by the PKG_INSTALLDIR invocation.
On modern file-systems (BTRFS, ZFS) it is possible to copy a file using
copy-on-write method. For large files it has the advantage of being
much faster and saving disk space (since identical extents are not
duplicated). This feature is stable and for example coreutils' `cp'
does use it automatically (see --reflink).
This commit adds support for this feature into our copy-file procedure.
Same as `cp', it defaults to 'auto, meaning the copy-on-write is
attempted, and in case of failure the regular copy is performed.
No tests are provided, because the behavior depends on the system,
underlying file-system and its configuration. That makes it challenging
to write a test for it. Manual testing was performed instead:
$ btrfs filesystem du /tmp/cow*
Total Exclusive Set shared Filename
36.00KiB 36.00KiB 0.00B /tmp/cow
$ cat cow-test.scm
(copy-file "/tmp/cow" "/tmp/cow-unspecified")
(copy-file "/tmp/cow" "/tmp/cow-always" #:copy-on-write 'always)
(copy-file "/tmp/cow" "/tmp/cow-auto" #:copy-on-write 'auto)
(copy-file "/tmp/cow" "/tmp/cow-never" #:copy-on-write 'never)
(copy-file "/tmp/cow" "/dev/shm/cow-unspecified")
(copy-file "/tmp/cow" "/dev/shm/cow-auto" #:copy-on-write 'auto)
(copy-file "/tmp/cow" "/dev/shm/cow-never" #:copy-on-write 'never)
$ ./meta/guile -s cow-test.scm
$ btrfs filesystem du /tmp/cow*
Total Exclusive Set shared Filename
36.00KiB 0.00B 36.00KiB /tmp/cow
36.00KiB 0.00B 36.00KiB /tmp/cow-always
36.00KiB 0.00B 36.00KiB /tmp/cow-auto
36.00KiB 36.00KiB 0.00B /tmp/cow-never
36.00KiB 0.00B 36.00KiB /tmp/cow-unspecified
$ sha1sum /tmp/cow* /dev/shm/cow*
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-always
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-auto
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-never
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-unspecified
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /dev/shm/cow-auto
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /dev/shm/cow-never
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /dev/shm/cow-unspecified
This commit also adds to new failure modes for (copy-file).
Failure to copy-on-write when 'always was passed in:
scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'always)
ice-9/boot-9.scm:1676:22: In procedure raise-exception:
In procedure copy-file: copy-on-write failed: Invalid cross-device link
Passing in invalid value for the #:copy-on-write keyword argument:
scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'nevr)
ice-9/boot-9.scm:1676:22: In procedure raise-exception:
In procedure copy-file: invalid value for #:copy-on-write: nevr
* NEWS: Add note for copy-file supporting copy-on-write.
* configure.ac: Check for linux/fs.h.
* doc/ref/posix.texi (File System)[copy-file]: Document the new
signature.
* libguile/filesys.c (clone_file): New function cloning a file using
FICLONE, if supported.
(k_copy_on_write): New keyword.
(sym_always, sym_auto, sym_never): New symbols.
(scm_copy_file2): Renamed from scm_copy_file. New #:copy-on-write
keyword argument. Attempt copy-on-write copy by default.
(scm_copy_file): Call scm_copy_file2.
* libguile/filesys.h: Add scm_copy_file2 as SCM_INTERNAL.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
clearenv() may not be provided by non-glibc systems. As a fallback,
just set environ to NULL.
* libguile/posix.c (scm_environ)[!HAVE_CLEARENV]: add fallback logic
for clearenv()
* 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'.
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'.
* configure.ac: Detect if ‘openat’ is defined.
* libguile/filesys.c
(flags_to_mode): Extract from ...
(scm_mode): ... here.
(scm_open_fdes_at, scm_openat): Define the Scheme bindings.
* libguile/filesys.h (scm_open_fdes_at, scm_openat): Make them part
of the API.
* doc/ref/posix.texi (File System): Document them.
* test-suite/tests/filesys.test ("openat"): Test ‘openat’.
* libguile/syscalls.h (openat_or_openat64): Decide between ‘openat’
and ‘openat64’.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect if ‘fstatat’ is defined.
* libguile/filesys.c (scm_statat): Define a Scheme binding to ‘fstatat’.
* libguile/filesys.h (scm_statat): Make it part of the C API.
* doc/ref/posix.texi (File System): Document it.
* libguile/syscalls.h (fstatat_or_fstatat64): Choose between ‘fstatat’
and ‘fstatat64’.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘fchownat’ is available.
* libguile/filesys.c (scm_chownat): Define a Scheme binding to
‘fchownat’ when available.
* libguile/filesys.h (scm_chownat): Make it part of the API.
* doc/ref/posix.texi (File System): Document it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
‘unlinkat’ is used for both unlinking regular files
and removing empty directories.
* configure.ac: Detect if ‘unlinkat’ exists.
* doc/ref/posix.texi (File System): Document why there is no
‘rmdirat’ procedure, and document the ‘delete-file-at’ procedure.
* libguile/filesys.c
(scm_rmdir): Adjust the docstring here as well.
(scm_delete_file_at): Define a Scheme binding to ‘unlinkat’.
* libguile/filesys.h (scm_delete_file_at): Make ‘scm_delete_file_at’
part of the C API.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect existence of fchmodat.
* libguile/filesys.c (scm_chmodat): New procedure.
* libguile/filesys.h (scm_chmodat): Make it part of the API.
* test-suite/tests/filesys.test ("chmodat"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect if ‘renameat’ is defined.
* libguile/filesys.c (scm_renameat): Define a Scheme binding
to the ‘renameat’ system call.
* doc/ref/posix.texi (File System): Document it.
* libguile/filesys.h (scm_renameat): Make it part of the C API.
* test-suite/tests/filesys.test ("rename-file-at"): New tests.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘symlinkat’ exists.
* libguile/filesys.c (scm_symlinkat): Define a Scheme binding
when it exists.
* libguile/filesys.h: Make the binding part of the public C API.
* doc/ref/posix.texi (File System): Document the binding.
* test-suite/tests/filesys.test ("symlinkat"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘readlinkat’ is defined.
* libguile/filesys.c (scm_readlink): Support file ports
when ‘readlinkat’ exists.
(scm_init_filesys): Provide ‘chdir-ports’ when it exists.
* doc/ref/posix.texi (File System): Document it.
* test-suite/tests/filesys.test ("readlink"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Check for ‘fchdir’.
* libguile/filesys.c
(scm_chdir): Support file ports.
(scm_init_filesys): Report support of file ports.
* doc/ref/posix.texi (Processes): Update accordingly.
* doc/ref/guile.texi: Add copyright line for new documentation in this
patch and later patches.
* test-suite/tests/filesys.test ("chdir"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Since Guile requires a C99 compiler, we can rely on signal handlers
returning void, not int.
* configure.ac: remove AC_TYPE_SIGNAL
* libguile/scmsigs.c (SIGRETTYPE): remove SIGRETTYPE
(take_signal): returns void
(scm_sigaction_for_thread): presumes handlers return void
This is the same strategy as used for the 'accept4' bindings introduced
in 6e0965104c.
* libguile/posix.c (scm_pipe): Rename to...
(scm_pipe2): ... this. Add an optional 'flags' parameter and honor it.
(scm_pipe): Rewrite as a call to 'scm_pipe2'.
* libguile/posix.h (scm_pipe2): New declaration.
* test-suite/tests/posix.test ("pipe"): New tests.
* configure.ac: Look for 'pipe2'.
* NEWS: Update.
Before the change ./configure incorrectly enabled -flto on toolchains
that support -flto on compiler side but don't support -flto on linker
side. This caused incorrect type size detection on nixpkgs' Darwin:
configure:54594: checking size of size_t
configure:54600: clang -std=gnu11 -o conftest -g -O2 -flto conftest.c >&5
ld: warning: ignoring file /private/tmp/nix-build-guile-3.0.8.drv-0/conftest-00e93d.o,
building for macOS-x86_64 but attempting to link with file built
for unknown-unsupported file format ( 0xDE 0xC0 0x17 0x0B 0x00 0x00 0x00 0x00 0x14 0x00 0x00 0x00 0x80 0x1A 0x00 0x00 )
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
Taken from https://github.com/NixOS/nixpkgs/pull/160051#issuecomment-1046105041
The change makes sure -flto support tests basic support of just for
object file generation but for linker as well.
* configure.ac: use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Fixes <https://issues.guix.gnu.org/54198>.
As noted in the comment at the top, 'SIZEOF_TYPE' must be used instead
of 'sizeof (TYPE)' to support cross-compilation.
The regression was introduced in
5e5afde06f but only became apparent with
717e787da6.
* libguile/gen-scmconfig.c (main): Replace uses of 'sizeof' by
references to the SIZEOF_* macros.
* configure.ac: Add 'AC_CHECK_SIZEOF' call for 'intmax_t'.
* 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.
* configure.ac: Check if the compiler supports link-time optimization.
If it does, turn it on. Saves around 15% off libguile binary size.
Controllable via --enable-lto configure option.
This suggests moving the conditional that determines if mini-gmp is used
into scmconfig.h.
* configure.ac: replace PKG_CHECK_MODULES for gmp with AC_LIB_HAVE_LINKFLAGS
Remove ENABLE_MINI_GMP define. Also don't run mpz_inits test for
--enable-mini-gmp.
* libguile/gen-scmconfig.c (main) [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
with SCM_I_GSC_ENABLE_MINI_GMP
* libguile/bytevectors.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
with SCM_ENABLE_MINI_GMP
* libguile/init.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
with SCM_ENABLE_MINI_GMP
* libguile/numbers.c: include scm.h
[SCM_ENABLE_MINI_GMP]: provide mpz_inits and mpz_clears
[ENABLE_MINI_GMP]: prefer SCM_ENABLE_MINI_GMP to ENABLE_MINI_GMP
* libguile/numbers.h: include scm.h
* libguile/random.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
with SCM_ENABLE_MINI_GMP
* libguile/socket.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
with SCM_ENABLE_MINI_GMP