VirusTotal / yara-x

A rewrite of YARA in Rust.
https://virustotal.github.io/yara-x/
BSD 3-Clause "New" or "Revised" License
565 stars 46 forks source link

Compilation as Go binding fails #122

Closed steffenfritz closed 1 month ago

steffenfritz commented 1 month ago

I built the C library as documented here: https://virustotal.github.io/yara-x/docs/api/c/c-/#building-the-c-library without errors.

Adding it to a project with import yarax "github.com/VirusTotal/yara-x/go" and building the Go code fails with:

# github.com/VirusTotal/yara-x/go
vendor/github.com/VirusTotal/yara-x/go/compiler.go:20:24: not enough arguments in call to (_Cfunc_yrx_compiler_create)
    have (**_Ctype_struct_YRX_COMPILER)
    want (_Ctype_uint, **_Ctype_struct_YRX_COMPILER)

Machine:

  1. MacOS
  2. ARM64 - M1
  3. MacOS 14.5
  4. Homebrew used for rust and cargo installation

Go Environement:

GO111MODULE='' GOARCH='arm64' GOBIN='' GOCACHE='/Users/steffen/Library/Caches/go-build' GOENV='/Users/steffen/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/steffen/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/opt/homebrew/Cellar/go/1.22.3/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.3/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.22.3' GCCGO='gccgo' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/rt/mbz5zkp533sgg49fmm6ky3tr0000gn/T/go-build4207267908=/tmp/go-build -gno-record-gcc-switches -fno-common'

plusvic commented 1 month ago

This is because you have the latest version of the Rust library, but an older version of the Go module. I've published v0.3.0 for the Go module now. You should be able to do: go get github.com/VirusTotal/yara-x/go@v0.3.0 and everything should go fine.

steffenfritz commented 1 month ago

Yes, I can confirm. Thanks!