This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Use joined format for include flag on Windows
ClosedPublic

Authored by phosek on Apr 29 2021, 10:14 AM.

Details

Summary

Without this, CMake deduplicates the /I flag breaking the build. See https://cmake.org/cmake/help/v3.13/command/target_compile_options.html for more details on why this is needed.

Diff Detail

Event Timeline

phosek created this revision.Apr 29 2021, 10:14 AM
phosek requested review of this revision.Apr 29 2021, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2021, 10:14 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
mstorsjo added a subscriber: mstorsjo.

Can you explain the issue, including the circumstances where/when the issue occurs, in a bit more detail, I don't quite follow. (We do have CI for windows, in an msvc setting, so it works in some configs at least.)

Can you explain the issue, including the circumstances where/when the issue occurs, in a bit more detail, I don't quite follow. (We do have CI for windows, in an msvc setting, so it works in some configs at least.)

See the last paragraph on https://cmake.org/cmake/help/v3.13/command/target_compile_options.html, I'll add it to the description as well.

phosek edited the summary of this revision. (Show Details)Apr 29 2021, 10:32 AM

Can you explain the issue, including the circumstances where/when the issue occurs, in a bit more detail, I don't quite follow. (We do have CI for windows, in an msvc setting, so it works in some configs at least.)

See the last paragraph on https://cmake.org/cmake/help/v3.13/command/target_compile_options.html, I'll add it to the description as well.

Thanks, that explains the "what". (FTR, for both the -D options in the example, and the -I options here, there's also the possibility to write them joined.)

What I'm still wondering though, is, in which cases does this crop up, as it builds fine in all configs I know of? Is this to avoid issues with some other patch that adds more include dirs?

Thanks, that explains the "what". (FTR, for both the -D options in the example, and the -I options here, there's also the possibility to write them joined.)

What I'm still wondering though, is, in which cases does this crop up, as it builds fine in all configs I know of? Is this to avoid issues with some other patch that adds more include dirs?

I'm trying to use the runtimes build on Windows and include libc++ in the build which is where I ran into this issue.

Prior to ea12d779bc238c387511fe7462020f4ecf4a8246 there was only one /I and that change only landed yesterday which likely explains why we haven't seen this earlier?

I tried using the joined form but that didn't work but that may have to be because of the quote placement. We need to use quotes around the path because of spaces (we ran into that issue before) but I'm not sure if the correct joined form is /I"${LIBCXX_GENERATED_INCLUDE_DIR}" or "/I${LIBCXX_GENERATED_INCLUDE_DIR}", do you know?

mstorsjo accepted this revision.Apr 29 2021, 12:33 PM

I'm trying to use the runtimes build on Windows and include libc++ in the build which is where I ran into this issue.

Prior to ea12d779bc238c387511fe7462020f4ecf4a8246 there was only one /I and that change only landed yesterday which likely explains why we haven't seen this earlier?

Ah, indeed, that would probably explain it.

I tried using the joined form but that didn't work but that may have to be because of the quote placement. We need to use quotes around the path because of spaces (we ran into that issue before) but I'm not sure if the correct joined form is /I"${LIBCXX_GENERATED_INCLUDE_DIR}" or "/I${LIBCXX_GENERATED_INCLUDE_DIR}", do you know?

On the windows command line quoting level, I think both of them are equally ok, but I'm not sure how this translates from the cmake level here to the actual final command line.

I'm fine with this solution in any case as it seems to be what cmake recommends. But it's a bit weird, because - doesn't this practically pass things as one single arg, containing /I<space>\path\to\dir? If that works with the compilers in practice I guess that's ok even though it's weird.

phosek updated this revision to Diff 341666.Apr 29 2021, 3:02 PM

I tested it a bit more and looks like the joined form without quotes is working so I'll go with that since it better matches what we do on other platforms.

phosek retitled this revision from [libcxx] Use shell quoting for include flag on Windows to [libcxx] Use joined format for include flag on Windows.Apr 29 2021, 3:03 PM
mstorsjo accepted this revision.Apr 29 2021, 9:03 PM

LGTM. Thanks, this feels less weird.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 30 2021, 11:40 AM
This revision was automatically updated to reflect the committed changes.