Skip to contentSkip to conversation

Make C and CXX compiler cache in toolchainfile.cmake.in

Buildroot Michael Dick 7 participants 7 messages Mar 25, 2018 – Apr 8, 2018

lore
Share & tools
lore
#0 lore raw

Hello,

I am using buildroot to create my custom gcc toolchain and sysroot for a raspberry pi.

Therefore, I call cmake with a script to configure my project. After that, I import the project into qtcreator.

The problem is, that C and CXX compiler variables are not cached into cmake cache, so when importing the project, qtcreator calling cmake is not aware oft he configured compiler.

My suggestion ist o use this patch. Is there any reason why the compilers are not cached?

Best regards

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180325/9f6edfa3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: toolchainfile.patch
Type: application/octet-stream
Size: 800 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180325/9f6edfa3/attachment.obj>

#1 lore raw

Greetings Michael,
?

Quoted 16 lines

Sent:?Sunday, March 25, 2018 at 1:36 PM
From:?"Michael Dick" <[email protected]>
To:?buildroot at busybox.net
Subject:?[Buildroot] Make C and CXX compiler cache in toolchainfile.cmake.in

Hello,
I am using buildroot to create my custom gcc toolchain and sysroot for a raspberry pi.
?
Therefore, I call cmake with a script to configure my project. After that, I import the project into qtcreator.
The problem is, that C and CXX compiler variables are not cached into cmake cache, so when importing the project, qtcreator calling cmake is not aware oft he >configured compiler. ?
My suggestion ist o use this patch. Is there any reason why the compilers are not cached?
?
?
Best regards

Quoted 1 line

_______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot

if you are trying to use Buildroot to generate a cross compiler, than you are using the wrong too, look for crosstool-ng

Dagg.
?

#2 lore raw

Hello,

Quoted 2 lines · daggs

if you are trying to use Buildroot to generate a cross compiler, than you are using the wrong too, look for crosstool-ng

That's not quite correct at all:

1. Crosstool-NG generates just a toolchain, with no additional libraries (besides the C library). So if what you're looking for is to build application linked against a number of libraries, you need more than a "pure" toolchain, and Crosstool-NG will not help you with this, while Buildroot will.

2. Buildroot can perfectly be used to generate toolchains. See
http://toolchains.bootlin.com for an illustration.

Best regards,

Thomas Petazzoni

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
In reply to Michael Dick
Quoted 10 lines · Michael Dick

Hello,

I am using buildroot to create my custom gcc toolchain and sysroot for a raspberry pi.

?

Therefore, I call cmake with a script to configure my project. After that, I import the project into qtcreator.

Quoted 8 lines

The problem is, that C and CXX compiler variables are not cached into cmake cache, so when importing the project, qtcreator calling cmake is not aware oft he configured compiler.

?

My suggestion ist o use this patch. Is there any reason why the compilers are not cached?

Sounds to me like a good idea.

Let's add Yann, Samuel and Luca in Cc as CMake experts :-P For their
convenience, here is the patch inline:

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 65

Quoted 13 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +2 -2
@@ -58,8 +58,8 @@
 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
 # This toolchain file can be used both inside and outside Buildroot.
-set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
-set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
+set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@" CACHE STRING "C Compiler")
+set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@" CACHE STRING "CXX Compiler")
 if(@@TOOLCHAIN_HAS_FORTRAN@@)
   set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
   set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")

Michael, could you resubmit as a proper patch with commit log and
Signed-off-by? See [1].

Regards,
Arnout

[1] https://buildroot.org/downloads/manual/manual.html#submitting-patches

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#4 lore raw

Arnout, All,

On 2018-03-30 21:57 +0200, Arnout Vandecappelle spake thusly:

Quoted 7 lines · Michael Dick
Quoted 2 lines

My suggestion ist o use this patch. Is there any reason why the compilers are not cached?

Sounds to me like a good idea.

Let's add Yann, Samuel and Luca in Cc as CMake experts :-P

I wonder at what time I gained this expertise level in a tool I rarely use... ;-)

Quoted 8 lines

For their
convenience, here is the patch inline:

Quoted 5 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +0 -0
@@ -58,8 +58,8 @@
 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
Quoted 5 lines

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 62

Quoted 5 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +2 -2
 # This toolchain file can be used both inside and outside Buildroot.
-set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
-set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
+set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@" CACHE STRING "C Compiler")
+set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@" CACHE STRING "CXX Compiler")

I have absolutely no clue what this means...

Regards,
Yann E. MORIN.

Quoted 20 lines

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 65

Quoted 3 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +0 -0
 if(@@TOOLCHAIN_HAS_FORTRAN@@)
   set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
   set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")

