RFR: 8321533: Clang build for Windows

Erik Joelsson erikj at openjdk.org
Thu Dec 7 20:56:17 UTC 2023


On Thu, 7 Dec 2023 15:52:46 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> I'd like to propose a new toolchain for Windows using the clang-cl compiler frontend.
> 
> Clang-cl is available as an optional feature in all Visual Studio editions, including the free-for-OSS-development community edition.
> 
> Clang-cl command line is mostly compatible with cl. However, clang-cl offers a distinct set of diagnostic messages and warnings, which can be used to improve code quality.
> 
> In order to use the clang compiler:
> - install Visual Studio 2022
> - install C++ Clang Compiler (https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-170)
> - configure `--with-toolchain-type=clcl`
> - compile as usual.
> 
> Note: at this moment the code does not build; I plan to submit separate patches that fix the build problems separately. For the impatient, [this patch](https://github.com/djelinski/jdk/commit/d67a16244f4e6db8e6e8c59266bebd17827bc2a5) should be enough to compile the JDK, and [this one](https://github.com/djelinski/jdk/commit/1580e7cf54cca61d3ab58891619553994ea26b10) is needed to get tier1 to pass.

I only commented on minor style issues. I would like to hear from others what they think about the validity of this approach.

Does it work with current devkits, or are they missing something? How is build performance relative to regular `cl`?

make/autoconf/spec.gmk.in line 167:

> 165:   export PATH := @TOOLCHAIN_PATH@:$(PATH)
> 166: endif
> 167: ifeq (@TOOLCHAIN_TYPE@, clcl)

You can combine this with the ifeq above using an ifneq like this:


ifneq ($(filter @TOOLCHAIN_TYPE@, microsoft clcl), )

make/common/NativeCompilation.gmk line 450:

> 448: 	$$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME)))
> 449: 	$$(call MakeDir, $$(@D))
> 450:         ifeq ($(findstring $(TOOLCHAIN_TYPE), microsoft clcl), )

I know `findstring` is used frequently for this construct in the makefile, but I prefer `filter` in cases like this as it only matches complete words.

-------------

PR Review: https://git.openjdk.org/jdk/pull/17019#pullrequestreview-1771104027
PR Review Comment: https://git.openjdk.org/jdk/pull/17019#discussion_r1419645950
PR Review Comment: https://git.openjdk.org/jdk/pull/17019#discussion_r1419649071


More information about the build-dev mailing list