dtolnay / linkme

Safe cross-platform linker shenanigans
Apache License 2.0
626 stars 42 forks source link

Opt-out of duplicate check #99

Open oberrich opened 2 weeks ago

oberrich commented 2 weeks ago

Based on the discussion in #3, it seems that when you declare a distributed_slice within a library it automatically gets prefixed with the crate's name, thus the duplicate check shouldn't be necessary. It appears however that the inclusion of multiple semvers of the crate can result in duplicate declarations.

Unfortunately, the duplicate check has two unwanted consequences: an extra .linkm2_ section as well as a potential panic!. I tried adding println!("cargo:rustc-link-arg-bins=/MERGE:.linkme_=.data,.linkm2_=.rdata") to the build.rs script in an attempt to get rid of the section(s), but that didn't seem to have any effect.

It would be helpful to have a feature flag, like no_dupcheck, to conditionally opt-out of the duplicate checks introduced in #53 when creating a release build.

Also, is there any way to prevent multiple semvers from causing duplicate slices in the first place?