Skip to content

Conversation

@akyrtzi
Copy link

@akyrtzi akyrtzi commented Dec 13, 2021

If Ninja Multi-Config is used and LLVM_TABLEGEN_USE_RELEASE_BUILD=YES is set
tablegen binaries will be built in Release, even when building for Debug configuration,
without needing a separate configured build directory just for tablegen binaries.
To get such a setup you'd configure like this:

cmake -G 'Ninja Multi-Config' /path/to/llvm-project/llvm \
     -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_CROSS_CONFIGS="Release" \
     -DLLVM_TABLEGEN_USE_RELEASE_BUILD=YES                \
   ....

…e it in Debug for `Ninja Multi-Config` generator

If `Ninja Multi-Config` is used and `LLVM_TABLEGEN_USE_RELEASE_BUILD=YES` is set
tablegen binaries will be built in `Release`, even when building for `Debug` configuration,
without needing a separate configured build directory just for tablegen binaries.
@akyrtzi
Copy link
Author

akyrtzi commented Dec 13, 2021

This is a draft to get feedback whether it makes sense to try to get it in upstream.

@akyrtzi
Copy link
Author

akyrtzi commented Dec 13, 2021

The other benefit of Ninja Multi-Config is saving configure time, particularly when switching between Debug and Release during development.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the idea itself is good, but I would like to see this tied into the existing path. Also note that the existing path is very well tested - it is part of the cross-compilation path as well.

list(TRANSFORM tblgen_includes PREPEND -I)

set(tablegen_exe ${${project}_TABLEGEN_EXE})
set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the dependency on the tablegen target? Seems ... recursive?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just following what existing code was doing, see comments earlier that start with

We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the DEPENDS list

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest splitting this change (creating two variables and using them in existing places) into a prep commit so it's clear what the function change is.


set(tablegen_exe ${${project}_TABLEGEN_EXE})
set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})
if (LLVM_TABLEGEN_USE_RELEASE_BUILD)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something that already is supported without the multi-generator support LLVM_OPTIMIZED_TABLEGEN. I'd rather key off the same option and change the implementation if we are targeting a multi-generator build.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Copy link

@dexonsmith dexonsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'll be great to have. I agree with @compnerd about improving the existing optimized tablegen feature rather than creating a new one; also, I think you should split out some prep commits to make things more clear.

list(TRANSFORM tblgen_includes PREPEND -I)

set(tablegen_exe ${${project}_TABLEGEN_EXE})
set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest splitting this change (creating two variables and using them in existing places) into a prep commit so it's clear what the function change is.


# CMake doesn't let compilation units depend on their dependent libraries on some generators.
if(NOT CMAKE_GENERATOR STREQUAL "Ninja" AND NOT XCODE)
if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT XCODE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also suggest a separate prep commit for these MATCHES changes.

@akyrtzi
Copy link
Author

akyrtzi commented Jan 25, 2022

Prep commit posted at https://reviews.llvm.org/D118100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants