-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golang compile issues (bazel) #289
Comments
Without seeing your whole setup is going to be hard to help you, but there are a few things you should take into account:
|
Thanks for the quick reply! I have spend a few hours to try and figure out how to do it with bazel but in the end I found that compiling this logic with "go build" was just much easier than spending more time. No ideal but anyway. Maybe this could be solved by allowing a tag to be specified for building the library statically linked ? I'm using a few other cgo dependencies and none of them required any special config. I think I saw other bazel users in other issues so I'm hoping they can chime in. Can we keep this open for a few days and then close it ? Cheers! |
The tag for building the library statically exists ( I also tried to build a Golang project that uses YARA-X using Bazel, and my conclusion was that the drawbacks are greater than the benefits. Bazel's support for Rust is still immature (or at least it was when I looked at it). I managed to build a simple Rust project using Bazel, but when you have third-party dependencies that are not pure-Rust (they link agains C libraries), you start having issues. For this reason, building both the Golang and Rust code with Bazel was out question, and the alternative was building the YARA-X library using At the end I decided to discard Bazel and use |
Thank you for the reply. This makes me feel less bad about giving up
already. Or at least for now I will just use 'go build'. Only downside
being that the rest of the code is build using Bazel but honestly I'm no
longer convinced this is still necessary or a good choice.
Btw, I guess yara-x is not on //third_party yet :) :) or was it
//thirdparty. Can't remember and it only has been a year since I left o_0
…On Thu, Jan 16, 2025, 17:17 Victor M. Alvarez ***@***.***> wrote:
The tag for building the library statically exists (static_link), but the
process is not straightforward. See #257 (comment)
<#257 (comment)>.
I also tried to build a Golang project that uses YARA-X using Bazel, and
my conclusion was that the drawbacks are greater than the benefits. Bazel's
support for Rust is still immature (or at least it was when I looked at
it). I managed to build a simple Rust project using Bazel, but when you
have third-party dependencies that are not pure-Rust (they link agains C
libraries), you start having issues.
For this reason, building both the Golang and Rust code with Bazel was out
question, and the alternative was building the YARA-X library using cargo,
and use Bazel for building the Golang code, using the previously compiled
YARA-X library and header files.
At the end I decided to discard Bazel and use cargo and go build.
—
Reply to this email directly, view it on GitHub
<#289 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC5OIUG27ENZOOJZEEULSD32K7LQVAVCNFSM6AAAAABVIDU46CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJWGE2DQNZVGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'll close the issue if you don't mind. |
Yes please close as I'm actually already finished with the yara-x integration in lophiid. The current implement made this work super smooth so thanks for that! |
This problem might very well be due to my misunderstanding on how to use yara-x with bazel so feel free to treat this with a low priority.
I installed using:
go get -u github.com/VirusTotal/yara-x/go
Now if I try to build a binary I get this error:
`bazel build //cmd/yara:yara
INFO: Analyzed target //cmd/yara:yara (0 packages loaded, 0 targets configured).
ERROR: /disk/store/coding/lophiid/cmd/yara/BUILD.bazel:11:10: GoLink cmd/yara/yara_/yara failed: (Exit 1): builder failed: error executing GoLink command (from target //cmd/yara:yara) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/go_sdk/builder_reset/builder link -sdk external/go_sdk -installsuffix linux_amd64 -arc ... (remaining 47 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/go_sdk/pkg/tool/linux_amd64/link: running /usr/bin/gcc failed: exit status 1
/tmp/go-link-1884458403/000001.o:compiler.cgo2.c:function _cgo_1093191e5e44_Cfunc_yrx_buffer_destroy:(.text+0x8b): error: undefined reference to 'yrx_buffer_destroy'
/tmp/go-link-1884458403/000001.o:compiler.cgo2.c:function _cgo_1093191e5e44_Cfunc_yrx_compiler_add_source_with_origin:(.text+0xcd): error: undefined reference to 'yrx_compiler_add_source_with_origin'
/tmp/go-link-1884458403/000001.o:compiler.cgo2.c:function _cgo_1093191e5e44_Cfunc_yrx_compiler_ban_module:(.text+0x12e): error: undefined reference to 'yrx_compiler_ban_module'
...
...
...
`
Is there something I'm missing that needs to be done to make this work with bazel ? Any help is really appreciated!
The text was updated successfully, but these errors were encountered: