unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Removing a store reference from a file
@ 2017-10-26 15:04 Leo Famulari
  2017-10-27  0:43 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Famulari @ 2017-10-26 15:04 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1984 bytes --]

I noticed that Go executables built with the go-build-system keep an
unnecessary reference to Go itself:

$ guix gc --references $(realpath $(which syncthing))
/gnu/store/3h31zsqxjjg52da5gp3qmhkh4x8klhah-glibc-2.25
/gnu/store/bqlmgk6ngyi4pivnqpxma2wr5pj5mhkk-gcc-5.4.0-lib
/gnu/store/bzj472nmnnj5hcfd5yvfiqip1wzw84p9-tzdata-2017b
/gnu/store/qydgxm0sipn4bn5122a3zxiz1bz0vvnw-go-1.9.2
/gnu/store/z1lii251cy0y660910hsfc55cy82dk9i-net-base-5.3

The programs don't need or use this reference, so it would be nice to
get rid of it and save users some bandwidth when installing Go programs.

I'm still figuring out the best way to approach this issue (Go compiler
flags?), but here is some research.

In Nixpkgs, there is a switch to disallow this reference specifically:

------
# Do not enable this without good reason
# IE: programs coupled with the compiler
, allowGoReference ? false
------
https://github.com/NixOS/nixpkgs/blob/39cd40f7bea40116ecb756d46a687bfd0d2e550e/pkgs/development/go-modules/generic/default.nix#L29

... and it ends in a call to a general-purpose shell script,
remove-references-to, which uses sed to remove specific references:

https://github.com/NixOS/nixpkgs/blob/39cd40f7bea40116ecb756d46a687bfd0d2e550e/pkgs/build-support/remove-references-to/default.nix

I see that in Guix we have ((guix build utils) remove-store-references),
which removes *all* store references from a file, but using it here
leaves the Go executable unable to even start execution. I think it
needs libc's linker:

------
% strace -s1000 -f ./syncthing 
execve("./syncthing", ["./syncthing"], [/* 42 vars */]) = -1 ENOENT (No such file or directory)
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
write(2, "strace: exec: No such file or directory\n", 40strace: exec: No such file or directory
) = 40
getpid()                                = 5493
exit_group(1)                           = ?
+++ exited with 1 +++
------

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-27  0:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-26 15:04 Removing a store reference from a file Leo Famulari
2017-10-27  0:43 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).