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

DBUILD_WITH_CCACHE option does not work on Fedora #361

Closed
D4N opened this issue Jun 9, 2018 · 10 comments
Closed

DBUILD_WITH_CCACHE option does not work on Fedora #361

D4N opened this issue Jun 9, 2018 · 10 comments
Assignees
Milestone

Comments

@D4N
Copy link
Member

D4N commented Jun 9, 2018

The option DBUILD_WITH_CCACHE has no influence on whether ccache is used or not on Fedora (and I believe on Debian too) when ccache is installed:

cmake -DBUILD_WITH_CCACHE=OFF ..
-- The C compiler identification is GNU 8.1.1
-- The CXX compiler identification is GNU 8.1.1
-- Check for working C compiler: /usr/lib64/ccache/gcc
-- Check for working C compiler: /usr/lib64/ccache/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/lib64/ccache/g++
-- Check for working CXX compiler: /usr/lib64/ccache/g++ -- works

The problem is quite simple: once ccache is installed, it's put into $PATH before /usr/bin/ (where ordinary gcc & clang binaries sit), thus gcc resolves to ccache/gcc before our switch can do anything.

A viable alternative is to set the CCACHE_DISABLE environment variable for ccache to true. Then ccache itself will directly call the compiler if it is installed.

@piponazo
Copy link
Collaborator

Hi @D4N . I think we discussed this some time ago via Slack and we concluded that the problem here is the way in which those distributions alter the symbolic links in the system when ccache is installed.

The CMake code taking care of ccache in exiv2 is:

if( BUILD_WITH_CCACHE )
    find_program(CCACHE_FOUND ccache)
    if(CCACHE_FOUND)
        message(STATUS "Program ccache found")
        set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
        set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
    endif()
endif()

If BUILD_WITH_CCACHE is disabled, CMake will just rely in the default compiler detected in the system. There is not much we can do about it. Should we close this issue?

@D4N
Copy link
Member Author

D4N commented Aug 14, 2018 via email

@clanmills
Copy link
Collaborator

I'd like to document and close this issue. However this is very confusing. If -DBUILD_WITH_CCACHE doesn't work, we should remove it.

I think you're saying that installing ccache modifies the PATH and the correct way to enable/disable is the environment variable CCACHE_DISABLE

Of have I misunderstood?

@clanmills clanmills assigned clanmills and piponazo and unassigned clanmills Nov 28, 2018
@clanmills clanmills added this to the v0.27 milestone Nov 28, 2018
@piponazo
Copy link
Collaborator

It works normally, but in Fedora it seems there were some issues (Explained already by Dan). We do not need to do anything about the code, but Dan thought about adding some notes.

@clanmills
Copy link
Collaborator

OK. So there's something wrong on Fedora. I'll add a section to README.md concerning ccache tomorrow and I'll mention this. Then we can get this closed.

@clanmills clanmills changed the title DBUILD_WITH_CCACHE option does not work when ccache is installed DBUILD_WITH_CCACHE option does not work on Fedora Nov 28, 2018
@clanmills
Copy link
Collaborator

commit 5bb090f793113ad0efc1c280732df47179974595
Author: Robin Mills <robin@clanmills.com>
Date:   Wed Nov 28 20:24:27 2018 +0000

    Added "2.13 Building Exiv2 with ccache".

commit 6d913484ce1e86683ea662ed0fca58277c772060
Author: Robin Mills <robin@clanmills.com>
Date:   Wed Nov 28 19:08:05 2018 +0000

@D4N
Copy link
Member Author

D4N commented Nov 28, 2018

OK. So there's something wrong on Fedora.

As far as I know it is common on various Linux distros to put ccache into $PATH before the actual compiler (or it is the recommended way how to enable it), so that you get ccache without having to set CC & CXX manually. So I wouldn't describe the situation as wrong, however that default unfortunately makes the flag DBUILD_WITH_CCACHE ineffective, albeit ccache can still be turned off by setting CC & CXX to the actual compiler.

Is anyone actually using this option (I personally don't)?

@clanmills
Copy link
Collaborator

commit 19b2528c7e578195270abda6548026765df7a4d5
Author: Robin Mills <robin@clanmills.com>
Date:   Wed Nov 28 22:54:11 2018 +0000

    Revised "Building Exiv2 with ccache" in response to Dan's feedback.

commit 5bb090f793113ad0efc1c280732df47179974595
Author: Robin Mills <robin@clanmills.com>
Date:   Wed Nov 28 20:24:27 2018 +0000

@piponazo
Copy link
Collaborator

I personally use it a lot and on Ubuntu where it works as expected:

  • When BUILD_WITH_CCACHE=OFF the selection of the compiler relies solely in CC & CXX, or in the CMake arguments CMAKE_C_COMPILER and CMAKE_CXX_COMPILER.
  • When BUILD_WITH_CCACHE=ON, the selection of the compiler still relies in the previous variables, but in top of that ccache (if found) is used as the first argument in the compilation command. Note: Maybe we should make the configuration fail if ccache is not found and we are requiring it.

I actually think we could use that same CMake option to control whether clcache should be used on Windows (we could rename the variable to something like BUILD_WITH_CACHE).

@piponazo
Copy link
Collaborator

Since this is documented in #557 (which will be merged tomorrow), I'll close this issue.

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

No branches or pull requests

3 participants