执行-LDFLAGS:-w -hostobj给出错误

I am writing a Go package that calls C code. I need to invoke the host linker, but unfortunately adding the -hostobj flag gives me following error:

gcc: error: unrecognized option ‘-h’

Operating system is Linux, architecture amd64.

Here are all the flags:

// #cgo CFLAGS: -I. -fPIC
// #cgo LDFLAGS: -lstdc++ -w -hostobj -L. libsomething.a
// #include "something.h"
// #include <stdlib.h>

What am I doing wrong?

At tip of Go source repository default branch, use -linkmode, not -hostobj. For example, -linkmode=external.

Issue 4069: cmd/ld: invoke host linker for cgo build has not been marked as fixed.