Hello,
As described in
https://go.googlesource.com/gollvm/#seetheir, you will generally want to run "go build" in order to see the correct invocation of llvm-goc for your use case.
In your case (building a Go file that uses CGO), there is a lot happening "under the hood" when you do the build -- it's not a single compiler invocation.
I recommend that you try the following:
go build -x -work somecgo.go 1> err.txt 2>&1
then take a look at the commands that "go build" is executing to carry out the build.
You'll first see the invocation of the "cgo" tool, something like this
TERM='dumb' CGO_LDFLAGS='"-g" "-O2"' /x/gollvm-install/tools/cgo -objdir ./go-build3209048615/b001/ -importpath command-line-arguments -gccgo -- -I ./go-build3209048615/b001/ -g -O2 -fsplit-stack ./somecgo.go
The cgo tool analyzes the Go source file and emits new boilerplate / glue files (both C files and Go files) needed to connect up the two chunks of code in the file (the C chunk and the Go chunk).
Next you'll see more invocations of the C and Go compilers, e.g. things like
TERM='dumb' /usr/bin/clang-10 -I /tmp -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -funwind-tables -I ./ -g -O2 -fsplit-stack -o ./_x002.o -c somecgo.cgo2.c
and
/x/gollvm-install/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-relative-import-path=_/tmp -o ./go-build3209048615/b001/_go_.o -I ./go-build3209048615/b001/_importcfgroot_ ./go-build3209048615/b001/_cgo_gotypes.go ./go-build3209048615/b001/somecgo.cgo1.go ./go-build3209048615/b001/_gomod_.go
to generate objects that feed into the final link.
If you want to collect the LLVM IR, you'll need to capture and replay all of these compilations with the appropriate compiler options (e.g. "-emit-llvm") and capture the results.
Hope this helps.
Than