Skip to content

Linking error with --emit=obj,metadata #67294

Closed
@0dvictor

Description

@0dvictor

rustc --emit=obj,metadata helloworld.rs generates a linking error as below:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L"
... 
,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: cc: error: helloworld.helloworld.7rcbfp3g-cgu.0.rcgu.o: No such file or directory
error: aborting due to previous error

Both rustc --emit=obj helloworld.rs and rustc --emit=metadata helloworld.rs work.

To reproduce, the code of helloworld.rs is:

// This is the main function
fn main() {
    println!("Hello World!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesA-metadataArea: Crate metadataC-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