Michael, could you resubmit as a proper patch with commit log and
Signed-off-by? See [1].

Regards,
Arnout

[1] https://buildroot.org/downloads/manual/manual.html#submitting-patches

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw
In reply to Arnout Vandecappelle

Hi,

Quoted 32 lines · Arnout Vandecappelle
Quoted 10 lines · Michael Dick

Hello,

I am using buildroot to create my custom gcc toolchain and sysroot for a raspberry pi.

?

Therefore, I call cmake with a script to configure my project. After that, I import the project into qtcreator.

Quoted 8 lines

The problem is, that C and CXX compiler variables are not cached into cmake cache, so when importing the project, qtcreator calling cmake is not aware oft he configured compiler.

?

My suggestion ist o use this patch. Is there any reason why the compilers are not cached?

Sounds to me like a good idea.

Let's add Yann, Samuel and Luca in Cc as CMake experts :-P For their
convenience, here is the patch inline:

Quoted 5 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +0 -0
@@ -58,8 +58,8 @@
 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
Quoted 5 lines

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 62

Quoted 5 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +2 -2
 # This toolchain file can be used both inside and outside Buildroot.
-set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
-set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
+set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@" CACHE STRING "C Compiler")
+set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@" CACHE STRING "CXX Compiler")

Although my cmake wisdom is definitely overrated here, I *do* have a kind of clue of what this means! :-)

I think this change makes sense, and this is confirmed by the fact that CMake does it as well by default. I tested with a minimal project:

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(hello)
add_executable(hello hello.c utils.c)
$ cmake .
[...]
$ grep COMPILER CMakeCache.txt
CMAKE_CXX_COMPILER:FILEPATH=/usr/lib/ccache/c++
CMAKE_C_COMPILER:FILEPATH=/usr/lib/ccache/cc
[...]
$
Quoted 7 lines

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 65

Quoted 3 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +0 -0
 if(@@TOOLCHAIN_HAS_FORTRAN@@)
   set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
   set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")

Michael, could you resubmit as a proper patch with commit log and
Signed-off-by? See [1].

And keep me Cc:.

Bye,

Signature · 1 line
Luca
#6 lore raw

Hi all,

Apologies for the late response.

Quoted 44 lines · Luca Ceresoli

Hi,

Quoted 32 lines · Arnout Vandecappelle
Quoted 10 lines · Michael Dick

Hello,

I am using buildroot to create my custom gcc toolchain and sysroot for a raspberry pi.

Therefore, I call cmake with a script to configure my project. After that, I import the project into qtcreator.

Quoted 8 lines

The problem is, that C and CXX compiler variables are not cached into cmake cache, so when importing the project, qtcreator calling cmake is not aware oft he configured compiler.

My suggestion ist o use this patch. Is there any reason why the compilers are not cached?

Sounds to me like a good idea.

Let's add Yann, Samuel and Luca in Cc as CMake experts :-P For their
convenience, here is the patch inline:

Quoted 5 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +0 -0
@@ -58,8 +58,8 @@
 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
Quoted 5 lines

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 62

Quoted 5 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +2 -2
 # This toolchain file can be used both inside and outside Buildroot.
-set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
-set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
+set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@" CACHE STRING "C Compiler")
+set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@" CACHE STRING "CXX Compiler")

Although my cmake wisdom is definitely overrated here, I *do* have a kind of clue of what this means! :-)

Quoted 2 lines

I think this change makes sense, and this is confirmed by the fact that CMake does it as well by default. I tested with a minimal project:

I second, I even wonder why I did not add it for the complers paths in the first place whereas I did add it to the various compiler flags variables... :-/

Quoted 23 lines
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(hello)
add_executable(hello hello.c utils.c)
$ cmake .
[...]
$ grep COMPILER CMakeCache.txt
CMAKE_CXX_COMPILER:FILEPATH=/usr/lib/ccache/c++
CMAKE_C_COMPILER:FILEPATH=/usr/lib/ccache/cc
[...]
$
Quoted 7 lines

tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 line 65

Quoted 3 lines
tmp/toolchainfile.cmake.in 2018-03-25 12:32:52.647000419 +0200 renamed from tmp/toolchainfile.cmake.in.orig 2018-03-25 12:32:03.353000419 +0200 +0 -0
 if(@@TOOLCHAIN_HAS_FORTRAN@@)
   set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
   set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")

Michael, could you resubmit as a proper patch with commit log and
Signed-off-by? See [1].

And keep me Cc:.

Quoted 8 lines

Bye,
--
Luca

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Regards,

Signature · 1 line
Samuel