-fmodules-decluse resulting in errors from Xcode SDK

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 <module-includes>: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 <sys/cdefs.h>
      |          ^

Is this something I can fix or work around, to be able to use -fmodules-decluse to test my work?

Thanks! :slight_smile:

None of the Apple module maps have any use declarations so I don’t know how you would be able to use -fmodules-decluse with Apple SDKs.

Right. I was hoping there was some way to isolate -fmodules-decluse to e.g. ignore system modules, or otherwise let me diagnose issues in my own modules separately.

I don’t see a form like -fmodules-decluse=<module_name> but that’s an interesting idea.

Filed feature: Per-module -fmodules-decluse (-fmodules-decluse=<module_name>) · Issue #162846 · llvm/llvm-project · GitHub