[llvm] [cmake] Optimize RelWithDebInfo compiler options on windows (PR #101533)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 04:45:50 PDT 2024


GkvJwa wrote:

> > > This patch seems brittle though. What if LLVM's regular Release flags change, how do we ensure that CMAKE_CXX_FLAGS_RELWITHDEBINFO is kept in sync?
> > > Could we define CMAKE_CXX_FLAGS_RELWITHDEBINFO to be CMAKE_CXX_FLAGS_RELEASE + debug flags somewhere?
> > 
> > 
> > Sure, we can overwrite RELWITHDEBINFO based on the CMAKE_CXX_FLAGS_RELEASE flags like this
> > ```
> >   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
> >   set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
> >   set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
> > ```
> 
> Shouldn't the `LINKER_FLAGS_RELEASE` variables already include the `/OPT:` flags?
> 
> > and do we need to add some additional flags for FLAGS_RELEASE, such as /FIXED:NO
> 
> Why?

cmake `LINKER_FLAGS_RELEASE` does not include `/OPT:` flags, because it will not generate pdb on windows
I just found out in the llvm repository that there are actually setting options for release

https://github.com/llvm/llvm-project/blob/5c56b46a32a8856a022a54291bc9294068f7ddbd/llvm/cmake/modules/HandleLLVMOptions.cmake#L590-L602

But it is very obscure. People who are not familiar with llvm will not notice it at all, and it is only for release.

https://github.com/llvm/llvm-project/pull/101533


More information about the llvm-commits mailing list