all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Developing golang programs on guix
@ 2018-01-29  9:50 Peter Mikkelsen
  2018-01-29 21:39 ` bug#30287: Go compiler tries writing to the store Leo Famulari
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Mikkelsen @ 2018-01-29  9:50 UTC (permalink / raw)
  To: help-guix

Hi guix,

Lately I have been playing around with go after a long time with no
use, but last time I was on fedora I think.
Now that I am on guixSD, I have found that the standard go way of
doing things is not working as expected.

For example, after setting the environment variable GOPATH to
/home/peter/go, and creating a small hello world program in there, I
would normally be able to run 'go install' in that folder, and the
hello world binary would end up in my gopath. But on guixSD this is
not the case, since it seems like 'go install' is trying to compile
every single library provided by to go package itself, and that means
writing to the store, which is not possible.

For example, the output of 'go install -x' in my hello world project
gives me this output:

WORK=/tmp/go-build858282353
mkdir -p $WORK/runtime/internal/sys/_obj/
mkdir -p $WORK/runtime/internal/
cd /gnu/store/fgwh2q36s5rqyxdbs2sl6ybpyxbv5y14-go-1.9.3/src/runtime/internal/sys
/gnu/store/fgwh2q36s5rqyxdbs2sl6ybpyxbv5y14-go-1.9.3/pkg/tool/linux_amd64/compile
-o $WORK/runtime/internal/sys.a -trimpath $WORK -goversion go1.9.3 -p
runtime/internal/sys -std -+ -complete -buildid
817fb51b0d31bc187077c53e22d9b0fe9df62e9d -D
_/gnu/store/fgwh2q36s5rqyxdbs2sl6ybpyxbv5y14-go-1.9.3/src/runtime/internal/sys
-I $WORK -pack ./arch.go ./arch_amd64.go ./intrinsics.go ./stubs.go
./sys.go ./zgoarch_amd64.go ./zgoos_linux.go ./zversion.go
mkdir -p /gnu/store/fgwh2q36s5rqyxdbs2sl6ybpyxbv5y14-go-1.9.3/pkg/linux_amd64/runtime/internal/
cp $WORK/runtime/internal/sys.a
/gnu/store/fgwh2q36s5rqyxdbs2sl6ybpyxbv5y14-go-1.9.3/pkg/linux_amd64/runtime/internal/sys.a
go install runtime/internal/sys: open
/gnu/store/fgwh2q36s5rqyxdbs2sl6ybpyxbv5y14-go-1.9.3/pkg/linux_amd64/runtime/internal/sys.a:
read-only file system

so to me it looks like it wants to compile stuff in the store, but why
is that? shouldn't it be compiled by default?

So my question is: Is there a way to prevent 'go install' compiling
things in the store, maybe by pre-compiling during installation of the
go package? Or is there another preferred way to develop go
applications on guix, since what i do now is 'go build', but that gets
really slow with larger projects, at it recompiles everything
everytime if i understand it right.

Cheers,
Peter Mikkelsen

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

* bug#30287: Go compiler tries writing to the store
  2018-01-29  9:50 Developing golang programs on guix Peter Mikkelsen
@ 2018-01-29 21:39 ` Leo Famulari
  2021-07-03 22:35   ` Sarah Morgensen via Bug reports for GNU Guix
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Famulari @ 2018-01-29 21:39 UTC (permalink / raw)
  To: Peter Mikkelsen; +Cc: 30287

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

On Mon, Jan 29, 2018 at 10:50:10AM +0100, Peter Mikkelsen wrote:
> Hi guix,

Hi, thanks for this report! I saw your brief conversation on #guix with
civodul. Unfortunately I've only been paying attention to packaging Go
software with Guix, so I didn't notice this issue.

> For example, after setting the environment variable GOPATH to
> /home/peter/go, and creating a small hello world program in there, I
> would normally be able to run 'go install' in that folder, and the
> hello world binary would end up in my gopath. But on guixSD this is
> not the case, since it seems like 'go install' is trying to compile
> every single library provided by to go package itself, and that means
> writing to the store, which is not possible.

This is definitely a problem that we need to fix. However, I'm not sure
where to start...

I'll try debugging by checking if this works on Nix, and seeing what
they do differently.

> So my question is: Is there a way to prevent 'go install' compiling
> things in the store, maybe by pre-compiling during installation of the
> go package? Or is there another preferred way to develop go
> applications on guix, since what i do now is 'go build', but that gets
> really slow with larger projects, at it recompiles everything
> everytime if i understand it right.

The compiler should never try to write to the store; something is wrong
with how we build it.

Changing the subject slightly, yes, `go build` always recompiles some
things:

In general, for Go libraries (they call them "packages"), `go build`
always discards the compiled objects. You have to use `go install` to
retain them and achieve a caching speedup.

For Go executable programs (called "commands"), `go build` does keep the
compiled executable.

To quote the docs [0]:

"Build compiles the packages named by the import paths, along with their
dependencies, but it does not install the results. [...] When compiling
multiple packages or a single non-main package, build compiles the
packages but discards the resulting object, serving only as a check that
the packages can be built."

https://golang.org/cmd/go/

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

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

* bug#30287: Go compiler tries writing to the store
  2018-01-29 21:39 ` bug#30287: Go compiler tries writing to the store Leo Famulari
