* [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 @ 2019-05-14 15:04 Nikolai Merinov 2019-05-14 15:49 ` Bach, Pascal ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Nikolai Merinov @ 2019-05-14 15:04 UTC (permalink / raw) To: openembedded-core The CMake takes mandatory compiler arguments from the following variables: - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers that supports several targets through command line options. e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain, used for compilers that support build with external toolchain. e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler command. CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory arguments, that belongs to CC variable with other build systems, to a compiler. Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by CMakeLists.txt files. --- meta/classes/cmake.bbclass | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass index d3f0d70847..4da4c00a09 100644 --- a/meta/classes/cmake.bbclass +++ b/meta/classes/cmake.bbclass @@ -27,27 +27,33 @@ python() { cc_list = d.getVar('CC').split() if cc_list[0] == 'ccache': d.setVar('OECMAKE_C_COMPILER', '%s %s' % (cc_list[0], cc_list[1])) + cc_arg1 = ' '.join(cc_list[2:]) else: d.setVar('OECMAKE_C_COMPILER', cc_list[0]) + cc_arg1 = ' '.join(cc_list[1:]) + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) if not d.getVar('OECMAKE_CXX_COMPILER'): cxx_list = d.getVar('CXX').split() if cxx_list[0] == 'ccache': d.setVar('OECMAKE_CXX_COMPILER', '%s %s' % (cxx_list[0], cxx_list[1])) + cxx_arg1 = ' '.join(cxx_list[2:]) else: d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) + cxx_arg1 = ' '.join(cxx_list[1:]) + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) } OECMAKE_AR ?= "${AR}" # Compiler flags -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" +OECMAKE_C_FLAGS ?= "${CFLAGS}" +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" -CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" -CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" +OECMAKE_CXX_LINK_FLAGS ?= "${CXXFLAGS} ${LDFLAGS}" OECMAKE_RPATH ?= "" OECMAKE_PERLNATIVE_DIR ??= "" @@ -85,8 +91,11 @@ $cmake_crosscompiling set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" ) set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" ) -- 2.17.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-05-14 15:04 [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Nikolai Merinov @ 2019-05-14 15:49 ` Bach, Pascal 2019-05-15 9:19 ` Nikolai Merinov 2019-05-20 20:41 ` Khem Raj 2019-06-20 14:30 ` ✗ patchtest: failure for cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 (rev2) Patchwork 2 siblings, 1 reply; 9+ messages in thread From: Bach, Pascal @ 2019-05-14 15:49 UTC (permalink / raw) To: Nikolai Merinov, openembedded-core Hi Nikolai, I think this would work. However I would like to understand the problem you are trying to solve with this. Do you have an example of a recipe this would be needed? Pascal > -----Original Message----- > From: openembedded-core-bounces@lists.openembedded.org > <openembedded-core-bounces@lists.openembedded.org> On Behalf Of > Nikolai Merinov > Sent: Dienstag, 14. Mai 2019 17:04 > To: openembedded-core@lists.openembedded.org > Subject: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler flags > through CMAKE_<LANG>_COMPILER_ARG1 > > The CMake takes mandatory compiler arguments from the following > variables: > - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for > compilers > that supports several targets through command line options. > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external > toolchain, > used for compilers that support build with external toolchain. > e.g. "clang --gcc-toolchain > ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a > compiler > command. > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass > mandatory arguments, that belongs to CC variable with other build systems, > to a compiler. > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by > CMakeLists.txt files. > --- > meta/classes/cmake.bbclass | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass index > d3f0d70847..4da4c00a09 100644 > --- a/meta/classes/cmake.bbclass > +++ b/meta/classes/cmake.bbclass > @@ -27,27 +27,33 @@ python() { > cc_list = d.getVar('CC').split() > if cc_list[0] == 'ccache': > d.setVar('OECMAKE_C_COMPILER', '%s %s' % (cc_list[0], cc_list[1])) > + cc_arg1 = ' '.join(cc_list[2:]) > else: > d.setVar('OECMAKE_C_COMPILER', cc_list[0]) > + cc_arg1 = ' '.join(cc_list[1:]) > + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): > + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) > > if not d.getVar('OECMAKE_CXX_COMPILER'): > cxx_list = d.getVar('CXX').split() > if cxx_list[0] == 'ccache': > d.setVar('OECMAKE_CXX_COMPILER', '%s %s' % (cxx_list[0], > cxx_list[1])) > + cxx_arg1 = ' '.join(cxx_list[2:]) > else: > d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) > + cxx_arg1 = ' '.join(cxx_list[1:]) > + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): > + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) > } > OECMAKE_AR ?= "${AR}" > > # Compiler flags > -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} > ${CFLAGS}" > -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} > ${CXXFLAGS}" > +OECMAKE_C_FLAGS ?= "${CFLAGS}" > +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" > OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" > OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" > -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} > ${CPPFLAGS} ${LDFLAGS}" > -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} > ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" > -CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > -CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" > +OECMAKE_CXX_LINK_FLAGS ?= "${CXXFLAGS} ${LDFLAGS}" > > OECMAKE_RPATH ?= "" > OECMAKE_PERLNATIVE_DIR ??= "" > @@ -85,8 +91,11 @@ $cmake_crosscompiling set( CMAKE_SYSTEM_NAME > `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) set( > CMAKE_SYSTEM_PROCESSOR > ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) set( > CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) > +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" > ) > set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) set( > CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) set( > CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" > ) > -- > 2.17.1 > > -- > _______________________________________________ > Openembedded-core mailing list > Openembedded-core@lists.openembedded.org > http://lists.openembedded.org/mailman/listinfo/openembedded-core ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-05-14 15:49 ` Bach, Pascal @ 2019-05-15 9:19 ` Nikolai Merinov 0 siblings, 0 replies; 9+ messages in thread From: Nikolai Merinov @ 2019-05-15 9:19 UTC (permalink / raw) To: Bach, Pascal; +Cc: openembedded-core Hi Pascal, I very often saw in proprietary projects the following code > set(CMAKE_C_FLAGS "list of flags that developer want to add") where package developer overwrite default CMAKE_C_FLAGS or CMAKE_CXX_FLAGS variables. There are several examples from github: https://github.com/psi4/psi4archive/blob/1.0.x/cmake/compilers/CFlags.cmake https://github.com/eloraiby/dna-cross-platform/blob/master/src/DNA/native/CMakeLists.txt https://github.com/JWZepf/bfsdk/blob/master/cmake/CMakeFlags_Native_GCC.txt https://github.com/redcurrant/metacd-http/blob/master/CMakeLists.txt https://github.com/HabanaAI/hl-thunk/blob/master/CMakeLists.txt https://github.com/chrisz/librain/blob/master/CMakeLists.txt https://github.com/chrishoen/Dev_RisLibLx/blob/master/CMakeLists.txt https://github.com/Farigh/yasc/blob/master/config/GccCompileOptions.cmake I suggest my changes in order to reduce risk of failure with such CMake projects. In same time suggested changes will logically tie this flags to the compiler in same manner as it tied in the CC and CXX variables. Regards, Nikolai ----- Original Message ----- From: "Bach, Pascal" <pascal.bach@siemens.com> To: "n merinov" <n.merinov@inango-systems.com>, openembedded-core@lists.openembedded.org Sent: Tuesday, May 14, 2019 8:49:57 PM Subject: RE: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Hi Nikolai, I think this would work. However I would like to understand the problem you are trying to solve with this. Do you have an example of a recipe this would be needed? Pascal > -----Original Message----- > From: openembedded-core-bounces@lists.openembedded.org > <openembedded-core-bounces@lists.openembedded.org> On Behalf Of > Nikolai Merinov > Sent: Dienstag, 14. Mai 2019 17:04 > To: openembedded-core@lists.openembedded.org > Subject: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler flags > through CMAKE_<LANG>_COMPILER_ARG1 > > The CMake takes mandatory compiler arguments from the following > variables: > - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for > compilers > that supports several targets through command line options. > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external > toolchain, > used for compilers that support build with external toolchain. > e.g. "clang --gcc-toolchain > ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a > compiler > command. > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass > mandatory arguments, that belongs to CC variable with other build systems, > to a compiler. > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by > CMakeLists.txt files. > --- > meta/classes/cmake.bbclass | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass index > d3f0d70847..4da4c00a09 100644 > --- a/meta/classes/cmake.bbclass > +++ b/meta/classes/cmake.bbclass > @@ -27,27 +27,33 @@ python() { > cc_list = d.getVar('CC').split() > if cc_list[0] == 'ccache': > d.setVar('OECMAKE_C_COMPILER', '%s %s' % (cc_list[0], cc_list[1])) > + cc_arg1 = ' '.join(cc_list[2:]) > else: > d.setVar('OECMAKE_C_COMPILER', cc_list[0]) > + cc_arg1 = ' '.join(cc_list[1:]) > + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): > + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) > > if not d.getVar('OECMAKE_CXX_COMPILER'): > cxx_list = d.getVar('CXX').split() > if cxx_list[0] == 'ccache': > d.setVar('OECMAKE_CXX_COMPILER', '%s %s' % (cxx_list[0], > cxx_list[1])) > + cxx_arg1 = ' '.join(cxx_list[2:]) > else: > d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) > + cxx_arg1 = ' '.join(cxx_list[1:]) > + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): > + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) > } > OECMAKE_AR ?= "${AR}" > > # Compiler flags > -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} > ${CFLAGS}" > -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} > ${CXXFLAGS}" > +OECMAKE_C_FLAGS ?= "${CFLAGS}" > +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" > OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" > OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" > -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} > ${CPPFLAGS} ${LDFLAGS}" > -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} > ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" > -CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > -CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" > +OECMAKE_CXX_LINK_FLAGS ?= "${CXXFLAGS} ${LDFLAGS}" > > OECMAKE_RPATH ?= "" > OECMAKE_PERLNATIVE_DIR ??= "" > @@ -85,8 +91,11 @@ $cmake_crosscompiling set( CMAKE_SYSTEM_NAME > `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) set( > CMAKE_SYSTEM_PROCESSOR > ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) set( > CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) > +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" > ) > set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) set( > CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) set( > CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" > ) > -- > 2.17.1 > > -- > _______________________________________________ > Openembedded-core mailing list > Openembedded-core@lists.openembedded.org > http://lists.openembedded.org/mailman/listinfo/openembedded-core ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-05-14 15:04 [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Nikolai Merinov 2019-05-14 15:49 ` Bach, Pascal @ 2019-05-20 20:41 ` Khem Raj 2019-06-20 14:16 ` [PATCHv2] " Nikolai Merinov 2019-06-20 14:30 ` ✗ patchtest: failure for cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 (rev2) Patchwork 2 siblings, 1 reply; 9+ messages in thread From: Khem Raj @ 2019-05-20 20:41 UTC (permalink / raw) To: Nikolai Merinov, openembedded-core On 5/14/19 8:04 AM, Nikolai Merinov wrote: > The CMake takes mandatory compiler arguments from the following variables: > - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers > that supports several targets through command line options. > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain, > used for compilers that support build with external toolchain. > e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler > command. > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory > arguments, that belongs to CC variable with other build systems, to a > compiler. > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by > CMakeLists.txt files. > --- > meta/classes/cmake.bbclass | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass > index d3f0d70847..4da4c00a09 100644 > --- a/meta/classes/cmake.bbclass > +++ b/meta/classes/cmake.bbclass > @@ -27,27 +27,33 @@ python() { > cc_list = d.getVar('CC').split() > if cc_list[0] == 'ccache': > d.setVar('OECMAKE_C_COMPILER', '%s %s' % (cc_list[0], cc_list[1])) > + cc_arg1 = ' '.join(cc_list[2:]) > else: > d.setVar('OECMAKE_C_COMPILER', cc_list[0]) > + cc_arg1 = ' '.join(cc_list[1:]) > + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): > + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) > > if not d.getVar('OECMAKE_CXX_COMPILER'): > cxx_list = d.getVar('CXX').split() > if cxx_list[0] == 'ccache': > d.setVar('OECMAKE_CXX_COMPILER', '%s %s' % (cxx_list[0], cxx_list[1])) > + cxx_arg1 = ' '.join(cxx_list[2:]) > else: > d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) > + cxx_arg1 = ' '.join(cxx_list[1:]) > + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): > + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) > } > OECMAKE_AR ?= "${AR}" > > # Compiler flags > -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" > -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" > +OECMAKE_C_FLAGS ?= "${CFLAGS}" > +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" > OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" > OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" > -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" > -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" > -CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > -CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" > +OECMAKE_CXX_LINK_FLAGS ?= "${CXXFLAGS} ${LDFLAGS}" > > OECMAKE_RPATH ?= "" > OECMAKE_PERLNATIVE_DIR ??= "" > @@ -85,8 +91,11 @@ $cmake_crosscompiling > set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) > set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) > set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) > +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" ) > set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) > set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) > set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" ) > these changes look ok, have you also tried building SDK and see if these changes are reflected in SDK as well ? ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCHv2] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-05-20 20:41 ` Khem Raj @ 2019-06-20 14:16 ` Nikolai Merinov 2019-06-24 10:24 ` [PATCHv3] " Nikolai Merinov 0 siblings, 1 reply; 9+ messages in thread From: Nikolai Merinov @ 2019-06-20 14:16 UTC (permalink / raw) To: Khem Raj; +Cc: openembedded-core [-- Attachment #1: Type: text/plain, Size: 4751 bytes --] Hi, Updated patch for the current "master" branch is attached. > have you also tried building SDK and see if these changes are reflected in SDK as well ? I checked that the changes reflected in the Extensible SDK for the "core-image-sato" image of the poky. Regards, Nikolai ----- Original Message ----- From: "Khem Raj" <raj.khem@gmail.com> To: "n merinov" <n.merinov@inango-systems.com>, "openembedded-core" <openembedded-core@lists.openembedded.org> Sent: Tuesday, May 21, 2019 1:41:46 AM Subject: Re: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 On 5/14/19 8:04 AM, Nikolai Merinov wrote: > The CMake takes mandatory compiler arguments from the following variables: > - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers > that supports several targets through command line options. > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain, > used for compilers that support build with external toolchain. > e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler > command. > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory > arguments, that belongs to CC variable with other build systems, to a > compiler. > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by > CMakeLists.txt files. > --- > meta/classes/cmake.bbclass | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass > index d3f0d70847..4da4c00a09 100644 > --- a/meta/classes/cmake.bbclass > +++ b/meta/classes/cmake.bbclass > @@ -27,27 +27,33 @@ python() { > cc_list = d.getVar('CC').split() > if cc_list[0] == 'ccache': > d.setVar('OECMAKE_C_COMPILER', '%s %s' % (cc_list[0], cc_list[1])) > + cc_arg1 = ' '.join(cc_list[2:]) > else: > d.setVar('OECMAKE_C_COMPILER', cc_list[0]) > + cc_arg1 = ' '.join(cc_list[1:]) > + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): > + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) > > if not d.getVar('OECMAKE_CXX_COMPILER'): > cxx_list = d.getVar('CXX').split() > if cxx_list[0] == 'ccache': > d.setVar('OECMAKE_CXX_COMPILER', '%s %s' % (cxx_list[0], cxx_list[1])) > + cxx_arg1 = ' '.join(cxx_list[2:]) > else: > d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) > + cxx_arg1 = ' '.join(cxx_list[1:]) > + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): > + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) > } > OECMAKE_AR ?= "${AR}" > > # Compiler flags > -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" > -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" > +OECMAKE_C_FLAGS ?= "${CFLAGS}" > +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" > OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" > OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" > -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" > -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" > -CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > -CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" > +OECMAKE_CXX_LINK_FLAGS ?= "${CXXFLAGS} ${LDFLAGS}" > > OECMAKE_RPATH ?= "" > OECMAKE_PERLNATIVE_DIR ??= "" > @@ -85,8 +91,11 @@ $cmake_crosscompiling > set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) > set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) > set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) > +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" ) > set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) > set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) > set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" ) > these changes look ok, have you also tried building SDK and see if these changes are reflected in SDK as well ? [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-cmake.bbclass-pass-mandatory-compiler-flags-through-.patch --] [-- Type: text/x-patch; name=0001-cmake.bbclass-pass-mandatory-compiler-flags-through-.patch, Size: 4086 bytes --] From 07dcf522cb4cadf211e76cd66f1897f6e22ca6e1 Mon Sep 17 00:00:00 2001 From: Nikolai Merinov <n.merinov@inango-systems.com> Date: Thu, 20 Jun 2019 14:15:14 +0500 Subject: [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 The CMake takes mandatory compiler arguments from the following variables: - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers that supports several targets through command line options. e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain, used for compilers that support build with external toolchain. e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler command. CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory arguments, that belongs to CC variable with other build systems, to a compiler. Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by CMakeLists.txt files. --- meta/classes/cmake.bbclass | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass index f80a7e2f1d..034735bc13 100644 --- a/meta/classes/cmake.bbclass +++ b/meta/classes/cmake.bbclass @@ -28,26 +28,34 @@ python() { if cc_list[0] == 'ccache': d.setVar('OECMAKE_C_COMPILER_LAUNCHER', cc_list[0]) d.setVar('OECMAKE_C_COMPILER', cc_list[1]) + cc_arg1 = ' '.join(cc_list[2:]) else: d.setVar('OECMAKE_C_COMPILER', cc_list[0]) + cc_arg1 = ' '.join(cc_list[1:]) + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) if not d.getVar('OECMAKE_CXX_COMPILER'): cxx_list = d.getVar('CXX').split() if cxx_list[0] == 'ccache': d.setVar('OECMAKE_CXX_COMPILER_LAUNCHER', cxx_list[0]) d.setVar('OECMAKE_CXX_COMPILER', cxx_list[1]) + cxx_arg1 = ' '.join(cxx_list[2:]) else: d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) + cxx_arg1 = ' '.join(cxx_list[1:]) + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) } OECMAKE_AR ?= "${AR}" # Compiler flags -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" +OECMAKE_C_FLAGS ?= "${CFLAGS}" +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" +OECMAKE_CXX_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" @@ -90,10 +98,13 @@ $cmake_crosscompiling set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" ) set( CMAKE_C_COMPILER_LAUNCHER ${OECMAKE_C_COMPILER_LAUNCHER} ) set( CMAKE_CXX_COMPILER_LAUNCHER ${OECMAKE_CXX_COMPILER_LAUNCHER} ) set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" ) -- 2.17.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCHv3] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-06-20 14:16 ` [PATCHv2] " Nikolai Merinov @ 2019-06-24 10:24 ` Nikolai Merinov 2019-06-25 8:03 ` Richard Purdie 0 siblings, 1 reply; 9+ messages in thread From: Nikolai Merinov @ 2019-06-24 10:24 UTC (permalink / raw) To: n merinov; +Cc: openembedded-core [-- Attachment #1: Type: text/plain, Size: 5381 bytes --] Patch updated with "Signed-off-by" field as required by automatic checks. ----- Original Message ----- From: "openembedded-core" <openembedded-core@lists.openembedded.org> To: "Khem Raj" <raj.khem@gmail.com> Cc: "openembedded-core" <openembedded-core@lists.openembedded.org> Sent: Thursday, June 20, 2019 7:16:07 PM Subject: [OE-core] [PATCHv2] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Hi, Updated patch for the current "master" branch is attached. > have you also tried building SDK and see if these changes are reflected in SDK as well ? I checked that the changes reflected in the Extensible SDK for the "core-image-sato" image of the poky. Regards, Nikolai ----- Original Message ----- From: "Khem Raj" <raj.khem@gmail.com> To: "n merinov" <n.merinov@inango-systems.com>, "openembedded-core" <openembedded-core@lists.openembedded.org> Sent: Tuesday, May 21, 2019 1:41:46 AM Subject: Re: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 On 5/14/19 8:04 AM, Nikolai Merinov wrote: > The CMake takes mandatory compiler arguments from the following variables: > - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers > that supports several targets through command line options. > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain, > used for compilers that support build with external toolchain. > e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler > command. > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory > arguments, that belongs to CC variable with other build systems, to a > compiler. > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by > CMakeLists.txt files. > --- > meta/classes/cmake.bbclass | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass > index d3f0d70847..4da4c00a09 100644 > --- a/meta/classes/cmake.bbclass > +++ b/meta/classes/cmake.bbclass > @@ -27,27 +27,33 @@ python() { > cc_list = d.getVar('CC').split() > if cc_list[0] == 'ccache': > d.setVar('OECMAKE_C_COMPILER', '%s %s' % (cc_list[0], cc_list[1])) > + cc_arg1 = ' '.join(cc_list[2:]) > else: > d.setVar('OECMAKE_C_COMPILER', cc_list[0]) > + cc_arg1 = ' '.join(cc_list[1:]) > + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): > + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) > > if not d.getVar('OECMAKE_CXX_COMPILER'): > cxx_list = d.getVar('CXX').split() > if cxx_list[0] == 'ccache': > d.setVar('OECMAKE_CXX_COMPILER', '%s %s' % (cxx_list[0], cxx_list[1])) > + cxx_arg1 = ' '.join(cxx_list[2:]) > else: > d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) > + cxx_arg1 = ' '.join(cxx_list[1:]) > + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): > + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) > } > OECMAKE_AR ?= "${AR}" > > # Compiler flags > -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" > -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" > +OECMAKE_C_FLAGS ?= "${CFLAGS}" > +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" > OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" > OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" > -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" > -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" > -CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > -CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" > +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" > +OECMAKE_CXX_LINK_FLAGS ?= "${CXXFLAGS} ${LDFLAGS}" > > OECMAKE_RPATH ?= "" > OECMAKE_PERLNATIVE_DIR ??= "" > @@ -85,8 +91,11 @@ $cmake_crosscompiling > set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) > set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) > set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) > +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" ) > set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) > +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) > set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) > set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) > set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" ) > these changes look ok, have you also tried building SDK and see if these changes are reflected in SDK as well ? -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-cmake.bbclass-pass-mandatory-compiler-flags-through-.patch --] [-- Type: text/x-patch; name=0001-cmake.bbclass-pass-mandatory-compiler-flags-through-.patch, Size: 4149 bytes --] From 2c59e9429a3b9fb153b639643a730839a468d2de Mon Sep 17 00:00:00 2001 From: Nikolai Merinov <n.merinov@inango-systems.com> Date: Thu, 20 Jun 2019 14:15:14 +0500 Subject: [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 The CMake takes mandatory compiler arguments from the following variables: - CMAKE_SYSROOT -- path to sysroot that should be passed to compiler. - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for compilers that supports several targets through command line options. e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external toolchain, used for compilers that support build with external toolchain. e.g. "clang --gcc-toolchain ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a compiler command. CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass mandatory arguments, that belongs to CC variable with other build systems, to a compiler. Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided by CMakeLists.txt files. Signed-off-by: Nikolai Merinov <n.merinov@inango-systems.com> --- meta/classes/cmake.bbclass | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass index f80a7e2f1d..034735bc13 100644 --- a/meta/classes/cmake.bbclass +++ b/meta/classes/cmake.bbclass @@ -28,26 +28,34 @@ python() { if cc_list[0] == 'ccache': d.setVar('OECMAKE_C_COMPILER_LAUNCHER', cc_list[0]) d.setVar('OECMAKE_C_COMPILER', cc_list[1]) + cc_arg1 = ' '.join(cc_list[2:]) else: d.setVar('OECMAKE_C_COMPILER', cc_list[0]) + cc_arg1 = ' '.join(cc_list[1:]) + if not d.getVar('OECMAKE_C_COMPILER_ARG1'): + d.setVar('OECMAKE_C_COMPILER_ARG1', cc_arg1) if not d.getVar('OECMAKE_CXX_COMPILER'): cxx_list = d.getVar('CXX').split() if cxx_list[0] == 'ccache': d.setVar('OECMAKE_CXX_COMPILER_LAUNCHER', cxx_list[0]) d.setVar('OECMAKE_CXX_COMPILER', cxx_list[1]) + cxx_arg1 = ' '.join(cxx_list[2:]) else: d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0]) + cxx_arg1 = ' '.join(cxx_list[1:]) + if not d.getVar('OECMAKE_CXX_COMPILER_ARG1'): + d.setVar('OECMAKE_CXX_COMPILER_ARG1', cxx_arg1) } OECMAKE_AR ?= "${AR}" # Compiler flags -OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" -OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" +OECMAKE_C_FLAGS ?= "${CFLAGS}" +OECMAKE_CXX_FLAGS ?= "${CXXFLAGS}" OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" -OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" -OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" +OECMAKE_C_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" +OECMAKE_CXX_LINK_FLAGS ?= "${CPPFLAGS} ${LDFLAGS}" CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}" @@ -90,10 +98,13 @@ $cmake_crosscompiling set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) +set( CMAKE_C_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) +set( CMAKE_CXX_COMPILER_ARG1 "${OECMAKE_CXX_COMPILER_ARG1}" ) set( CMAKE_C_COMPILER_LAUNCHER ${OECMAKE_C_COMPILER_LAUNCHER} ) set( CMAKE_CXX_COMPILER_LAUNCHER ${OECMAKE_CXX_COMPILER_LAUNCHER} ) set( CMAKE_ASM_COMPILER ${OECMAKE_C_COMPILER} ) +set( CMAKE_ASM_COMPILER_ARG1 "${OECMAKE_C_COMPILER_ARG1}" ) set( CMAKE_AR ${OECMAKE_AR} CACHE FILEPATH "Archiver" ) set( CMAKE_C_FLAGS "${OECMAKE_C_FLAGS}" CACHE STRING "CFLAGS" ) set( CMAKE_CXX_FLAGS "${OECMAKE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" ) -- 2.17.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCHv3] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-06-24 10:24 ` [PATCHv3] " Nikolai Merinov @ 2019-06-25 8:03 ` Richard Purdie 2019-06-25 12:39 ` Nikolai Merinov 0 siblings, 1 reply; 9+ messages in thread From: Richard Purdie @ 2019-06-25 8:03 UTC (permalink / raw) To: Nikolai Merinov; +Cc: openembedded-core On Mon, 2019-06-24 at 13:24 +0300, Nikolai Merinov via Openembedded- core wrote: > Patch updated with "Signed-off-by" field as required by automatic > checks. > > ----- Original Message ----- > From: "openembedded-core" <openembedded-core@lists.openembedded.org> > To: "Khem Raj" <raj.khem@gmail.com> > Cc: "openembedded-core" <openembedded-core@lists.openembedded.org> > Sent: Thursday, June 20, 2019 7:16:07 PM > Subject: [OE-core] [PATCHv2] cmake.bbclass: pass mandatory compiler > flags through CMAKE_<LANG>_COMPILER_ARG1 > > Hi, > > Updated patch for the current "master" branch is attached. > > > have you also tried building SDK and see if these changes are > > reflected in SDK as well ? > > I checked that the changes reflected in the Extensible SDK for the > "core-image-sato" image of the poky. > > Regards, > Nikolai > > ----- Original Message ----- > From: "Khem Raj" <raj.khem@gmail.com> > To: "n merinov" <n.merinov@inango-systems.com>, "openembedded-core" < > openembedded-core@lists.openembedded.org> > Sent: Tuesday, May 21, 2019 1:41:46 AM > Subject: Re: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler > flags through CMAKE_<LANG>_COMPILER_ARG1 > > On 5/14/19 8:04 AM, Nikolai Merinov wrote: > > The CMake takes mandatory compiler arguments from the following > > variables: > > - CMAKE_SYSROOT -- path to sysroot that should be passed to > > compiler. > > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for > > compilers > > that supports several targets through command line options. > > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external > > toolchain, > > used for compilers that support build with external toolchain. > > e.g. "clang --gcc-toolchain > > ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a > > compiler > > command. > > > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass > > mandatory > > arguments, that belongs to CC variable with other build systems, to > > a > > compiler. > > > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided > > by > > CMakeLists.txt files. > I'm afraid this caused a number of build failures and selftest issues: https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/236 (most of the selftest failures there for example are from this, as is https://autobuilder.yoctoproject.org/typhoon/#/builders/69/builds/746/steps/7/logs/step7b ) Cheers, Richard ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv3] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 2019-06-25 8:03 ` Richard Purdie @ 2019-06-25 12:39 ` Nikolai Merinov 0 siblings, 0 replies; 9+ messages in thread From: Nikolai Merinov @ 2019-06-25 12:39 UTC (permalink / raw) To: Richard Purdie; +Cc: openembedded-core Hi Richard, Can you help me to understand how I can reproduce this issue on local build? I want to try to debug it. Regards, Nikolai ----- Original Message ----- From: "Richard Purdie" <richard.purdie@linuxfoundation.org> To: "n merinov" <n.merinov@inango-systems.com> Cc: "openembedded-core" <openembedded-core@lists.openembedded.org> Sent: Tuesday, June 25, 2019 1:03:11 PM Subject: Re: [OE-core] [PATCHv3] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 On Mon, 2019-06-24 at 13:24 +0300, Nikolai Merinov via Openembedded- core wrote: > Patch updated with "Signed-off-by" field as required by automatic > checks. > > ----- Original Message ----- > From: "openembedded-core" <openembedded-core@lists.openembedded.org> > To: "Khem Raj" <raj.khem@gmail.com> > Cc: "openembedded-core" <openembedded-core@lists.openembedded.org> > Sent: Thursday, June 20, 2019 7:16:07 PM > Subject: [OE-core] [PATCHv2] cmake.bbclass: pass mandatory compiler > flags through CMAKE_<LANG>_COMPILER_ARG1 > > Hi, > > Updated patch for the current "master" branch is attached. > > > have you also tried building SDK and see if these changes are > > reflected in SDK as well ? > > I checked that the changes reflected in the Extensible SDK for the > "core-image-sato" image of the poky. > > Regards, > Nikolai > > ----- Original Message ----- > From: "Khem Raj" <raj.khem@gmail.com> > To: "n merinov" <n.merinov@inango-systems.com>, "openembedded-core" < > openembedded-core@lists.openembedded.org> > Sent: Tuesday, May 21, 2019 1:41:46 AM > Subject: Re: [OE-core] [PATCH] cmake.bbclass: pass mandatory compiler > flags through CMAKE_<LANG>_COMPILER_ARG1 > > On 5/14/19 8:04 AM, Nikolai Merinov wrote: > > The CMake takes mandatory compiler arguments from the following > > variables: > > - CMAKE_SYSROOT -- path to sysroot that should be passed to > > compiler. > > - CMAKE_<LANG>_COMPILER_TARGET -- target architecture, used for > > compilers > > that supports several targets through command line options. > > e.g. "clang --target ${CMAKE_C_COMPILER_TARGET}". > > - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN -- path to external > > toolchain, > > used for compilers that support build with external toolchain. > > e.g. "clang --gcc-toolchain > > ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}". > > - CMAKE_<LANG>_COMPILER_ARG1 -- other mandatory arguments to a > > compiler > > command. > > > > CMAKE_<LANG>_COMPILER_ARG1 is the most suitable variable to pass > > mandatory > > arguments, that belongs to CC variable with other build systems, to > > a > > compiler. > > > > Additionally usage of CMAKE_<LANG>_COMPILER_ARG1 instead of > > CMAKE_<LANG>_FLAGS reduce the risk that a variable can be overrided > > by > > CMakeLists.txt files. > I'm afraid this caused a number of build failures and selftest issues: https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/236 (most of the selftest failures there for example are from this, as is https://autobuilder.yoctoproject.org/typhoon/#/builders/69/builds/746/steps/7/logs/step7b ) Cheers, Richard ^ permalink raw reply [flat|nested] 9+ messages in thread
* ✗ patchtest: failure for cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 (rev2) 2019-05-14 15:04 [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Nikolai Merinov 2019-05-14 15:49 ` Bach, Pascal 2019-05-20 20:41 ` Khem Raj @ 2019-06-20 14:30 ` Patchwork 2 siblings, 0 replies; 9+ messages in thread From: Patchwork @ 2019-06-20 14:30 UTC (permalink / raw) To: Andrii Bordunov via Openembedded-core; +Cc: openembedded-core == Series Details == Series: cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 (rev2) Revision: 2 URL : https://patchwork.openembedded.org/series/17610/ State : failure == Summary == Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures: * Patch [v2] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Issue Patch is missing Signed-off-by [test_signed_off_by_presence] Suggested fix Sign off the patch (either manually or with "git commit --amend -s") If you believe any of these test results are incorrect, please reply to the mailing list (openembedded-core@lists.openembedded.org) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...). --- Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-06-25 12:39 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-14 15:04 [PATCH] cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 Nikolai Merinov 2019-05-14 15:49 ` Bach, Pascal 2019-05-15 9:19 ` Nikolai Merinov 2019-05-20 20:41 ` Khem Raj 2019-06-20 14:16 ` [PATCHv2] " Nikolai Merinov 2019-06-24 10:24 ` [PATCHv3] " Nikolai Merinov 2019-06-25 8:03 ` Richard Purdie 2019-06-25 12:39 ` Nikolai Merinov 2019-06-20 14:30 ` ✗ patchtest: failure for cmake.bbclass: pass mandatory compiler flags through CMAKE_<LANG>_COMPILER_ARG1 (rev2) Patchwork
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.