Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 558368 - dev-lang/go-1.5: failed to build on OS X
Summary: dev-lang/go-1.5: failed to build on OS X
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-21 22:05 UTC by yegle
Modified: 2016-01-15 18:47 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
go-macos-sysctl.patch (go-macos-sysctl.patch,484 bytes, patch)
2015-10-21 15:41 UTC, yegle
Details | Diff
go-1.5.1.ebuild (go-1.5.1.ebuild,5.08 KB, text/plain)
2015-10-21 15:42 UTC, yegle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yegle 2015-08-21 22:05:24 UTC
Looking at the ebuild it looks like the GOHOSTARCH was set to x64-macos where it should be amd64.

Also it seems like the script will use /usr/sbin/sysctl to get the system architecture information https://golang.org/src/cmd/dist/util.go#L407 and this binary is not in PATH during emerge.

Reproducible: Always
Comment 1 yegle 2015-10-09 20:01:25 UTC
Ping on this?

I have a dirty workaround on this if someone wants to review it.
Comment 2 yegle 2015-10-21 15:41:30 UTC
Created attachment 415100 [details, diff]
go-macos-sysctl.patch
Comment 3 yegle 2015-10-21 15:42:00 UTC
Created attachment 415102 [details]
go-1.5.1.ebuild
Comment 4 Fabian Groffen gentoo-dev 2015-11-02 19:27:04 UTC
I applied this stuff, thanks!
Comment 5 William Hubbs gentoo-dev 2015-11-22 16:18:09 UTC
All, I just came across this bug.
Comment #1 states that this is a dirty workaround, and I agree.
The better fix is to figure out why /usr/bin is not in the path and fix
that issue.
Comment 6 Fabian Groffen gentoo-dev 2015-11-22 18:10:55 UTC
/usr/sbin is not in the path because this is Prefix.  Also outside of prefix, it isn't expected that non-root users have /usr/sbin in PATH.

