Skip to content

[llvm] Fix cmake string expansion in CrossCompile.cmake #138901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/cmake/modules/CrossCompile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)

add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
-DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}"
-DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}"
-DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"
"-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
Copy link
Member

Choose a reason for hiding this comment

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

Do you have an example where you'd want to pass flags to the native build system?

Copy link
Member Author

@DavidTruby DavidTruby May 7, 2025

Choose a reason for hiding this comment

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

I didn't have one specifically for the CMAKE_MAKE_PROGRAM, I just thought I'd fx it as well while I was here as the same reasoning would apply there.
We want this for CMAKE_C/CXX_COMPILER_LAUNCHER, where we want to add flags to ccache when using LLVM_CCACHE_BUILD to control certain behaviour especially when building flang. When we tried to make that change it worked on non-Windows but didn't work on Windows, this fixes at least that case. So that's the specific motivation for the change.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose I can imagine a case where you might want to enable some debug modes in ninja with -d ...

"-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}"
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
Copy link
Contributor

@s-barannikov s-barannikov May 7, 2025

Choose a reason for hiding this comment

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

LLVM_TABLEGEN_FLAGS below should also be fixed (added recently, #138086).

${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR}
${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
Expand Down