Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deny mixing bin crate type with lib crate types #92933

Merged
merged 2 commits into from
Feb 18, 2022

Commits on Jan 15, 2022

  1. 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
    ```
    bjorn3 committed Jan 15, 2022
    Configuration menu
    Copy the full SHA
    1b0c0eb View commit details
    Browse the repository at this point in the history
  2. Update tests

    bjorn3 committed Jan 15, 2022
    Configuration menu
    Copy the full SHA
    0b59630 View commit details
    Browse the repository at this point in the history