

The default config lookup algorithm looks for -.cfg first. The sys-devel/clang-common package installs a default set of configuration files there. Technically, the build system also permits specifying “user” configuration directory but it’s not practically useful, as it provides no way of referencing the user’s home directory. However, it should be noted that some values are appended rather than overrode, and there is no way to “reset” them right now.Īs built in Gentoo, clang looks for configuration files in two locations: /etc/clang and the executable directory.

This permits explicit files to override the options specified in default configs. Default configuration files are loaded first (unless explicitly disabled by -no-default-config or a non-empty CLANG_NO_DEFAULT_CONFIG envvar - the latter intended to be used in clang’s test suites), and configuration files specified via -config= options are loaded afterwards.

In clang 16, configuration files can be both specified explicitly and loaded from default locations. With clang 16, I have taken the opportunity to finally change that. In this post, I’d like to shortly describe the new configuration file features, how much of them have been backported to 15.x in Gentoo and how defaults are going to be selected from now on.Ĭonfiguration files were supported at least for a few clang releases now but they weren’t very useful for us before. This change has also been partially backported to clang 15.0.2 in Gentoo, and (unless major problems are reported) will be part of the stable clang 15.x release (currently planned for upcoming 15.0.3). This enabled Gentoo to finally replace the default-* flags used on sys-devel/clang, effectively empowering our users with the ability to change defaults without rebuilding whole clang.

Notably, it adds support for specifying multiple files and better default locations. The upcoming clang 16 release features substantial improvements to configuration file support.
