/usr/bin/link: missing operand after ‘\377\376"’ when compiling bitflags - rust

Following Phillip Opperman's Blog OS, I have been trying to use the bitflags and x86_64 rust crates. The latest x86_64 crate release has bitflags 1.0.4 as a dependency which makes sense. However, I have been completely unable to compile bitflags 1.2.1 on any target with several compilers (tried nightly for every release since June 2019, stable)
Every time I try, Cargo throws this error:
error: linking with `link.exe` failed: exit code: 1
|
= note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.10igbbtzvlu2gjzc.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.178969nxbu3nxuky.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.17xe0ilsif9upn0h.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.18t5fqmvmcakbqcu.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.1tks4n3zsagbiucs.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.1x00x4dovi546kkl.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.20khrbf3w08gf7gw.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.2300zqtgv1madedz.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.242aa09d34jshbc9.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.24klb7r0emqymm3t.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.27en69ffbhnktrj7.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.2bws5627knv64y1n.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.2e1o13g4bta7mxfq.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.2msccpkq1gofr2iq.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.2so84tb4ib2abjhy.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.2wrpuwxc6a2lpmw3.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.34jaofsecblmluop.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3h9hs48cyaiaawqq.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3i7788k802tubyhd.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3jxyc8towsdfxyad.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3ofhy3w7e48bfc7j.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3qnhz4aum3qd07zo.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3y43d86jozz1eymi.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.3ycwew3k0fan7v08.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.40hi0t5daivy49tp.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.447ecvqx3zomb1b8.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.455qjh596c0k58u.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4755rsha0yaachh.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4c1izw4dwgrqtuxe.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4ckqzzupgkkb0m3s.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4e31qbizzcl2oip1.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4l4pis8wno6tow0u.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4p1k3k8ws4isf3lw.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.4tdt9b2iyabiwph8.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.519b3wup2l151966.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.54m1xq349ayksbun.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.57ectnnsg543kzfn.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.58dovvuhpiqcojaw.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.5a7xswmgibmgqieq.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.5du0pnnn1wob2l02.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.5gmrtuynfugoyo5w.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.dy9ewngypkxb53u.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.g92a319cgc2j7m4.rcgu.o"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.o22syf9m375w02v.rcgu.o" "
OUT:C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.exe"
"C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\build\\bitflags-10ba28bcd480cb56\\build_script_build-10ba28bcd480cb56.yhwnnfvr19au4rm.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "
NATVIS:C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "
NATVIS:C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "
NATVIS:C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "
NATVIS:C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Users\\jlsat\\Desktop\\projects\\bitflags\\target\\debug\\deps" "
LIBPATH:C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-18c6858731fa3bc3.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-a66e087848bc7936.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-338ca20351402107.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-4f84af8e7d3388ab.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libbacktrace-a1aab3ed9b27c85d.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-7ec4d8ba283cadef.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-95d48056521518ae.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-0da050bb8301bdcc.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-4fecd5ded0f89344.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-6c3a580df1907230.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-a7e28ad09d5bceb4.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-d611b18b12aad85e.rlib"
"C:\\Users\\jlsat\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-72682309e5e16886.rlib" "advapi32.lib" "ws2_32.lib"
"userenv.lib" "msvcrt.lib"
= note: /usr/bin/link: missing operand after ‘\377\376"’
Try '/usr/bin/link --help' for more information.
(More outputs at bottom)
This, to me, is gibberish. Clearly, the linker is failing, but as far as I understand it, the bitflags crate has a custom build script (build.rs) that really only checks for compiler compatibility. Since the crate only works on rustc 1.2+ (something of the sort) it makes sense that it checks this. However, this also leaves me with no leads. What is the source of this issue? I can't see any point where the linker is being directly modified in a way that would cause such a mess.
cargo build --verbose output (same as before with this section appended):
Caused by:
process didn't exit successfully:
`rustc --crate-name build_script_build build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' -C metadata=10ba28bcd480cb56 -C extra-filename=-10ba28bcd480cb56 --out-dir 'C:\Users\jlsat\Desktop\projects\bitflags\target\debug\build\bitflags-10ba28bcd480cb56' -C 'incremental=C:\Users\jlsat\Desktop\projects\bitflags\target\debug\incremental' -L 'dependency=C:\Users\jlsat\Desktop\projects\bitflags\target\debug\deps'` (exit code: 1)
Running this process separately output almost exactly the same thing, with no new information.
Edit:
I was trying this on bash for windows, and my MSVC linker along with the rest of the suite was broken (windows doesn't like me). I believe this massive printout was caused because the terminal defaulted to the gnu linker, which didn't like that. After reinstalling the build tools and updating my toolchain and xbuild, everything worked fine. Thanks for those who tried to help!

I also meet this error.
I fix it by installing Windows 10 SDK.
Rustc need Windows 10 SDK. I found this in here:
For Visual Studio, make sure to check the "C++ tools" and "Windows 10 SDK" option.

Related

Code coverage in Rust - "failed to run `rustc` to learn about target-specific information"

I am trying to get code coverage for my project in Rust. I am following the instructions provided here: https://marco-c.github.io/2020/11/24/rust-source-based-code-coverage.html
Based on that (and from https://doc.rust-lang.org/book/ch01-03-hello-cargo.html), I followed the steps:
cd projects // this could be really anything. Just meant to say I am in a clean directory.
cargo new hello_world --bin // creates a new module with hello world
export RUSTFLAGS="-Zinstrument-coverage"
cargo build
Results in following error:
error: failed to run `rustc` to learn about target-specific information
Caused by:
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Zinstrument-coverage --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 1)
--- stderr
error: the option `Z` is only accepted on the nightly compiler
I followed the post: "Error loading target specification" when building a WebAssembly module with Cargo which has a similar error. But I did not run any rustc command before. So I am not sure if the suggestion there is valid.
My end goal is to not debug this specific error but just try to find a workable way to get code coverage for the project from the command line. So, if I can debug this issue, that's great or if there is something else which I should follow, please point me to it.
Also, I use Intellij - on which I can get code coverage. But I would like to learn that using a command-line approach.
Thanks!

How do I fix "ld: error: unable to find library -lgcc" when cross-compiling rust to android?

I'm trying to get rust working on android. However, when I try to cross-compile to android I get the following linking error:
$ cargo build --target=arm-linux-androideabi
Compiling <project> v0.1.0 (<project>)
error: linking with `/opt/android-sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi31-clang` failed: exit status: 1
(very long toolchain command from cargo)
ld: error: unable to find library -lgcc
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
I have installed the ndk and changed the linker in .cargo/config to the android clang linker. I also tried the standalone toolchains with the same result. The guide I used was the following: https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html
Cross-compilation does work when using crate-type = ["rlib"] instead of crate-type = ["cdylib"], but I need an .so file not an .rlib file.
In case it's relevant, i'm using Manjaro Linux.
UPDATE:
I found the following pull request: https://github.com/rust-lang/rust/pull/85806 After switching to ndk22 it worked. I havn't tried if the pull request fixes the issue (probably does).
Without switching to an older NDK version, I found using the workaround provided by ssrlive to work for me. Here's their comment:
Fixing build error for NDK 23 and above
find out all the 4 folders containing file libunwind.a, in my PC,
it's
C:\Users\Administrator\AppData\Local\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\12.0.8\lib\linux\x86_64\
and more. create 4 text files named libgcc.a in the same folders
with this contents
INPUT(-lunwind)
reference
link
In macOS, the paths are
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/i386/libunwind.a
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/arm/libunwind.a
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/aarch64/libunwind.a
~/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/libunwind.a
In Linux, the paths are
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/i386/libunwind.a
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/aarch64/libunwind.a
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/libunwind.a
~/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/arm/libunwind.a
In Windows, the paths are
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/aarch64/libunwind.a
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/arm/libunwind.a
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/i386/libunwind.a
~/AppData/Local/Android/Sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/14.0.1/lib/linux/x86_64/libunwind.a
create file command in Linux/macOS
cat << EOF > libgcc.a
INPUT(-lunwind)
EOF
This is of course extremely brittle and not the "right" solution, but the workaround works fine as of 2022-10-12 with ndk version 25.1.8937393.

Statically linking ffmpeg-sys on Amazon Linux fails with undefined references

My project depends on the ffmpeg-sys crate which is configured to build statically, as follows:
[dependencies.ffmpeg-sys]
version = "3.4.1"
default-features = false
features = ["avcodec", "avformat", "swresample", "build", "static"]
My project consists of a single simple file:
extern crate ffmpeg_sys;
use ffmpeg_sys::av_register_all;
fn main() {
unsafe { av_register_all() };
println!("Hello, world!");
}
When compiling with cargo build I get the following error:
Compiling sample v0.1.0 (file:///home/ec2-user/sample)
error: linking with 'cc' failed: exit code: 1 | = note: "cc"
"-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L"
[... elided for clarity ...]
In function 'sample::main::hbbb19855251826d6':
/home/ec2-user/sample/src/main.rs:6: undefined reference to 'av_register_all'
collect2: error: ld returned 1 exit status
The required static libraries, libavformat.a and friends, are found in the target/build/debug folder, showing that ffmpeg-sys successfully compiled the libraries.
Here's the rustc command that is failing:
Caused by: process didn't exit successfully: 'rustc --crate-name
sample src/main.rs --crate-type bin --emit=dep-info,link -C
debuginfo=2 -C metadata=250bf40eb277d05a -C
extra-filename=-250bf40eb277d05a --out-dir
/home/ec2-user/sample/target/debug/deps -C
incremental=/home/ec2-user/sample/target/debug/incremental -L
dependency=/home/ec2-user/sample/target/debug/deps --extern
ffmpeg_sys=/home/ec2-user/sample/target/debug/deps/libffmpeg_sys-fa3ff87f80f2d27e.rlib
-L native=/home/ec2-user/sample/target/debug/build/ffmpeg-sys-0b3c813f29a9a20e/out/dist/lib'
(exit code: 1)
libffmpeg_sys-fa3ff87f80f2d27e.rlib is 207M and I assume therefore contains all the statically compiled ffmpeg code.
This only happens when I build on an Amazon Linux instance. Compiling on my regular Fedora 28 desktop results in a working binary.
How would I go about figuring out the root cause of this error?
I solved this problem by building llvm 6.0.1 and then rebuilding with LIBCLANG_PATH set to point to the newer version.
It would appear that rustc has a minimum version requirement on libclang.so, but I could not find an official source documenting that. The version installed on amazon-linux is 3.6.2 which is evidently too old.

failure to build rust-libc using cargo when rustc is musl-enabled

I successfully created a musl configured rustc by following this link
My attempt to build a project (which builds fine using non-musl configured rust) failed when I used cargo rustc -- --target=x86_64-unknown-linux-musl
'error: could not find crate `libc` with expected target triple x86_64-unknown-linux-musl'
Then, I tried to create rust-libc library using the code from crate. To be more accurate, I used the command provided by cargo to build rust-libc, I've only added --target=x86_64-unknown-linux-musl to the command. This time it failed reporting:
'error: could not find native static library `c`, perhaps an -L flag is missing?`'
I have two questions:
Is it mandatory to build musl configured cargo to be able to use cargo build --target=x86_64-unknown-linux-musl?
How can I address this:
'error: could not find native static library `c`, perhaps an -L flag is missing?'
This worked for me to build libc:
rustc --target=x86_64-unknown-linux-musl /address-of-libc/lib.rs --crate-name libc --crate-type lib -L /address-of-musldist/musldist/lib/ --out-dir=/your-chosen-address/target --cfg feature=\"default\" --cfg feature=\"cargo-build\" --emit=dep-info,link

How to make Travis CI work with Rust 0.12.0 and Cargo?

I am trying to make Travis CI build and test the contents of my GitHub repository, which is compatible with Rust 0.12.0 and an older Cargo:
rustc 0.12.0 (ba4081a5a 2014-10-07 13:44:41 -0700)
cargo 0.0.1-pre-nightly (861c07f 2014-10-07 23:29:57 +0000)
I have specified Rust 0.12.0 in the .travis.yml:
language: rust
rust: 0.12.0
script:
- cargo build --verbose
- cargo test --verbose
- rustdoc --test README.md -L target
- cargo doc
The issue I seem to be hitting is that Travis will pick the latest Cargo nightly:
cargo 0.0.1-pre-nightly (fd5d7a9 2014-12-25 04:28:40 +0000)
But this newer version is incompatible with Rust 0.12.0, as it is now using --emit=dep-info where it used to use --dep-info:
--dep-info [FILENAME]
Output dependency info to <filename> after compiling,
in a format suitable for use by Makefiles
This gives rustc invocation errors, as the value for is --emit is invalid:
Running `rustc src/sqlite3.rs --crate-name sqlite3 --crate-type lib -g -C metadata=1c7080eec8c6f90d -C extra-filename=-1c7080eec8c6f90d --out-dir target/deps --emit=dep-info,link -L target/deps -L target/deps -Awarnings`
...
error: unknown emission type: `dep-info`
...
Could not compile `sqlite3`.
I have been looking at other repositories for how to get around this, but it seems they either do not use Cargo with 0.12.0 (which works with Travis) or hit the same issue, like here: https://travis-ci.org/eliovir/rust-ini
I have failed to find any repository that works with Travis, rust 0.12.0 and Cargo. If I can specify the version of Cargo somewhere, I would be able to get around this, but I have failed to find a way to do so in the .travis.yml file.
Of course, with Rust 1.0 coming up, I will just wait for it, if there is no obvious solution that I have overlooked :-)
I agree that tracking nightly is probably the best bet. If there are dependencies you rely on that aren't being updated, then maybe that's a sign that they wont be updated come 1.0 time, either!
All that being said, Travis does allow you to install things before your build. This is completely untested, but you might be able to do something like
before_script:
- wget https://static.rust-lang.org/dist/rust-0.12.0-x86_64-unknown-linux-gnu.tar.gz
- tar -xvf rust-0.12.0-x86_64-unknown-linux-gnu.tar.gz
- ./rust-0.12.0-x86_64-unknown-linux-gnu/install.sh --prefix /tmp/rust-0.12/
- export PATH=$PATH:$PWD/tmp/rust-0.12/bin
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/tmp/rust-0.12/lib
This would download Rust 0.12, unpack and install it somewhere writable (doesn't really matter where). Then you setup env vars to point out where Rust is. Do the same to download a compatible version of Cargo.
If Travis has a "bare" language pack, that would be the best. Otherwise you could try using the Rust buildpack, or maybe just anything else (to avoid dealing with multiple rustc versions).

Resources