bytecodealliance / bytecodealliance/wasmtime-go

Go build failing due to "multiple definition of" error

Open
#160 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
913
Forks
100
Avg merge
10m
Merged PRs (30d)
1

Description

Getting below traceback while building go source code.
```
[2022-11-16T11:45:45.447Z] export CGO_ENABLED=1
[2022-11-16T11:45:45.447Z] go build -tags opa_wasm -o ./bin/opa_argus_metrics_linux_amd64 ./".gopath/src/git.soma.salesforce.com/opa-argus-metrics-plugin"/cmd/opa-argus-metrics-plugin/...
[2022-11-16T11:46:03.580Z] # git.soma.salesforce.com/Kuleana/opa-argus-metrics-plugin/.gopath/src/git.soma.salesforce.com/opa-argus-metrics-plugin/cmd/opa-argus-metrics-plugin
[2022-11-16T11:46:03.580Z] /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
[2022-11-16T11:46:03.580Z] /tmp/go-link-3790786405/000023.o: In function `assertions':
[2022-11-16T11:46:03.580Z] /tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:30: multiple definition of `assertions'
[2022-11-16T11:46:03.580Z] /tmp/go-link-3790786405/000022.o:/tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:30: first defined here
[2022-11-16T11:46:03.580Z] /tmp/go-link-3790786405/000025.o: In function `assertions':
[2022-11-16T11:46:03.580Z] /tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:30: multiple definition of `assertions'
[2022-11-16T11:46:03.580Z] /tmp/go-link-3790786405/000022.o:/tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:30: first defined here
[2022-11-16T11:46:03.580Z] /tmp/go-link-3790786405/000026.o: In function `assertions':
```
[Found another similar issue](https://github.com/bytecodealliance/wasmtime-go/issues/54), so tried using gcc7+ with centos7. But still got same error. After that tried using `--ldflags '-extldflags "-Wl,--allow-multiple-definition"'` flags along with go build but this time got below error.
```
[2022-11-22T12:02:21.391Z] export CGO_ENABLED=1
[2022-11-22T12:02:21.391Z] go build --ldflags '-extldflags "-Wl,--allow-multiple-definition"' -tags opa_wasm -o ./bin/opa_argus_metrics_linux_amd64 ./".gopath/src/git.soma.salesforce.com/opa-argus-metrics-plugin"/cmd/opa-argus-metrics-plugin/...
[2022-11-22T12:02:39.577Z] # git.soma.salesforce.com/Kuleana/opa-argus-metrics-plugin/.gopath/src/git.soma.salesforce.com/opa-argus-metrics-plugin/cmd/opa-argus-metrics-plugin
[2022-11-22T12:02:39.577Z] /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
[2022-11-22T12:02:39.577Z] /tmp/go-link-2410706016/000022.o: In function `assertions':
[2022-11-22T12:02:39.577Z] /tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:30: undefined reference to `static_assert'
[2022-11-22T12:02:39.577Z] /tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:31: undefined reference to `static_assert'
[2022-11-22T12:02:39.577Z] /tmp/go-link-2410706016/000023.o:/tmp/project/vendor/github.com/bytecodealliance/wasmtime-go/build/include/wasm.h:32: more undefined references to `static_assert' follow
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.