[PATCH] D116709: [CMake][WinMsvc] Fix user passed compiler/linker flags

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 04:04:58 PST 2022


mstorsjo added a comment.

> User could pass flags by environment variables like CFLAGS/CXXFLAGS/LDFLAGS or by using CMAKE_<LANG>_FLAGS_INIT/CMAKE_<t>_LINKER_FLAGS_INIT. So this toolchain file should append to INIT flags instead. Otherwise, user flags would be discarded here by assigning to CMAKE_<LANG>_FLAGS directly.

Can you elaborate a bit more here so I follow properly (with more explanation of exactly what cmake does here)? If the user has set e.g. `CXXFLAGS`, that does end up picked up by cmake and set in `CMAKE_CXX_FLAGS_INIT` - is that correct? What happened before, when we appended things into `CMAKE_CXX_FLAGS` without taking `CMAKE_CXX_FLAGS_INIT` into account - were the flags from `CXXFLAGS` and/or `CMAKE_CXX_FLAGS_INIT` missed/forgotten/overridden? Can you explain the implicit cmake behavious that are at play here?

> Also, for the native tool build, target flags should not be used.

Flags specified to the main cmake build (`CMAKE_<LANG>_FLAGS*`) shouldn't be propagated automatically to the inner native cmake build, or am I missing something?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116709/new/

https://reviews.llvm.org/D116709



More information about the llvm-commits mailing list