[PATCH] D133229: [driver] Prune module-map related flags, if they are not going to be needed

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 16:17:00 PDT 2022


rsmith added a comment.

I've landed some tests for the specific functionality that intends to use modules info under `-fno-modules` in b484256f59850e702df4d4532c5f31f478879bb9 <https://reviews.llvm.org/rGb484256f59850e702df4d4532c5f31f478879bb9>.

I think the approach you're taking here is probably doomed -- too many things in Clang depend on whether we've read module map files, and it seems unlikely to me that you'll be able to catch all of them from the driver. For example:

  $ touch a.h
  $ echo 'module a { private header "a.h" }' > module.modulemap
  $ echo '#include "a.h"' > b.cc
  $ clang -fmodule-map-file=module.modulemap b.cc
  b.cc:1:10: error: use of private header from outside its module: 'a.h' [-Wprivate-header]
  #include "a.h"
           ^
  1 error generated.

(and that error can be controlled by a `#pragma`, so you can't even do this if the driver sees `-Wno-private-header`).

I wonder if we could mark a `Module` as "used" whenever we use information from it, and treat module map files as dependencies of the current compilation only if they're used?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133229/new/

https://reviews.llvm.org/D133229



More information about the cfe-commits mailing list