@ 2021-07-03 22:35   ` Sarah Morgensen via Bug reports for GNU Guix
  2021-07-25  0:17     ` Sarah Morgensen
  0 siblings, 1 reply; 4+ messages in thread
From: Sarah Morgensen via Bug reports for GNU Guix @ 2021-07-03 22:35 UTC (permalink / raw)
  To: Leo Famulari; +Cc: 30287, Peter Mikkelsen

Hello,

Looking through old Go bugs I found this. Is this still an issue for
anyone? I just tested with go@1.14 and go@1.16 and I got expected
behavior (binary was installed in ~/go/bin, since ~/go is the default
GOPATH).

Leo Famulari <leo@famulari.name> writes:

> On Mon, Jan 29, 2018 at 10:50:10AM +0100, Peter Mikkelsen wrote:
>> Hi guix,
>
> Hi, thanks for this report! I saw your brief conversation on #guix with
> civodul. Unfortunately I've only been paying attention to packaging Go
> software with Guix, so I didn't notice this issue.
>
>> For example, after setting the environment variable GOPATH to
>> /home/peter/go, and creating a small hello world program in there, I
>> would normally be able to run 'go install' in that folder, and the
>> hello world binary would end up in my gopath. But on guixSD this is
>> not the case, since it seems like 'go install' is trying to compile
>> every single library provided by to go package itself, and that means
>> writing to the store, which is not possible.

--
Sarah




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

* bug#30287: Go compiler tries writing to the store
  2021-07-03 22:35   ` Sarah Morgensen via Bug reports for GNU Guix
@ 2021-07-25  0:17     ` Sarah Morgensen
  0 siblings, 0 replies; 4+ messages in thread
From: Sarah Morgensen @ 2021-07-25  0:17 UTC (permalink / raw)
  To: Leo Famulari; +Cc: 30287-done, Peter Mikkelsen

Closing this as it seems this is no longer an issue with the go versions
currently packaged.

Sarah Morgensen <iskarian@mgsn.dev> writes:

> Hello,
>
> Looking through old Go bugs I found this. Is this still an issue for
> anyone? I just tested with go@1.14 and go@1.16 and I got expected
> behavior (binary was installed in ~/go/bin, since ~/go is the default
> GOPATH).
>
> Leo Famulari <leo@famulari.name> writes:
>
>> On Mon, Jan 29, 2018 at 10:50:10AM +0100, Peter Mikkelsen wrote:
>>> Hi guix,
>>
>> Hi, thanks for this report! I saw your brief conversation on #guix with
>> civodul. Unfortunately I've only been paying attention to packaging Go
>> software with Guix, so I didn't notice this issue.
>>
>>> For example, after setting the environment variable GOPATH to
>>> /home/peter/go, and creating a small hello world program in there, I
>>> would normally be able to run 'go install' in that folder, and the
>>> hello world binary would end up in my gopath. But on guixSD this is
>>> not the case, since it seems like 'go install' is trying to compile
>>> every single library provided by to go package itself, and that means
>>> writing to the store, which is not possible.
>
> --
> Sarah




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

end of thread, other threads:[~2021-07-25  0:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-29  9:50 Developing golang programs on guix Peter Mikkelsen
2018-01-29 21:39 ` bug#30287: Go compiler tries writing to the store Leo Famulari
2021-07-03 22:35   ` Sarah Morgensen via Bug reports for GNU Guix
2021-07-25  0:17     ` Sarah Morgensen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.