Ah, I see now, sorry for not noticing that. My understanding then is that cmd/dist first builds for the host here <https://go.googlesource.com/go/+/refs/tags/go1.19/src/cmd/dist/build.go#1411> (in my case, for Linux) and then builds for the target starting here <https://go.googlesource.com/go/+/refs/tags/go1.19/src/cmd/dist/build.go#1432>. 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 <skull...@gmail.com> 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 >> <https://pubs.opengroup.org/onlinepubs/9699919799/idx/functions.html>, >> and POSIX only has a setregid() >> <https://pubs.opengroup.org/onlinepubs/9699919799/functions/setregid.html> >> function, >> and not a setresgid() <https://linux.die.net/man/2/setresgid> function. >> >> And >> > make.bash runs go build with the GOOS and GOARCH set to empty strings >> here >> <https://go.googlesource.com/go/+/refs/tags/go1.19/src/make.bash#201>. >> >> 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 >> >> <https://groups.google.com/d/msgid/golang-nuts/ab7f958c-e662-4f2e-a4ed-ef0426c174dcn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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.