malformed #cgo argument when adding `solace.dev/go/messaging` dependency
I'm trying to configure please in a project that depends on "solace.dev/go/messaging" package. My configuration in the third_party/go/BUILD file is as following:
go_module(
name="solace_messaging",
module="solace.dev/go/messaging",
version="v1.3.0",
install= ["..."],
)
And it fails to build or either test the go_library with the following message:
please_go install -> touch LD_FLAGS
Compiling package solace.dev/go/messaging/.github/workflows from []
Compiling package solace.dev/go/messaging from []
Compiling package solace.dev/go/messaging/internal/impl from [solace.dev/go/messaging]
Compiling package solace.dev/go/messaging/internal/ccsmp from [solace.dev/go/messaging solace.dev/go/messaging/internal/impl]
2023/06/24 11:43:22 /home/user/Documents/project_name/plz-out/tmp/third_party/go/_solace_messaging#a_rule._build/third_party/go/solace_messaging/internal/ccsmp/includes_linux.go: malformed #cgo argument: -I/home/user/Documents/project_name/plz-out/tmp/third_party/go/_solace_messaging#a_rule._build/third_party/go/solace_messaging/internal/ccsmp/lib/include
I've attempted to use also a go_repo:
go_repo(
name="solace_messaging",
module="solace.dev/go/messaging",
version="v1.3.0",
install= ["..."],
)
And the message is the same:
Error building target //third_party/go:_solace_messaging#repo: exit status 1
2023/06/24 11:48:07 failed to generate go rules: /home/user/Documents/project_name/plz-out/tmp/third_party/go/_solace_messaging#repo._build/third_party/go/_solace_messaging#dl/internal/ccsmp/includes_linux.go: malformed #cgo argument: -I/home/user/Documents/project_name/plz-out/tmp/third_party/go/_solace_messaging#repo._build/third_party/go/_solace_messaging#dl/internal/ccsmp/lib/include
I've followed the codelab when setting up the project, should I do any special configuration for this specific dependecy to work?
Thanks for the help.
This is a known bug with libraries that have include directories that use ${SRCDIR} in their cgo args. A workaround if you're on linux is build sandboxing:
[Sandbox]
Build = true
This will use linux namespaces to mount the tmp dir under /tmp/plz_sandbox which avoids the issue.
Thanks for the response @Tatskaari!
I added the entry to my .plzconfig file. Now it looks like that:
[Sandbox]
Build = true
[Plugin "go"]
Target = //plugins:go
ImportPath = github.com/wcodesoft/buso/libs/go/buso
GoTool = //third_party/go:toolchain|go
When trying to add a third party dependency using this command:
plz run ///go//tools/please_go -- get github.com/smartystreets/[email protected]
I received the following error:
19:28:52.253 WARNING: Can't find sandbox tool please_sandbox on the path: please_sandbox not found in path /home/linuxbrew/.linuxbrew/Cellar/please/17.0.0/bin:/usr/local/bin:/usr/bin:/bin
Build stopped after 10ms. 1 target failed:
//plugins:go
Error building target //plugins:go: exec: no command
I imagine that this is caused for not having please_sandbox installed. I was not able to find a guide about how to install the please_sandbox. Where can I find it?
Apologies! This was meant to change in v17 but it seems we missed it. Please has a build in sandboxing mechanism but it's not the default. To enable it, you need to unset the sandboxing tool config option:
[Sandbox]
build = true
SandboxTool =
I'll change this here:
https://github.com/thought-machine/please/pull/2841
When I use the config option when try to build that's what I'm receiving:
21:03:55.941 WARNING: Error in config file /home/user/Documents/buso/.plzconfig: warning:
can't store data at section "Sandbox", variable "SandboxTool"
21:03:55.941 WARNING: Can't find sandbox tool please_sandbox on the path: please_sandbox not found in path /home/linuxbrew/.linuxbrew/Cellar/please/17.0.0/bin:/usr/local/bin:/usr/bin:/bin
Build stopped after 10ms. 1 target failed:
//plugins:go
Error building target //plugins:go: exec: no command