How to fix `failed to increase jobserver pipe capacity from 4096 to 8192; jobserver otherwise might deadlock` error from cargo/rustc - rust

When performing some rust compilation tasks such as running cargo build or cargo xtask install, occasionally the compiler will crash with an error message:
Caused by:
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -C link-arg=-fuse-ld=lld --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: 101)
--- stderr
thread 'rustc' panicked at 'failed to create jobserver: Custom { kind: PermissionDenied, error: "failed to increase jobserver pipe capacity from 4096 to 8192; jobserver otherwise might deadlock" }', compiler/rustc_data_structures/src/jobserver.rs:23:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.56.0-nightly (0035d9dce 2021-08-16) running on x86_64-unknown-linux-gnu
note: compiler flags: -C link-arg=-fuse-ld=lld --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro
query stack during panic:
end of query stack
This is occurring on the latest Rust nightly toolchain that includes a working RLS as of the time of posting, rustc 1.56.0-nightly (0035d9dce 2021-08-16)
OS is Debian Linux

This bug is likely caused by a PR merged into jobserver-rs that aims to increase the jobserver pipe buffer capacity on Linux: https://github.com/alexcrichton/jobserver-rs/pull/34
This seems to have created a regression and so was reverted here: https://github.com/alexcrichton/jobserver-rs/pull/35
However, since no new rust nightlies have been minted in a couple of weeks due to rls failing to build, the bug persists in the latest nightly.
The fix is to revert to an older rust nightly and wait for a new working nightly to be released with rls support which will include the revert for the breaking commit to jobserver-rs.

Related

error: the option `Z` is only accepted on the nightly compiler is not solved

I'm trying to use Address sanitizer in rust with this manual(https://github.com/japaric/rust-san),
but when I build this code with command RUSTFLAGS="-Z sanitier=address" cargo rustc -- --emit=llvm-ir, it cause error like this;
error: failed to run rustc to learn about target-specific information
Caused by:
process didn't exit successfully: rustc - --crate-name ___ --print=file-names -Z sanitier=address --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 think that "the option Z is only accepted on the nightly compiler" is problem, so I set up to nightly compiler with
rustup install nightly, rustup default nightly, but it cause same error when I build with that command.
How should I do?
Perhaps you should build your code with command:
RUSTFLAGS="-Z sanitier=address" cargo run ${your-binary-name} --target x86_64-unknown-linux-gnu -- --emit=llvm-ir
This works for me to check example in manual:
RUSTFLAGS="-Z sanitizer=address" cargo run --example out-of-bounds --target x86_64-unknown-linux-gnu -- --emit=llvm-ir
**==618620==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffbcbf1250 at pc 0x55adfda84e90 bp 0x7fffbcbf1210 sp 0x7fffbcbf1208
READ of size 4 at 0x7fffbcbf1250 thread T0
#0 0x55adfda84e8f in out_of_bounds::main::hf228b092630ab849 /tmp/rust-san/asan/examples/out-of-bounds.rs:3:22
#1 0x55adfda846fa in core::ops::function::FnOnce::call_once::h84454ea25b7d75ab /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/core/src/ops/function.rs:248:5
#2 0x55adfda84a94 in std::sys_common::backtrace::__rust_begin_short_backtrace::hbc7697f2c0b7e35d /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/sys_common/backtrace.rs:122:18
#3 0x55adfda853a3 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h01c2d6f3a231ead0 /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/rt.rs:145:18
#4 0x55adfda9704d in core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::hfce3f72e51a03fc4 /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/core/src/ops/function.rs:280:13
**
According to the manual, you should always pass --target x86_64-unknown-linux-gnu to Cargo.
Be sure to always pass --target x86_64-unknown-linux-gnu to Cargo or else you'll end up sanitizing the build scripts that Cargo runs or run into compilation error if your crate depends on a dylib.
And you could check your toolchain version with:
> rustup default
nightly-x86_64-unknown-linux-gnu (default)

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!

error: could not compile `time` when using cargo to compile

Today when I run cargo build with my project in Fedora 32, shows compile error like this:
Compiling devise v0.3.1
thread 'rustc' panicked at 'assertion failed: sentinel == STR_SENTINEL', /rustc/0b42deaccc2cbe17a68067aa5fdb76104369e1fd/compiler/rustc_serialize/src/opaque.rs:669:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.59.0-nightly (0b42deacc 2021-12-09) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
Compiling async-stream v0.3.2
error: could not compile `time`
warning: build failed, waiting for other jobs to finish...
error: build failed
my cargo version is:
[dolphin#MiWiFi-R4CM-srv]~/Documents/GitHub/rust_wheel% cargo version
cargo 1.58.0-nightly (40dc28175 2021-12-06)
anybody facing the same problem? any fix suggestion? I searching from Google seem no one facing this same issue.
Looks like this internal compiler error is tracked by this issue:
Try cleaning your build artifacts: cargo clean, in most cases the crash should go away after a rebuild.
should be fixed with nightly 2021-12-11

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

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.

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.

Resources