llvm / llvm/llvm-project

feature: Per-module -fmodules-decluse (-fmodules-decluse=<module_name>)

Open
#162,846 2 comments 0 reactions 0 assignees View on GitHub
clang:modules
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I’m setting up Clang module maps for Qt and thought I’d use -fmodules-decluse to test my work. Unfortunately, enabling -fmodules-decluse results in quite a few errors of this kind:

```
While building module '_DarwinFoundation2' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:61:
In file included from :1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/nl_types.h:44:10: error: module _DarwinFoundation2 does not directly depend on a module exporting 'sys/cdefs.h', which is part of indirectly-used module cdefs
44 | #include
| ^
```

Which doesn't seem possible to work around.

As suggesteded in https://discourse.llvm.org/t/fmodules-decluse-resulting-in-errors-from-xcode-sdk/88267 a `-fmodules-decluse=` might be a useful addition to the modules machinery.

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start in the Clang modules machinery and reproduce the reported errors with Qt module maps, the Xcode SDK, and -fmodules-decluse. Compare the proposed -fmodules-decluse= behavior with the existing flag, then verify that per-module declaration-use checking handles indirectly used modules without the reported diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.