Skip to content

Building a no_std cdylib results in "syntax error in VERSION script" #63925

Closed
@loganwendholt

Description

@loganwendholt

I'm trying to build a pure no_std cdylib with no external library dependencies. For an initial proof of concept, I tried to create such a library using the following code:

Cargo.toml:

[package]
name = "cdylib-no-std"
version = "0.1.0"
edition = "2018"

[lib]
crate-type = ["cdylib"]

[dependencies]

src/lib.rs

#![no_std]
#![no_main]
#![feature(lang_items)]
use core::panic::PanicInfo;

pub fn foo(a: i32, b: i32) -> i32 {
  a + b
}

#[lang = "eh_personality"]
extern "C" fn eh_personality() {}

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

Built using the following command:
cargo +nightly build --lib

Results in the following output:

/usr/bin/ld:/tmp/rustcE1gs9P/list:4: syntax error in VERSION script
          collect2: error: ld returned 1 exit status

However, if crate-type is changed to ["dylib"], it builds properly.

Tested using the following tool versions:
cargo 1.39.0-nightly (3f700ec43 2019-08-19)

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.39.0-nightly (521d78407 2019-08-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions