yara-x
yara-x copied to clipboard
Fail to build in Rust nightly
Trying to build the project under Rust nightly fails with the following error
>>> referenced by yara_x.1d0ae0f25a4d2322-cgu.05
>>> yara_x-0871b011ab05dce0.yara_x.1d0ae0f25a4d2322-cgu.05.rcgu.o:(yara_x::wasm::WASM_EXPORTS::h112242e6a917df1a) in archive project/target/x86_64-unknown-linux-gnu/debug/deps/libyara_x-0871b011ab05dce0.rlib
>>> did you mean: __start_linkme_WASM_EXPORTS
>>> defined in: <internal>
>>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)
rust-lld: error: undefined symbol: __stop_linkm2_WASM_EXPORTS
>>> referenced by yara_x.1d0ae0f25a4d2322-cgu.05
>>> yara_x-0871b011ab05dce0.yara_x.1d0ae0f25a4d2322-cgu.05.rcgu.o:(yara_x::wasm::WASM_EXPORTS::h112242e6a917df1a) in archive project/target/x86_64-unknown-linux-gnu/debug/deps/libyara_x-0871b011ab05dce0.rlib
>>> did you mean: __stop_linkme_WASM_EXPORTS
>>> defined in: <internal>
collect2: error: ld returned 1 exit status
Expected behaviour: not to fail when trying to build with Rust nightly
A workaround is to use RUSTFLAGS="-C link-args=-znostart-stop-gc" as mentioned in https://github.com/dtolnay/linkme/issues/94
Proposal: create a build.rs script to build the library properly with rust nightly so that it doesn't explodes in the hands of the end user.
Update: it is not possible to create a build.rs in yara-x to solve this issue as this flag seems to be needed when building the end-project embedding yara-x.
Closing as obsolete.