Changes after editing diagnostics `.def` files not reflected in development compiler output

i suspect i'm missing something fairly straightforward here, but i'm running into issues i don't quite understand when editing diagnostics. i have an existing WARNING diagnostic defined in DiagnosticsSema.def, and i made modifications to it to add some parameters. when i rebuild my local compiler (via ninja ... swift-frontend, or via the generated Xcode project cmd+b) and then compile some code that hits the warning, i'm still getting output from an older version of the diagnostic. how can i force the changes to be 'seen' correctly?

1 Like

Where are you observing the stale warning--compiler tests? command line builds? Xcode?

In my experience, I successfully see warning and error updates I've made in the compiler in compiler tests and command lines builds. However, Xcode is a different story. If I use my locally built compiler by defining SWIFT_EXEC in my Xcode project, I don't see the updated warnings and errors in the code editor window, but I do see them if I drill down into the build output itself.

I don't know what, if anything, I'm doing wrong here. I have found that if I build the entire toolchain with utils/build-toolchain, install that toolchain in /Library/Developer/Toolchains, and then select that toolchain in Xcode, I then see the updated warnings and errors.

Does anyone know what the proper way to test updates to the compiler (including updated warnings/errors/fixits) in Xcode's code editor window is? Are there any shorter paths other than building the entire toolchain?

Changing one of the *.def files should recompile affected dependencies automatically, which includes every place that references those diagnostics. In particular one of these files is supposed to be lib/AST/DiagnosticEngine.cpp, which is where the strings that end up in the swift-frontend binary actually get emitted. If you touch that file and run ninja bin/swift-frontend, do the diagnostic strings update?

1 Like

this was after compiling and then invoking my local development compiler via a command line invocation like <build-dir>/bin/swiftc -typecheck file-with-warnings.swift.

thanks for the suggestions! unfortunately, in my impatience, i ran ninja <build-dir> -t clean swiftSema and then rebuilt things from there. after that, changes have more or less been working as expected – if i edit the .def file then rebuild, a number of things seem to be compiled/linked and the changes are reflected in the dev compiler output. not sure how i managed to get myself into this state, but i will try to keep this recommendation in mind if this occurs again.

2 Likes