Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/8c: use of prefetchnta requires SSE #4798

Closed
gopherbot opened this issue Feb 13, 2013 · 11 comments
Closed

cmd/8c: use of prefetchnta requires SSE #4798

gopherbot opened this issue Feb 13, 2013 · 11 comments
Milestone

Comments

@gopherbot
Copy link

by huseby@lindenlab.com:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. hg clone https://code.google.com/p/go
2. cd go/src
3. ./make.bash

What is the expected output?
The usual compilation output.

What do you see instead?
cmd/go
./make.bash: line 129: 29855 Illegal instruction     (core dumped)
"$GOTOOLDIR"/go_bootstrap clean -i std

Which compiler are you using (5g, 6g, 8g, gccgo)?
N/A

Which operating system are you using?
OpenBSD 5.2

Which version are you using?  (run 'go version')
hg tip

Please provide any additional information below.
My computer is a Soekris net4801 (386) with 64MB of RAM and 2GB of swap.  I followed the
instructions on the wiki for increasing the limits set in login.conf.  This sounds like
a quirk of the 233 Mhz NSC SC1100 CPU in this machine.  Core file attached.  My guess
would be that despite the GOARCH being set to 386, there is a 686 instruction being
executed.

Attachments:

  1. go_bootstrap.core (4576016 bytes)
@gopherbot
Copy link
Author

Comment 1 by huseby@lindenlab.com:

I just confirmed that the problem is a prefetchnta instruction in go_bootstrap:
(gdb) run
Starting program: /home/mannie/Projects/go/pkg/tool/openbsd_386/go_bootstrap clean -i std
Program received signal SIGILL, Illegal instruction.
0x0808fc1b in ?? ()
(gdb) x/i $pc
0x808fc1b:      prefetchnta (%eax)
Not sure why/where/how this is getting generated when compiling go_bootstrap.

@davecheney
Copy link
Contributor

Comment 2:

@huseby, the error is happening running go_bootstrap, not compiling it. The build
process builds the compilers, then the a small version of the go tool, go_bootstrap is
built by hand, which is then used to produce the full go tool.
To date, we don't have an openbsd/386 builder, so I'm not surprised that it ran into
problems. When goarch says 386, it means 'not amd64' not 80386, the minimum requirements
for 32bit intel architecture is a Pentium with MMX.
+cc jsing

Labels changed: added os-openbsd.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 3:

Uh oh, do I see GO386=386 coming on, like GOARM=5?

@gopherbot
Copy link
Author

Comment 4 by huseby@lindenlab.com:

Yes, the error is in running go_bootstrap.  It is trying to execute PREFETCHNTA which is
an SSE instruction that the Geode processor doesn't support.
I was able to fix this with an ugly hack.  I just commented out the body of the
gprefetch function in 8c/txt.c to prevent 8c from generating that instruction.  Since
the prefetch instruction is just there to speed things up and shouldn't change the
correctness of the executable, this should work and it does.

@minux
Copy link
Member

minux commented Feb 13, 2013

Comment 5:

what does the following command say?
sysctl machdep.cpufeature
does it have 0x00000100 bit (CMPXCHG8B) and 0x00800000 bit (MMX) set?
the definition for bits is in:
http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/i386/include/specialreg.h?rev=1.44;content-type=text%2Fplain
@dave cheney, because of usage of prefetchnta, we have to raise the requirement of 386
from pentium mmx to sse.
the change is introduced in rev 455b7576cd25 (not included in release yet).
do we want to keep support for pentium mmx class machine and drop PREFETCH support 386
or make its use depend
on GO386 setting or just document 386 port requires SSE now?
FYI, pentium 3 introduced SSE while pentium 4 introduced SSE2.

Labels changed: added priority-later, removed priority-triage, os-openbsd.

Status changed to Thinking.

@minux
Copy link
Member

minux commented Feb 13, 2013

Comment 6:

because we've already introduced GO386, we can introduce one more possible value
for it: sse.
switch GO386 {
case "387": //use x87 FPU and only assume pentium MMX
case "sse":  //use x87 FPU and enable PREFETCH support
case "sse2": fallthrough
default: // use SSE2 for FPU and enable PREFETCH support
}
what do you think? IMHO, the point of supporting 386 port is just to make Go usable on
(17-year) old machines.

@gopherbot
Copy link
Author

Comment 7 by huseby@lindenlab.com:

On my machine, I'm getting the value 0x00808131 from the machdep.cpufeature.  So yes,
both CMPXCHG8B and MMX are set.
I like the idea of being able to set GO386=387 and have it assume pentium MMX.  There
are lots of embedded x86 machines that happily run *BSD/Linux but won't run go without
that change.

@rsc
Copy link
Contributor

rsc commented Feb 13, 2013

Comment 8:

I would prefer not to introduce another setting. We can disable PREFETCH on
non-sse2 machines.

@gopherbot
Copy link
Author

Comment 9 by huseby@lindenlab.com:

Doesn't the GO386 environment variable already exist?  It just defaults to 387/sse which
ATM includes the prefetch support.  Why couldn't those be separated?

@gopherbot
Copy link
Author

Comment 10 by huseby@lindenlab.com:

It worked for the GOARM setting.  If you changed the default of GO386 to be "sse" then
nothing would change for default invocations.  For those of us with older machines we'd
have to set GO386=387 like setting GOARM=5 to get go to compile on a Raspberry Pi.
Thanks for taking a look at this though.

@rsc
Copy link
Contributor

rsc commented Feb 14, 2013

Comment 11:

This issue was closed by revision 594360c.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants