diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-01-15 14:23:45 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-01-15 14:48:00 +0100 |
| commit | 1b0c0eb717fc5457ec1881c6310f7d7c25ba0d19 (patch) | |
| tree | 2150daa9befd6a2701f42a9b584b11d24b57ee8b /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 38c22af0153cf8f920c01ef04493e8878401fd18 (diff) | |
| download | rust-1b0c0eb717fc5457ec1881c6310f7d7c25ba0d19.tar.gz rust-1b0c0eb717fc5457ec1881c6310f7d7c25ba0d19.zip | |
Deny mixing bin crate type with lib crate types
The produced library would get a main shim too which conflicts with the
main shim of the executable linking the library.
```
$ cat > main1.rs <<EOF
fn main() {}
pub fn bar() {}
EOF
$ cat > main2.rs <<EOF
extern crate main1;
fn main() {
main1::bar();
}
EOF
$ rustc --crate-type bin --crate-type lib main1.rs
$ rustc -L. main2.rs
error: linking with `cc` failed: exit status: 1
[...]
= note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main':
main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here
collect2: error: ld returned 1 exit status
```
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
