matts1 wrote: > The issue is that if we allow the preprocessor's state to differ across > modules, then the resulting compiled units can be arbitrary (and subtly > incompatible). > > I wonder if a possible solution is to record which macros are used (ie, are > expanded or appear in `#ifdef` / `defined`) And ONLY serialize the set of > macros that are used. That way, if your program never uses `__SSP__`, for > example, then your module would not be incompatible just because **SPP** has > been defined.
IIUC, you're saying that codegen options that create macros are benign when they are never read. This statement seems correct and would probably be a good optimization, however it won't solve all use cases. In our use case, for example, we want our code built without exceptions to depend upon libc++ built with exceptions. As libc++ reads `__cpp_exceptions`, this won't work. I think that the correct thing to do would be to, similarly to [https://github.com/llvm/llvm-project/blob/1cf9f764ac41fb3492e10c78640dd50e616388db/clang/include/clang/Basic/LangOptions.def#L209](other options) which only affect a single macro, turn it into a compatible langopt, with a future potential optimization that if the macro is never read it can be turned into a benign langopt. https://github.com/llvm/llvm-project/pull/131569 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits