@@ -1642,3 +1642,74 @@ fn target_applies_to_host_rustdocflags_works() {
16421642 )
16431643 . run ( ) ;
16441644}
1645+
1646+ #[ cargo_test]
1647+ fn host_config_shared_build_dep ( ) {
1648+ // rust-lang/cargo#14253
1649+ Package :: new ( "cc" , "1.0.0" ) . publish ( ) ;
1650+ let p = project ( )
1651+ . file (
1652+ "Cargo.toml" ,
1653+ r#"
1654+ [package]
1655+ name = "bootstrap"
1656+ edition = "2021"
1657+
1658+ [dependencies]
1659+ cc = "1.0.0"
1660+
1661+ [build-dependencies]
1662+ cc = "1.0.0"
1663+
1664+ [profile.dev]
1665+ debug = 0
1666+ "# ,
1667+ )
1668+ . file ( "src/lib.rs" , "" )
1669+ . file ( "build.rs" , "fn main() {}" )
1670+ . file (
1671+ ".cargo/config.toml" ,
1672+ "
1673+ target-applies-to-host=false
1674+
1675+ [host]
1676+ rustflags = ['--cfg', 'from_host']
1677+
1678+ [build]
1679+ rustflags = ['--cfg', 'from_target']
1680+ " ,
1681+ )
1682+ . build ( ) ;
1683+
1684+ p. cargo ( "build -v" )
1685+ . masquerade_as_nightly_cargo ( & [ "target-applies-to-host" ] )
1686+ . arg ( "-Ztarget-applies-to-host" )
1687+ . arg ( "-Zhost-config" )
1688+ // Sometimes it compiles. Not deterministic...
1689+ . with_stderr_data ( str![ [ r#"
1690+ [UPDATING] `dummy-registry` index
1691+ [LOCKING] 2 packages to latest compatible versions
1692+ [DOWNLOADING] crates ...
1693+ [DOWNLOADED] cc v1.0.0 (registry `dummy-registry`)
1694+ [WARNING] output filename collision.
1695+ The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
1696+ Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rlib
1697+ The targets should have unique names.
1698+ Consider changing their names to be unique or compiling them separately.
1699+ This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
1700+ [WARNING] output filename collision.
1701+ The lib target `cc` in package `cc v1.0.0` has the same output filename as the lib target `cc` in package `cc v1.0.0`.
1702+ Colliding filename is: [ROOT]/foo/target/debug/deps/libcc-[HASH].rmeta
1703+ The targets should have unique names.
1704+ Consider changing their names to be unique or compiling them separately.
1705+ This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
1706+ [COMPILING] cc v1.0.0
1707+ [RUNNING] `rustc --crate-name cc [..]--cfg from_host[..]`
1708+ [RUNNING] `rustc --crate-name cc [..]--cfg from_target[..]`
1709+ [ERROR] failed to build archive: No such file or directory
1710+
1711+ [ERROR] could not compile `cc` (lib) due to 1 previous error
1712+
1713+ "# ] ] )
1714+ . run ( ) ;
1715+ }
0 commit comments