dlang / dub

Package and build management system for D
MIT License
662 stars 228 forks source link

Root package dflags does not propagate to subpackages #1881

Open Geod24 opened 4 years ago

Geod24 commented 4 years ago

System information

Bug Description

I might be way off, but when using sub-packages, I expect them to be a component of the root package. Hence, I expect some settings to propagate from the root package to subpackages. I recently tried setting:

dflags "-preview=dip25"

In Vibe.d's dub.dsl and could see it was not propagated to subpackages: there was a DIP25 violation in vibe-d:data which wasn't caught until I added the flag there too.

Expected Behavior

Flags in root package propagate to subpackages.

s-ludwig commented 4 years ago

The general idea with sub packages is that they are logically completely separate packages, with the exception of being tied to the same version. Everything in addition to that would lead to another dimension of opt-in/opt-out directives that become necessary to override the default inheritance behavior.

It would also complicate the build logic for sub packages, as they would have to trace back to the root package to determine their build configuration, and it may be counter-intuitive in cases where the dependencies are reversed (foo:bar depends on foo vs. foo depends on foo:bar).

Geod24 commented 3 years ago

@s-ludwig : One problem with this approach is that some flags need to affect the whole dependency tree. Think about flags which modify the ABI used (-fPIC), or the semantics / mangling (-preview=XXX). This ties back to https://github.com/dlang/dub/issues/279 . I tried to use -preview=in in my project, but since Vibe.d does not use it, I get a linker error.