"Calling a function with bad signature" while building a crate


#1

I am getting this weird Calling a function with bad signature! error message from LLVM while trying to build a Rust crate using rustc 1.20.0-nightly (bf0a9e0b4 2017-07-10). The error message is not verbose enough to pinpoint the source of the issue. How can I debug the problem?

Compiling hello v0.1.0 (file:///home/dipanjan/research/rust.ko)
     Running `rustc --crate-name hello src/lib.rs --crate-type staticlib --emit=dep-info,link -C debuginfo=2 -C metadata=eff424a84d960dec -C extra-filename=-eff424a84d960dec --out-dir /home/dipanjan/research/rust.ko/target/x86_64-unknown-none-gnu/debug/deps --target x86_64-unknown-none-gnu -L dependency=/home/dipanjan/research/rust.ko/target/x86_64-unknown-none-gnu/debug/deps -L dependency=/home/dipanjan/research/rust.ko/target/debug/deps --extern linux_std=/home/dipanjan/research/rust.ko/target/x86_64-unknown-none-gnu/debug/deps/liblinux_std-8d3907c46544e57d.rlib --sysroot /home/dipanjan/.xargo`
rustc: /checkout/src/llvm/lib/IR/Instructions.cpp:258: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
error: Could not compile `hello`.

Caused by:
  process didn't exit successfully: `rustc --crate-name hello src/lib.rs --crate-type staticlib --emit=dep-info,link -C debuginfo=2 -C metadata=eff424a84d960dec -C extra-filename=-eff424a84d960dec --out-dir /home/dipanjan/research/rust.ko/target/x86_64-unknown-none-gnu/debug/deps --target x86_64-unknown-none-gnu -L dependency=/home/dipanjan/research/rust.ko/target/x86_64-unknown-none-gnu/debug/deps -L dependency=/home/dipanjan/research/rust.ko/target/debug/deps --extern linux_std=/home/dipanjan/research/rust.ko/target/x86_64-unknown-none-gnu/debug/deps/liblinux_std-8d3907c46544e57d.rlib --sysroot /home/dipanjan/.xargo` (exit code: 1)
/home/dipanjan/research/rust.ko/build/Makefile:44: recipe for target '/home/dipanjan/research/rust.ko/build/libhello.a' failed
make[2]: *** [/home/dipanjan/research/rust.ko/build/libhello.a] Error 101
Makefile:1491: recipe for target '_module_/home/dipanjan/research/rust.ko/build' failed
make[1]: *** [_module_/home/dipanjan/research/rust.ko/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.8.0-52-generic'
Makefile:36: recipe for target 'all' failed
make: *** [all] Error 2