Skip to content
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

[deps] Deal with USECCACHE=1 in common CMake options #50146

Merged
merged 2 commits into from
Jun 28, 2023
Merged

Conversation

giordano
Copy link
Contributor

I haven't tested this thoroughly but something like this should make building an external LLVM more USECCACHE-friendly, saving lots of time when recompiling code.

@giordano giordano added domain:building Build system, or building Julia or its dependencies external dependencies Involves LLVM, OpenBLAS, or other linked libraries compiler:llvm For issues that relate to LLVM labels Jun 12, 2023
Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

I thought we were already suppose to have support for this in tools/common.mk in CMAKE_COMMON

@giordano
Copy link
Contributor Author

Ah, that's a better file where to do this, I'll move it there, but it doesn't deal with USECCACHE at all, so you get

$ make print-CMAKE_COMMON USECCACHE=1
CMAKE_COMMON=-DCMAKE_INSTALL_PREFIX:PATH=/home/mose/repo/julia/usr -DCMAKE_PREFIX_PATH=/home/mose/repo/julia/usr -DLIB_INSTALL_DIR=/home/mose/repo/julia/usr/lib -DCMAKE_C_COMPILER="$(which ccache)" -DCMAKE_C_COMPILER_ARG1="gcc -m64 " -DCMAKE_CXX_COMPILER="ccache" -DCMAKE_CXX_COMPILER_ARG1="g++ -m64 " -DCMAKE_LINKER="$(which ld)" -DCMAKE_AR="$(which ar)" -DCMAKE_RANLIB="$(which ranlib)"

CMAKE_C{,XX}_COMPILER are set to ccache, which is wrong.

@giordano giordano changed the title Make deps/llvm.mk USECCACHE-friendly [deps] Deal with USECCACHE=1 in common CMake options Jun 16, 2023
@giordano giordano removed the compiler:llvm For issues that relate to LLVM label Jun 16, 2023
@giordano
Copy link
Contributor Author

Ok, I moved this to deps/tools/common.mk.

Before PR:

% make print-CMAKE_COMMON             
CMAKE_COMMON=-DCMAKE_INSTALL_PREFIX:PATH=/home/mose/repo/julia/usr -DCMAKE_PREFIX_PATH=/home/mose/repo/julia/usr -DLIB_INSTALL_DIR=/home/mose/repo/julia/usr/lib -DCMAKE_C_COMPILER="$(which gcc)" -DCMAKE_C_COMPILER_ARG1="-m64 " -DCMAKE_CXX_COMPILER="g++" -DCMAKE_CXX_COMPILER_ARG1="-m64 " -DCMAKE_LINKER="$(which ld)" -DCMAKE_AR="$(which ar)" -DCMAKE_RANLIB="$(which ranlib)"
% make USECCACHE=1 print-CMAKE_COMMON 
CMAKE_COMMON=-DCMAKE_INSTALL_PREFIX:PATH=/home/mose/repo/julia/usr -DCMAKE_PREFIX_PATH=/home/mose/repo/julia/usr -DLIB_INSTALL_DIR=/home/mose/repo/julia/usr/lib -DCMAKE_C_COMPILER="$(which ccache)" -DCMAKE_C_COMPILER_ARG1="gcc -m64 " -DCMAKE_CXX_COMPILER="ccache" -DCMAKE_CXX_COMPILER_ARG1="g++ -m64 " -DCMAKE_LINKER="$(which ld)" -DCMAKE_AR="$(which ar)" -DCMAKE_RANLIB="$(which ranlib)"

With PR:

% make print-CMAKE_COMMON            
CMAKE_COMMON=-DCMAKE_INSTALL_PREFIX:PATH=/home/mose/repo/julia/usr -DCMAKE_PREFIX_PATH=/home/mose/repo/julia/usr -DLIB_INSTALL_DIR=/home/mose/repo/julia/usr/lib -DCMAKE_C_COMPILER="$(which gcc)" -DCMAKE_C_COMPILER_ARG1="-m64 " -DCMAKE_CXX_COMPILER="$(which g++)" -DCMAKE_CXX_COMPILER_ARG1="-m64 " -DCMAKE_LINKER="$(which ld)" -DCMAKE_AR="$(which ar)" -DCMAKE_RANLIB="$(which ranlib)"
% make USECCACHE=1 print-CMAKE_COMMON 
CMAKE_COMMON=-DCMAKE_INSTALL_PREFIX:PATH=/home/mose/repo/julia/usr -DCMAKE_PREFIX_PATH=/home/mose/repo/julia/usr -DLIB_INSTALL_DIR=/home/mose/repo/julia/usr/lib -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER="$(which gcc)" -DCMAKE_C_COMPILER_ARG1="-m64 " -DCMAKE_CXX_COMPILER="$(which g++)" -DCMAKE_CXX_COMPILER_ARG1="-m64 " -DCMAKE_LINKER="$(which ld)" -DCMAKE_AR="$(which ar)" -DCMAKE_RANLIB="$(which ranlib)"

# `ccache` must be used as compiler launcher, not compiler itself.
CMAKE_COMMON += -DCMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_COMMON += -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
CMAKE_CC := "$$(which $(shell echo $(CC_ARG) | cut -d' ' -f1))"
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Shouldn’t this be CC_BASE, not CC_ARG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No:

% make USECCACHE=1 print-CC_ARG print-CC_BASE print-CC print-CC_FULL 
CC_ARG=gcc -m64
CC_BASE=ccache
CC=ccache gcc -m64
CC_FULL=ccache gcc

@staticfloat staticfloat merged commit e6d67a7 into master Jun 28, 2023
1 check passed
@staticfloat staticfloat deleted the mg/llvm-ccache branch June 28, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:building Build system, or building Julia or its dependencies external dependencies Involves LLVM, OpenBLAS, or other linked libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants