Re: [PATCH] cmake: read asm flags correctly from environment in toolchain file


Martin Beeger
 

The docs say that cmake is consuming ASMFLAGS (https://cmake.org/cmake/help/v3.23/envvar/ASM_DIALECTFLAGS.html). If that is not the correct spelling for the given langage mode for gcc, we should probably set CMAKE_AS_FLAGS instead and assume the general mechanism in https://cmake.org/cmake/help/v3.23/variable/CMAKE_LANG_FLAGS.html works.
It seems the best option to not provide the line at all in this case,
as the default set here is unlikely to be correct then.

Are there any projects/recipes who are known to use cmake in combination with providing direct assembly files and linking them to programs (in openembedded)?





Am 15.02.22 um 15:18 schrieb Peter Kjellerstedt:

-----Original Message-----
From: openembedded-core@... <openembedded-
core@...> On Behalf Of Martin Beeger
Sent: den 14 februari 2022 17:32
To: Richard Purdie <richard.purdie@...>; openembedded-
core@...
Subject: Re: [OE-core] [PATCH] cmake: read asm flags correctly from
environment in toolchain file


I'm a little more puzzled on this one since whilst we set CFLAGS and
CXXFLAGS in
bitbake.conf, we don't set ASMFLAGS and it wouldn't be present in our
environment.

Perhaps this should be $ENV{CFLAGS} instead of ${CMAKE_C_FLAGS}? There
are flags
in our CFLAGS which like need to be passed to the assembler too?
I am a bit unsure now about this.
As far as I understand the environment-setup will not set ASMFLAGS, that
is correct. For all non-cmake recipes, the compiler will not pick up
CFLAGS instead. It will simply still use no extra parameters for the
inline assembly.
In cmake it will use the CFLAGS for the ASM too, yielding inconsistent
behaviour over build systems. Is that really a good thing?

Also the CFLAGS are usually "-O2 -g". At least the -g parameter will
have limited effect for the assembly, and optimizations for inline
assembly are also extremely limited.
So the practical difference between both modes and whether the flags
propagate through is minimal, if at all existent.

All critical compiler parameters like the --sysroot and others are not
stored in CFLAGS, but are instead directly appended to the compiler
executable path for CC, CXX and so on. These are always applied and
cmake does understand these, parses them out, forces them to always be
there etc.
This code has nothing to do with that, it only impacts the optimization
and debugging flags.

This patch makes this behaviour consistent between cmake and non-cmake
recipes in that is never applies ASM flags, instead of inconsistently
applying them.
For the record, the variable name that, e.g., make expects for assembler
flags in its default rules is "ASFLAGS", not "ASMFLAGS".
//Peter

Join openembedded-core@lists.openembedded.org to automatically receive all group messages.