Newer Clang has a problem with using -fmodules and module auto-linking on linux. Using -fmodules for the C++ code is not necessary but SwiftPM passes the flags unconditionally.
To workaround this set this env var for the build invocation:
env CCC_OVERRIDE_OPTIONS="#x-fmodules s/-fmodules-cache-path.*//" swift build <...>
this will remove the module options from the clang invocations