-
Couldn't load subscription status.
- Fork 1.4k
Description
| Previous ID | SR-1393 |
| Radar | rdar://problem/23237241 |
| Original Reporter | @ddunbar |
| Type | Bug |
| Status | In Progress |
| Resolution |
Additional Detail from JIRA
| Votes | 9 |
| Component/s | Package Manager |
| Labels | Bug |
| Assignee | owenvoorhees (JIRA) |
| Priority | Medium |
md5: b673faead2f75706db0bdac53b7b8ef3
is duplicated by:
- SR-4539 Build executable with modules, without specified dependencies
- SR-8344 SPM include path is too permissive, leads to link errors that should have been compile errors
- SR-9359 SwiftPM should have better diagnostics if tests depend on executable target
- SR-11758 Undefined symbol: static allcases.MyEnum.allCases.getter : [allcases.MyEnum]
relates to:
- SR-3033 Poor diagnostic when importing executable target module in a test
- SR-13651 Linker error while linking unit test cases
- SR-3205 Ability to restrict the import of implicit module dependencies
- SR-14212 Removing package from Package.swift doesn't result in import error
- SR-7483 Deserialization Failure
Issue Description:
Currently, SwiftPM passes a -I to the directory containing all built modules, which allows any Swift code to import any module which has been built.
This is unfortunate, as it means code can easily import modules which haven't been explicitly declared as a dependency. That might frequently work but it can be the source of transient build failures or "works for me" type problems.
Instead, we should enforce that Swift code is only allowed to import modules which have been explicitly declared as dependencies. We could also let this include transitive dependencies, but I would actually prefer we require any module explicitly declare all other modules it is allowed to import.
swiftc doesn't expose a mechanism currently we can use to implement this directly. We could:
-
Extend
swiftcto explicitly support this. -
Build symlink trees for each target we want to build, and point the
-Iat that instead, to enforce what is allowed.