[go-nuts] Re: Changes in the language/ Compile Go

2022-08-27 Thread ramki...@hotmail.com
Think I found it here https://go.dev/doc/install/source 

On Saturday, August 27, 2022 at 5:28:50 PM UTC-4 ramki...@hotmail.com wrote:

> I wanted to make changes to golang io package. If I fork golang from 
> github (https://github.com/golang/go) and make the changes, how do I 
> access these changes in my go project?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/51aa45e2-6159-4836-bd5b-138f3c7187den%40googlegroups.com.


[go-nuts] Changes in the language/ Compile Go

2022-08-27 Thread ramki...@hotmail.com
I wanted to make changes to golang io package. If I fork golang from github 
(https://github.com/golang/go) and make the changes, how do I access these 
changes in my go project?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4a505693-9d0f-4743-90f2-3a99b86b0d91n%40googlegroups.com.


[go-nuts] Re: abort assembly code profile

2022-08-27 Thread 'Keith Randall' via golang-nuts
For #1, that is https://github.com/golang/go/issues/15808

For #2, the Go compiler is generally not great at optimizing arrays, 
particularly copies of them (in your case, from ret to the return slot). I 
would recommend using either slices ([]int) or structs (struct {x, y int}), 
or even pointer to array (*[2]int).

On Friday, August 26, 2022 at 1:02:03 AM UTC-7 sydnash wrote:

> I have some golang code like this:
>
> ```golang
> type C [2]int
>
> //go:noinline
> func t1(a, b C) C {
> var ret C
> for i := 0; i < len(a); i++ {
> ret[i] = a[i] + b[i]
> }
> return ret
> }
>
> //go:noinline
> func t2(a, b C) C {
> return t1(a, b)
> }
> ```
>
> and build with command: go build main.go
>
> then i use objdump -d main to check the output assembly code, it like this:
>
> ```golang
> 000100086b40 <_main.t1>:
> 100086b40: fe 0f 1e f8  str x30, [sp, #-32]!
> 100086b44: fd 83 1f f8  sturx29, [sp, #-8]
> 100086b48: fd 23 00 d1  sub x29, sp, #8
> 100086b4c: ff ff 04 a9  stp xzr, xzr, [sp, #72]
> 100086b50: ff ff 00 a9  stp xzr, xzr, [sp, #8]
> 100086b54: 00 00 80 d2  mov x0, #0
> 100086b58: 09 00 00 14  b   0x100086b7c <_main.t1+0x3c>
> 100086b5c: e1 a3 00 91  add x1, sp, #40
> 100086b60: 22 78 60 f8  ldr x2, [x1, x0, lsl #3]
> 100086b64: e3 e3 00 91  add x3, sp, #56
> 100086b68: 64 78 60 f8  ldr x4, [x3, x0, lsl #3]
> 100086b6c: 42 00 04 8b  add x2, x2, x4
> 100086b70: e4 23 00 91  add x4, sp, #8
> 100086b74: 82 78 20 f8  str x2, [x4, x0, lsl #3]
> 100086b78: 00 04 00 91  add x0, x0, #1
> 100086b7c: 1f 08 00 f1  cmp x0, #2
> 100086b80: eb fe ff 54  b.lt0x100086b5c <_main.t1+0x1c>
> 100086b84: e0 07 40 f9  ldr x0, [sp, #8]
> 100086b88: e1 0b 40 f9  ldr x1, [sp, #16]
> 100086b8c: e0 27 00 f9  str x0, [sp, #72]
> 100086b90: e1 2b 00 f9  str x1, [sp, #80]
> 100086b94: ff 83 00 91  add sp, sp, #32
> 100086b98: fd 23 00 d1  sub x29, sp, #8
> 100086b9c: c0 03 5f d6  ret
> ```
> I think the above assembly code is not optimal。
>
> 1. the register value of x1,x3 can be compute out side of the loop.
> 2.  store the result directly to [sp, #72], and [sp, #80], the temporary 
> data in [sp, #8] and [sp, #16] not necessary.
>
> i want to know why the compiler couldn't do the optimize, or which command 
> cat go more optimized code.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3d4bfed3-b71f-4abe-a6d9-2c05e9c8b1a9n%40googlegroups.com.


Re: [go-nuts] go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

2022-08-27 Thread Ian Lance Taylor
On Sat, Aug 27, 2022 at 12:06 PM Lonnie TC  wrote:
>
> I hope that everyone is doing well today.
> I am working on a Golang project to port go-pmem over to MSYS2 using MinGW 64:
>
> https://github.com/jerrinsg/go-pmem
>
> In trying to build the patched Go distro toolchain, I am getting some strange 
> error in the build that I do not know how to handle and am hoping that 
> someone can answer this for me.
>
> go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT
>
> any help would be truly appreciate.

I don't know what go-pmem is, but a Go distribution should have a file
$GOROOT/VERSION that contains the version number of the release.  If
you download the sources of, say, the Go 1.19 release, you will see a
VERSION file.  For development purposes, if that VERSION file does not
exist, the Go build will pull the version from the git repo.  You seem
to have Go sources that are not in a git repo and also do not have a
VERSION file.  That setup is not expected or supported.  The simple
fix is to create your own VERSION file.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWnOY4EERFbEvLf5Orx1kMVTA97S5gB8Fz%3DNLXGTr-cUA%40mail.gmail.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Ian Lance Taylor
On Sat, Aug 27, 2022 at 12:15 PM Shane  wrote:
>
> My understanding then is that cmd/dist first builds for the host here (in my 
> case, for Linux) and then builds for the target starting here. Since there is 
> always a build for the host first, then since my host OS is Linux, the 
> linux_syscall.c is always part of the compilation (since I do not disable 
> cgo). If anything is incorrect with my understanding, please correct me.
>
> I believe then I need to have both Linux system headers and Solaris system 
> headers available on my build machine for the cross-compile, if I want to 
> build Go for Solaris with cgo support.
>
> Is it possible for there to be two header files with the same name but 
> different OS have the same #include path in the cgo source code? If so, could 
> the C compiler get the correct header for the target of the cgo? For example, 
> how could the C compiler know to use the Linux unistd.h header for the Linux 
> build, and later use the Solaris unistd.h header for the Solaris build?

I'm not sure whether this answers your question, but normally a system
will have a native compiler that will look for header files in
/usr/include.  It can also have a cross-compiler that looks for header
files in some other location.  A cross-compiler should never look in
/usr/include, it should only look at the cross-compilation header
files.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWgft7wLnAC-AOTePFve33zpz0%2Bugm%2Birk42XFhPpceDw%40mail.gmail.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
Ah, I see now, sorry for not noticing that.

My understanding then is that cmd/dist first builds for the host here 
 
(in my case, for Linux) and then builds for the target starting here 
. 
Since there is always a build for the host first, then since my host OS is 
Linux, the linux_syscall.c is always part of the compilation (since I do 
not disable cgo). If anything is incorrect with my understanding, please 
correct me.

I believe then I need to have both Linux system headers and Solaris system 
headers available on my build machine for the cross-compile, if I want to 
build Go for Solaris with cgo support.

Is it possible for there to be two header files with the same name but 
different OS have the same #include path in the cgo source code? If so, 
could the C compiler get the correct header for the target of the cgo? For 
example, how could the C compiler know to use the Linux unistd.h header for 
the Linux build, and later use the Solaris unistd.h header for the Solaris 
build?

On Saturday, August 27, 2022 at 2:59:31 PM UTC-4 se...@liao.dev wrote:

> make.bash calls cmd/dist which does the build chaining, calling it 
> directly doesn't skip the process.
>
> - sean
>
> On Sat, Aug 27, 2022, 19:54 Shane  wrote:
>
>> >  Is there some way I can skip straight to building Go for my Solaris 
>> target using my existing Linux Go tools?
>> Sorry, this question was foolish. Of course I can skip straight to 
>> building for Solaris, by using the make.bash script.
>>
>> But as I pointed out earlier,
>> > I looked at the POSIX docs 
>> , 
>> and POSIX only has a setregid() 
>>  
>> function, 
>> and not a setresgid()  function.
>>
>> And
>> >  make.bash runs go build with the GOOS and GOARCH set to empty strings 
>> here 
>> .
>>
>> Please correct me if I am wrong, but my assumption is that if GOOS was 
>> properly set to solaris by make.bash, then linux_syscall.c would not be 
>> compiled, and then I would not get the compiler error I am seeing.
>>
>> On Saturday, August 27, 2022 at 2:40:52 PM UTC-4 Shane wrote:
>>
>>> I already have a working Go 1.19 for Linux with cgo support on my build 
>>> machine that I downloaded and installed from https://go.dev. Given 
>>> this, is it still necessary to build for the host? Is there some way I can 
>>> skip straight to building Go for my Solaris target using my existing Linux 
>>> Go tools? Or if I do that, does that break the guarantee of a consistent 
>>> final artifact?
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/599210f2-ec20-4928-8d9c-89e1d56041b8n%40googlegroups.com.


[go-nuts] go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

2022-08-27 Thread Lonnie TC
Hi All,

I hope that everyone is doing well today.
I am working on a Golang project to port go-pmem over to MSYS2 using MinGW 
64:

https://github.com/jerrinsg/go-pmem

In trying to build the patched Go distro toolchain, I am getting some 
strange error in the build that I do not know how to handle and am hoping 
that someone can answer this for me.

go tool dist: FAILED: not a Git repo; must put a VERSION file in $GOROOT

any help would be truly appreciate.

Have a great day,
Lonnie



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/661c228c-d836-4f28-a558-e1c0ad5d2dfdn%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread 'Sean Liao' via golang-nuts
make.bash calls cmd/dist which does the build chaining, calling it directly
doesn't skip the process.

- sean

On Sat, Aug 27, 2022, 19:54 Shane  wrote:

> >  Is there some way I can skip straight to building Go for my Solaris
> target using my existing Linux Go tools?
> Sorry, this question was foolish. Of course I can skip straight to
> building for Solaris, by using the make.bash script.
>
> But as I pointed out earlier,
> > I looked at the POSIX docs
> ,
> and POSIX only has a setregid()
>  
> function,
> and not a setresgid()  function.
>
> And
> >  make.bash runs go build with the GOOS and GOARCH set to empty strings
> here 
> .
>
> Please correct me if I am wrong, but my assumption is that if GOOS was
> properly set to solaris by make.bash, then linux_syscall.c would not be
> compiled, and then I would not get the compiler error I am seeing.
>
> On Saturday, August 27, 2022 at 2:40:52 PM UTC-4 Shane wrote:
>
>> I already have a working Go 1.19 for Linux with cgo support on my build
>> machine that I downloaded and installed from https://go.dev. Given this,
>> is it still necessary to build for the host? Is there some way I can skip
>> straight to building Go for my Solaris target using my existing Linux Go
>> tools? Or if I do that, does that break the guarantee of a consistent final
>> artifact?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGabyPq-%3D6h3%2BDUi02aWbpPMoMrd5D6dVByoC%2BoqFK_8e_CHtw%40mail.gmail.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
>  Is there some way I can skip straight to building Go for my Solaris 
target using my existing Linux Go tools?
Sorry, this question was foolish. Of course I can skip straight to building 
for Solaris, by using the make.bash script.

But as I pointed out earlier,
> I looked at the POSIX docs 
, and 
POSIX only has a setregid() 
 
function, 
and not a setresgid()  function.

And
>  make.bash runs go build with the GOOS and GOARCH set to empty strings 
here .

Please correct me if I am wrong, but my assumption is that if GOOS was 
properly set to solaris by make.bash, then linux_syscall.c would not be 
compiled, and then I would not get the compiler error I am seeing.

On Saturday, August 27, 2022 at 2:40:52 PM UTC-4 Shane wrote:

> I already have a working Go 1.19 for Linux with cgo support on my build 
> machine that I downloaded and installed from https://go.dev. Given this, 
> is it still necessary to build for the host? Is there some way I can skip 
> straight to building Go for my Solaris target using my existing Linux Go 
> tools? Or if I do that, does that break the guarantee of a consistent final 
> artifact?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
I already have a working Go 1.19 for Linux with cgo support on my build 
machine that I downloaded and installed from https://go.dev. Given this, is 
it still necessary to build for the host? Is there some way I can skip 
straight to building Go for my Solaris target using my existing Linux Go 
tools? Or if I do that, does that break the guarantee of a consistent final 
artifact?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b8adfc70-db5c-48c1-b0d4-e0dd88e8382cn%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread 'Sean Liao' via golang-nuts
The bootstrap process is a chain of builds that each build the next stage,
to minimize any effects of the host system, in order to produce a
consistent final artifact.
Your builds are failing before it has successfully built the final host
stage, cross compiling hasn't come into the picture yet.
Where it fails is the (optional) cgo part, you'll want to fix that before
attempting to cross compile.

- sean

On Sat, Aug 27, 2022, 18:16 Shane  wrote:

> I noticed bootstrap.bash just calls make.bash here
> ,
> and make.bash runs go build with the GOOS and GOARCH set to empty strings
> here
> .
>
> Does this mean that whatever I set for GOOS when I run either
> boostrap.bash or make.bash is always ignored?
>
> On Saturday, August 27, 2022 at 12:53:48 PM UTC-4 Brian Candler wrote:
>
>> On Saturday, 27 August 2022 at 17:10:21 UTC+1 Shane wrote:
>>
>>> Is it expected that linux_syscall.c would be compiled when the GOOS
>>> environment variable is set to solaris?
>>
>>
>> I see the log output does include this line:
>>
>> Building packages and commands for host, linux/amd64.
>>
>> Although I'm not sure why it couldn't use the existing toolchain directly.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/d797bdf4-e0c8-4096-a54d-be792ed50a90n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGabyPptmrHBdtyFxsypaOqRGwKngDU6v3Yr1eTT3KWAGrr0Ug%40mail.gmail.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Shane
I noticed bootstrap.bash just calls make.bash here 
, 
and make.bash runs go build with the GOOS and GOARCH set to empty strings 
here .

Does this mean that whatever I set for GOOS when I run either boostrap.bash 
or make.bash is always ignored?

On Saturday, August 27, 2022 at 12:53:48 PM UTC-4 Brian Candler wrote:

> On Saturday, 27 August 2022 at 17:10:21 UTC+1 Shane wrote:
>
>> Is it expected that linux_syscall.c would be compiled when the GOOS 
>> environment variable is set to solaris?
>
>
> I see the log output does include this line:
>
> Building packages and commands for host, linux/amd64.
>
> Although I'm not sure why it couldn't use the existing toolchain directly.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d797bdf4-e0c8-4096-a54d-be792ed50a90n%40googlegroups.com.


Re: [go-nuts] How to cross-compile Go 1.19 compiler for Solaris 11 on Linux

2022-08-27 Thread Brian Candler
On Saturday, 27 August 2022 at 17:10:21 UTC+1 Shane wrote:

> Is it expected that linux_syscall.c would be compiled when the GOOS 
> environment variable is set to solaris?


I see the log output does include this line:

Building packages and commands for host, linux/amd64.

Although I'm not sure why it couldn't use the existing toolchain directly.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/74a1cbff-96df-4e99-840c-21219173255bn%40googlegroups.com.