Bug 2037724 - The CMake toolchains specify CMAKE_C_COMPILER/CMAKE_CXX_COMPILER with full path, effectively prevent use of ccache
Summary: The CMake toolchains specify CMAKE_C_COMPILER/CMAKE_CXX_COMPILER with full pa...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mingw-filesystem
Version: 35
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kalev Lember
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-06 12:44 UTC by Hedayat Vatankhah
Modified: 2022-01-18 01:55 UTC (History)
6 users (show)

Fixed In Version: mingw-filesystem-128-1.fc35
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-18 01:55:18 UTC
Type: Bug


Attachments (Terms of Use)

Description Hedayat Vatankhah 2022-01-06 12:44:52 UTC
Description of problem:
The cmake toolchain file for mingw is defined with absolute paths for C/C++ compilers, therefore the symlinks provided by ccache are not used and you cannot use ccache easily (even specifying CMAKE_CXX_COMPILER/CMAKE_C_COMPILER variables on command line doesn't override the ones provided by the toolchain file.

Version-Release number of selected component (if applicable):
mingw64-filesystem-119-2.fc35.noarch

Even if using absolute path are somehow justified, at least provide some way to select a ccache  based toolchain instead!

Comment 1 Hedayat Vatankhah 2022-01-06 13:04:12 UTC
Well, I just found that using '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' works; but still it'd be better if it can work by default.

Comment 2 Fedora Update System 2022-01-06 13:41:13 UTC
FEDORA-2022-2730d809df has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-2730d809df

Comment 3 Fedora Update System 2022-01-07 01:22:46 UTC
FEDORA-2022-2730d809df has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-2730d809df`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-2730d809df

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 Hedayat Vatankhah 2022-01-08 17:41:27 UTC
Are we expected to set CC/CXX env variables for it to work? Because, while in https://src.fedoraproject.org/rpms/mingw-filesystem/c/5788afad0b23f2970b6f056f79bfd38aa439a568?branch=f35 the addresses became relative, in https://src.fedoraproject.org/rpms/mingw-filesystem/c/ea5c8fc32e7a792782d6bc63aeafce5c324ca409?branch=f35 they are made absolute again; but it preserves environment variables if defined. So, it seems that if we do not define these variables, the compilers are still sepecified with absolute paths.

Comment 5 Sandro Mani 2022-01-08 17:48:59 UTC
The variables need to be a full path according to [1] (and indeed cmake broke when I had set them to relative paths). But, you can use the mingw32-cmake resp mingw64-cmake wrapper scripts to build your project, these scripts set the CC/CXX env-vars as relative paths, and ccache will work.


[1] https://cmake.org/cmake/help/v3.9/variable/CMAKE_LANG_COMPILER.html#variable:CMAKE_%3CLANG%3E_COMPILER

Comment 6 Hedayat Vatankhah 2022-01-08 17:56:26 UTC
Thanks for your prompt response.

I don't know why, but it doesn't work. I always use mingwXX-cmake wrapper scripts; but it still doesn't use ccache provided symlinks and chooses the compiler in /usr/bin. I even tried to export CXX and MINGW64_CXX variables to ccache links, but it still doesn't use them. Don't know why.

Comment 7 Sandro Mani 2022-01-08 17:57:50 UTC
Did you try clearing the CMakeCache folder?

Comment 8 Hedayat Vatankhah 2022-01-08 18:06:51 UTC
Yes, I create an empty build directory (Not related to this bug, but I wonder if Boost_ARCHITECTURE should also be set in the toolchain file):

hedayat@fedora Projects/powerfake] [master]% cd new.o 
[hedayat@fedora powerfake/new.o] [master]% mingw64-cmake ..
[hedayat@fedora powerfake/new.o] [master]% mingw64-cmake -DBoost_ARCHITECTURE=-x64 ..                                  
-- The CXX compiler identification is GNU 11.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/x86_64-w64-mingw32/sys-root/mingw/include (found version "1.75.0") found components: unit_test_framework 
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_INSTALL_LIBDIR
    INCLUDE_INSTALL_DIR
    SHARE_INSTALL_PREFIX
    SYSCONF_INSTALL_DIR


-- Build files have been written to: /home/hedayat/Projects/powerfake/new.o

[hedayat@fedora powerfake/new.o] [master]% make  VERBOSE=1 
[...]
make[2]: Entering directory '/home/hedayat/Projects/powerfake/new.o'
[  5%] Building CXX object CMakeFiles/powerfake.dir/powerfake.cpp.obj
/usr/bin/x86_64-w64-mingw32-g++ -DBOOST_ALL_DYN_LINK  -Wall -Wextra -Woverloaded-virtual -Wpedantic -fstack-protector-strong -std=gnu++17 -MD -MT CMakeFiles/powerfake.dir/powerfake.cpp.obj -MF CMakeFiles/powerfake.dir/powerfake.cpp.obj.d -o CMakeFiles/powerfake.dir/powerfake.cpp.obj -c /home/hedayat/Projects/powerfake/powerfake.cpp

Comment 9 Sandro Mani 2022-01-08 18:35:01 UTC
My bad, the syntax for checking whether the env-vars are set was incorrect in the toolchain files. Fixed mingw-filesystem-127-1.fc35 building now.

Comment 10 Fedora Update System 2022-01-08 18:48:42 UTC
FEDORA-2022-4083a68332 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-4083a68332

Comment 11 Hedayat Vatankhah 2022-01-08 18:49:45 UTC
Thanks, tried the changes in the latest commit and it works fine. :)

Sorry to ask again, but isn't it appropriate to also set Boost_ARCHITECTURE in the toolchain file? Without it, boost libraries are not properly found.

BTW, I guess this bug can be closed.

Comment 12 Sandro Mani 2022-01-08 18:59:09 UTC
How is your Boost getting detected? /usr/share/cmake/Modules/FindBoost.cmake should already contain code to detect the boost library architecture tag (look for _boost_ARCHITECTURE_TAG).

(This bug will automatically get closed when the update is pushed to stable)

Comment 13 Hedayat Vatankhah 2022-01-08 19:16:50 UTC
I use this (You can try building this using mingw: https://github.com/hedayat/powerfake):

find_package(Boost REQUIRED COMPONENTS unit_test_framework)

But it doesn't find boost libraries if I don't define Boost_ARCHITECTURE explicitly on cmake command execution.

Comment 14 Hedayat Vatankhah 2022-01-08 19:23:46 UTC
Apparently, CMAKE_CXX_COMPILER_ARCHITECTURE_ID which is used by FindBoost does not have any values.

Comment 15 Sandro Mani 2022-01-08 20:25:27 UTC
Does this help: https://koji.fedoraproject.org/koji/taskinfo?taskID=80997847 ?

Comment 16 Hedayat Vatankhah 2022-01-08 20:43:31 UTC
Not exactly. When I run mingw64-cmake in an empty build directory, it fails and FindBoost sees an empty CMAKE_CXX_COMPILER_ARCHITECTURE_ID. But if I run mingw64-cmake again in the same directory, it'll see CMAKE_CXX_COMPILER_ARCHITECTURE_ID and detect boost.

Comment 17 Hedayat Vatankhah 2022-01-08 21:05:10 UTC
Apparently, this is a known bug and specifying Boost_ARCHITECTURE is a workaround specifically for this problem:

https://gitlab.kitware.com/cmake/cmake/-/issues/18553

https://gitlab.kitware.com/cmake/cmake/-/issues/17702

https://gitlab.kitware.com/cmake/cmake/-/issues/17701

Comment 18 Sandro Mani 2022-01-08 22:23:19 UTC
Ok, so I guess just setting Boost_ARCHITECTURE as you suggested is the easiest way, please try https://koji.fedoraproject.org/koji/taskinfo?taskID=81000281

Comment 19 Hedayat Vatankhah 2022-01-08 22:39:42 UTC
Yeah, and I agree that it is an ugly workaround for that cmake bug :(

Anyway, please the it to "-x64" rather than "x64"; and it'll work:

set(Boost_ARCHITECTURE "-x64")

Thanks

Comment 20 Hedayat Vatankhah 2022-01-08 23:02:13 UTC
And for 32bit mode, it should be "-x32" rather than "x86".

Comment 21 Fedora Update System 2022-01-09 02:02:38 UTC
FEDORA-2022-4083a68332 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-4083a68332`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-4083a68332

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 22 Sandro Mani 2022-01-09 08:29:15 UTC
Ok, done in mingw-filesystem-128 proper. Thanks for reporting!

Comment 23 Hedayat Vatankhah 2022-01-09 09:36:06 UTC
You're welcome, and thank you for your dedication.

Comment 24 Fedora Update System 2022-01-10 01:46:26 UTC
FEDORA-2022-b023907185 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-b023907185`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-b023907185

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 25 Fedora Update System 2022-01-18 01:55:18 UTC
FEDORA-2022-b023907185 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.