So, not sure what you plan on doing on this.  The fix I applied is the right one (give that Gentoo only does Prefix for OSX).
Comment 7 William Hubbs gentoo-dev 2015-11-23 15:39:14 UTC
(In reply to Fabian Groffen from comment #6)
> /usr/sbin is not in the path because this is Prefix.  Also outside of
> prefix, it isn't expected that non-root users have /usr/sbin in PATH.
> 
> So, not sure what you plan on doing on this.  The fix I applied is the right
> one (give that Gentoo only does Prefix for OSX).

Outside of Prefix, /usr/sbin will always be in the path during emerge, because emerge always runs as root. If a user were going to install go as a user package outside of prefix, the user would use the upstream installation instructions, e.g. the installation would go in /home/<username>/go [1].

I'm not sure what I'm going to do yet, but basically I would rather not hard code paths to binaries because of something that Gentoo specifically does with the path, e.g. I think most distros have /usr/sbin in the path for everyone, and there really is no compelling reason not to do that.

I'll probably end up bringing this to the list if you do not see another way to handle it.

[1] https://golang.org/doc/install/source
Comment 8 Fabian Groffen gentoo-dev 2015-11-23 15:47:17 UTC
(In reply to William Hubbs from comment #7)
> (In reply to Fabian Groffen from comment #6)
> > /usr/sbin is not in the path because this is Prefix.  Also outside of
> > prefix, it isn't expected that non-root users have /usr/sbin in PATH.
> > 
> > So, not sure what you plan on doing on this.  The fix I applied is the right
> > one (give that Gentoo only does Prefix for OSX).
> 
> Outside of Prefix, /usr/sbin will always be in the path during emerge,
> because emerge always runs as root. If a user were going to install go as a
> user package outside of prefix, the user would use the upstream installation
> instructions, e.g. the installation would go in /home/<username>/go [1].

I think you miss the point of Prefix here.  It runs unprivileged, in a location other than /.

That said, if you're really that concerned about this (Python as opposed to Golang does this all-over for example) I suggest we try to find consensus which is beneficial for both of our users.  As I understand the situation right now:
- none of your users are affected in any way by my patch
- prefix users on OSX can enjoy golang from Gentoo
- the maintenance of this patch is fully up to me, and will never block you
Comment 9 Fabian Groffen gentoo-dev 2015-11-23 15:48:48 UTC
(In reply to William Hubbs from comment #7)
> I'm not sure what I'm going to do yet, but basically I would rather not hard
> code paths to binaries because of something that Gentoo specifically does
> with the path, e.g. I think most distros have /usr/sbin in the path for
> everyone, and there really is no compelling reason not to do that.

Even Gentoo doesn't add /usr/sbin to the path of users, so I'm not sure what you're aiming at here.
Comment 10 William Hubbs gentoo-dev 2015-11-23 17:19:25 UTC
(In reply to Fabian Groffen from comment #9)
> (In reply to William Hubbs from comment #7)
> > I'm not sure what I'm going to do yet, but basically I would rather not hard
> > code paths to binaries because of something that Gentoo specifically does
> > with the path, e.g. I think most distros have /usr/sbin in the path for
> > everyone, and there really is no compelling reason not to do that.
> 
> Even Gentoo doesn't add /usr/sbin to the path of users, so I'm not sure what
> you're aiming at here.

As I said, I think we should fix PATH, even in Gentoo, as opposed to hard coding paths to binaries in software. I don't see a compelling reason to not have /sbin and /usr/sbin in the path for everyone. After all, as far as I know, we are the only distro I'm aware of that goes out of our way to remove these from the path for users.
Comment 11 Mike Gilbert gentoo-dev 2015-11-23 17:19:45 UTC
sysctl doesn't belong in sbin if it can/should be utilized by normal users. That's likely historical baggage: the binary has always been in sbin.

I'm guessing it would be relatively difficult to convince Apple to move it to bin.

Given that constraint, using the full path to the binary seems like a reasonable workaround.
Comment 12 William Hubbs gentoo-dev 2015-11-23 17:28:25 UTC
(In reply to Mike Gilbert from comment #11)
> sysctl doesn't belong in sbin if it can/should be utilized by normal users.
> That's likely historical baggage: the binary has always been in sbin.
> 
> I'm guessing it would be relatively difficult to convince Apple to move it
> to bin.
> 
> Given that constraint, using the full path to the binary seems like a
> reasonable workaround.

@floppym:
I suspect that Prefix is doing the same thing we are in Gentoo, going out of our way to remove /sbin and /usr/sbin from the path for non-privileged users, which really there is no reason to do, and I've never seen another distro do that. I suspect that even on native OSx, /sbin and /usr/sbin are not removed from the path for a normal user.
Comment 13 Austin English (RETIRED) gentoo-dev 2015-11-23 18:40:15 UTC
(In reply to William Hubbs from comment #12)
> (In reply to Mike Gilbert from comment #11)
> > sysctl doesn't belong in sbin if it can/should be utilized by normal users.
> > That's likely historical baggage: the binary has always been in sbin.
> > 
> > I'm guessing it would be relatively difficult to convince Apple to move it
> > to bin.
> > 
> > Given that constraint, using the full path to the binary seems like a
> > reasonable workaround.
> 
> @floppym:
> I suspect that Prefix is doing the same thing we are in Gentoo, going out of
> our way to remove /sbin and /usr/sbin from the path for non-privileged
> users, which really there is no reason to do, and I've never seen another
> distro do that. I suspect that even on native OSx, /sbin and /usr/sbin are
> not removed from the path for a normal user.

Native OSX does not:
Austins-Mac-mini:~ austin$ uname -a
Darwin Austins-Mac-mini.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep  1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64

Austins-Mac-mini:~ austin$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin


but Debian (unstable) does remove it:
austin@debian-laptop:~$ uname -a
Linux debian-laptop 4.2.0-1-amd64 #1 SMP Debian 4.2.3-2 (2015-10-14) x86_64 GNU/Linux

austin@debian-laptop:~$ cat /etc/issue
Debian GNU/Linux stretch/sid \n \l

austin@debian-laptop:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Comment 14 William Hubbs gentoo-dev 2015-11-23 19:29:32 UTC
(In reply to austinenglish@gmail.com from comment #13)
> (In reply to William Hubbs from comment #12)
> > (In reply to Mike Gilbert from comment #11)
> > > sysctl doesn't belong in sbin if it can/should be utilized by normal users.
> > > That's likely historical baggage: the binary has always been in sbin.
> > > 
> > > I'm guessing it would be relatively difficult to convince Apple to move it
> > > to bin.
> > > 
> > > Given that constraint, using the full path to the binary seems like a
> > > reasonable workaround.
> > 
> > @floppym:
> > I suspect that Prefix is doing the same thing we are in Gentoo, going out of
> > our way to remove /sbin and /usr/sbin from the path for non-privileged
> > users, which really there is no reason to do, and I've never seen another
> > distro do that. I suspect that even on native OSx, /sbin and /usr/sbin are
> > not removed from the path for a normal user.
> 
> Native OSX does not:
> Austins-Mac-mini:~ austin$ uname -a
> Darwin Austins-Mac-mini.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 
> 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64
> 
> Austins-Mac-mini:~ austin$ echo $PATH
> /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

This is what I was mostly interested in. OSx doesn't remove *sbin from a users path, so I see this as an issue with PATH that should be fixed rather than hard coding the path to the sysctl binary.

> 
> but Debian (unstable) does remove it:
> austin@debian-laptop:~$ uname -a
> Linux debian-laptop 4.2.0-1-amd64 #1 SMP Debian 4.2.3-2 (2015-10-14) x86_64
> GNU/Linux
> 
> austin@debian-laptop:~$ cat /etc/issue
> Debian GNU/Linux stretch/sid \n \l
> 
> austin@debian-laptop:~$ echo $PATH
> /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

This is interesting that Debian unstable is removing *sbin from the user's path, but I don't think it affects this bug.
Comment 15 William Hubbs gentoo-dev 2015-11-23 19:55:25 UTC
(In reply to William Hubbs from comment #14)
> (In reply to austinenglish@gmail.com from comment #13)
> > (In reply to William Hubbs from comment #12)
> > > (In reply to Mike Gilbert from comment #11)
> > > > sysctl doesn't belong in sbin if it can/should be utilized by normal users.
> > > > That's likely historical baggage: the binary has always been in sbin.
> > > > 
> > > > I'm guessing it would be relatively difficult to convince Apple to move it
> > > > to bin.
> > > > 
> > > > Given that constraint, using the full path to the binary seems like a
> > > > reasonable workaround.
> > > 
> > > @floppym:
> > > I suspect that Prefix is doing the same thing we are in Gentoo, going out of
> > > our way to remove /sbin and /usr/sbin from the path for non-privileged
> > > users, which really there is no reason to do, and I've never seen another
> > > distro do that. I suspect that even on native OSx, /sbin and /usr/sbin are
> > > not removed from the path for a normal user.
> > 
> > Native OSX does not:
> > Austins-Mac-mini:~ austin$ uname -a
> > Darwin Austins-Mac-mini.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 
> > 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64
> > 
> > Austins-Mac-mini:~ austin$ echo $PATH
> > /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
> 
> This is what I was mostly interested in. OSx doesn't remove *sbin from a
> users path, so I see this as an issue with PATH that should be fixed rather
> than hard coding the path to the sysctl binary.

Or, it could be argued that using sysctl is flawed, so if possible, come up with another test that uses a binary in that is not located in /usr/sbin.
Comment 16 Austin English (RETIRED) gentoo-dev 2015-11-24 17:00:19 UTC
(In reply to William Hubbs from comment #14)
> (In reply to austinenglish@gmail.com from comment #13)
> > but Debian (unstable) does remove it:
> > austin@debian-laptop:~$ uname -a
> > Linux debian-laptop 4.2.0-1-amd64 #1 SMP Debian 4.2.3-2 (2015-10-14) x86_64
> > GNU/Linux
> > 
> > austin@debian-laptop:~$ cat /etc/issue
> > Debian GNU/Linux stretch/sid \n \l
> > 
> > austin@debian-laptop:~$ echo $PATH
> > /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
> 
> This is interesting that Debian unstable is removing *sbin from the user's
> path, but I don't think it affects this bug.

Sure. I included it as an extra data point, I assume most people on b.g.o mostly only have access to Gentoo machines ;)
Comment 17 Fabian Groffen gentoo-dev 2015-11-25 20:40:12 UTC
Looking at this in detail, for Gentoo Prefix this patch is wrong for it assumes 64-bits world even on a 32-bits userland/binary.  The whole /usr/sbin/sysctl point is moot.  I understand upstream had an issue figuring this out, but basically this should be a compile time setting such that the binary matches what it wants to produce, regardless machine it runs on.
Comment 18 William Hubbs gentoo-dev 2015-11-27 19:54:15 UTC
Based on comment #17, I am removing this patch. Is this an issue
to address Upstream, or is it something we can fix in the ebuild without
patching the code?
Comment 19 Fabian Groffen gentoo-dev 2015-11-28 12:02:31 UTC
If you insist on breaking Go for OSX, go ahead.

As it looks, no we can't fix it without patching the code.  We can conditionalise it for Darwin if that makes you feel better about it, though.
Comment 20 William Hubbs gentoo-dev 2015-11-28 14:10:53 UTC
In Gentoo, we are discussing adding the sbin directories to the path for
all users, and as Austin pointed out above, the sbin directories are in
the path for all users, privileged or not, on native OSx.

Is there any way you would consider doing that on prefix?
Comment 21 Fabian Groffen gentoo-dev 2015-11-28 16:02:49 UTC
If Gentoo mainline does it, we will follow.  It is irrelevant to this bug, however.

Portage itself re-sets PATH, so whatever the shell does, it doesn't care (for good reasons).
In Prefix, we currently do NOT include sbin from the host-OS, to do that we need to update Portage ebuild for it simply doesn't pass these onto configure.
Comment 22 Ruud Koolen (RETIRED) archtester gentoo-dev Security 2015-11-29 19:03:38 UTC
(In reply to Fabian Groffen from comment #17)
> Looking at this in detail, for Gentoo Prefix this patch is wrong for it
> assumes 64-bits world even on a 32-bits userland/binary.  The whole
> /usr/sbin/sysctl point is moot.  I understand upstream had an issue figuring
> this out, but basically this should be a compile time setting such that the
> binary matches what it wants to produce, regardless machine it runs on.

It is. The util.go code is the fallback autodetect code; its output gets overridden later by the envvars. The only thing that matters is that the build script can find a sysctl binary at all, it doesn't even matter what output it spits out. Thus, yegle's patch should do fine.
Comment 23 William Hubbs gentoo-dev 2015-11-29 20:36:48 UTC
@grobian:
I'm not interested in breaking things for OSx; I am interested in a
patch that could be sold upstream, and I think this patch is going to be
hard to sell.

What exactly is sysctl being used for on OSx? Is there a better way it
could be done that doesn't use sysctl?
Comment 24 William Hubbs gentoo-dev 2016-01-15 18:47:06 UTC
I have applied a version of the upstream patch to dev-lang/go-1.5.3.
This should resolve the issue.

Thanks,

William