#Manual use of "compile" + "link" for hello world

5 messages · Page 1 of 1 (latest)

trim field
#

Hi, Im a go newbie and I wanted to get a good grasp of the go tooling.

I wanted to compile the hello world program without the use of go build but a combination of go tool compile + go tool link
I find very few information online about this so I was hoping to get some help here.

I successfully compiled hello.go after running go build -o fmt.a fmt in GOROOT/src and moving the .a into GOROOT/pkg/GOOS_GOARCH/
Then when trying to link I was met with missing .o errors so I repeated the process for every module inside GOROOT/src until the error was regarding unicode/utf8.o
I tried doing the same step for the utf8 module and put it in a unicode subdirectory but not only did the error remain but I also thought this was not the right approach if I had to manually build every module and submodule.

Has anyone successfully done this before ?

split junco
#

Hey you can check go build -a -x hello.go ||or go build -a -v -x hello.go I don't remember if you need -v or not|| it will show you all the commands go build runs to build hello.go

#

there is a very strict build order to bootstrap the std due to the runtime being heavily intertwined

#

tbh I don't see many people attempting this, it's very pointless in itself, unless you work on go itself you never and I do really mean never need to manually do this,

there is a tool to generate bazel build files if you need a more complex build process ||(I don't actually recommend you use it for mercy to thoses who don't know bazel)||, you can also call go build multiple times in a bash, makefile, ...

but you will probably have a lot of fun and learn a lot about how the toolchain so Sparkles

trim field
#

Hey thanks, indeed i don't intend to do that in a serious project just trying to figure out what the toolchain does and where the different files are located