Repository: go
Issue: x/sys: does not build on linux/sparc64, stuck on porting attempt
Labels: NeedsInvestigation

<!--
Please answer these questions before submitting your issue. Thanks!
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version unknown linux/sparc64
$ gcc --version
gcc 12.2.0
</pre>

### Does this issue reproduce with the latest release?
Yes on git master branch


### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="sparc64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT="fieldtrack"
GOFLAGS=""
GOHOSTARCH="sparc64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/libexec/gcc/sparc64-unknown-linux-gnu/12.2.0"
GOVCS=""
GOVERSION="unknown"                                                                                                                                    
GCCGO="/usr/sparc64-unknown-linux-gnu/gcc-bin/12.2.0/gccgo"                                                                                            
AR="ar"                                                                                                                                                
CC="gcc"                                                                                                                                               
CXX="g++"                                                                                                                                              
CGO_ENABLED="1"                                                                                                                                        
GOMOD="/var/tmp/tmp/sys-sparc64/go.mod"                                                                                                                
GOWORK=""                                                                                                                                              
CGO_CFLAGS="-g -O2"                                                                                                                                    
CGO_CPPFLAGS=""                                                                                                                                        
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build878311104=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
</pre></details>

### What did you do?

Running with no changes, I get:
```
golang.org/x/sys/cpu
golang.org/x/sys/unix
# golang.org/x/sys/cpu
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20200615200032-f1bc736245b1/cpu/cpu.go:17:30: error: reference to undefined name ‘cacheLineSize’
   17 | type CacheLinePad struct{ _ [cacheLineSize]byte }
      |                              ^
github.com/matrix-org/dendrite/cmd/kafka-producer
# golang.org/x/sys/unix
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20200615200032-f1bc736245b1/unix/dirent.go:16:12: error: reference to undefined name ‘isBigEndian’
   16 |         if isBigEndian {
      |            ^
```

After [this commit](https://github.com/golang/sys/compare/master...Richard-Rogalski:sys-sparc64:master), and trying to write `unix/asm_linux_sparc64.s`(started with just copying over loong64's), I get this error:

```
# golang.org/x/sys/unix
unix/asm_linux_sparc64.s:9:10: fatal error: textflag.h: No such file or directory
    9 | #include "textflag.h"
      |          ^~~~~~~~~~~~
compilation terminated.
```

I assume this is why there was a `gc` requirement. On sparc64, gccgo is the only option.

So, how would I get an assembly file compileable with gccgo? Is there a way to make it work with `textflag.h`, or a way to make it work without it?

Thanks for your time, I am really excited about getting x/sys running on my sparcbox, and hopefully soon everyone elses =^D