gmake: CXXFLAGS override gb_Library_add_cxxflags

Petr Mladek pmladek at suse.cz
Wed Jan 9 06:41:38 PST 2013


Hi,

CXXFLAGS are used after gb_Library_add_cxxflags in gbuild.
This causes problems because gb_Library_add_cxxflags usually enforce
some setting that is strictly needed.

For example, my LO-4.0 build for openSUSE crashes in bridge test. It is
related to omit-frame-pointer gcc feature.

+ openSUSE uses:

	CXXFLAGS=-fomit-frame-pointer ...

bridges/Library_gcc3_linux_intel.mk includes:

--- cut ---
# In case someone enabled the non-standard -fomit-frame-pointer which
does not
# work with the .cxx sources of this library.
$(eval $(call gb_Library_add_cxxflags,gcc3_uno,\
        -fno-omit-frame-pointer \
        -fno-strict-aliasing \
        $(if $(filter TRUE,$(HAVE_GCC_AVX)),\
                -mno-avx \
        ) \
))
--- cut ---

Unfortunately, CXXFLAGS is listed later on the commandline, so 
the bridge is compiled with the global -f-omit-frame-pointer and is
miscompiled.

IMHO, it would make sense to use CXXFLAGS after the default global flags
but before the source file specific flags.

Another possibility would be to introduce another macro, for example
gb_Library_add_post_cxxflags or gb_Library_add_enforcing_cxxflags.
But then we would need to convert most (if not all)
gb_Library_add_cxxflags calls to the new macro :-)

What do you think?
Could you give me some hints how to do it?

Best Regards,
Petr

PS: I have troubles to understand the related gbuild code. It seems that
both CXXFLAGS and gb_Library_add_cxxflags are added to the T_CXXFLAGS
variable, see:

--- cut solenv/gbuild/LinkTarget.mk ---
$(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS :=
$$(gb_LinkTarget_CXXFLAGS)
[...]
define gb_LinkTarget_add_cxxflags
$(call gb_LinkTarget_get_headers_target,$(1)) \ 
$(call gb_LinkTarget_get_target,$(1)) : T_CXXFLAGS += $(2)
ifeq ($(gb_FULLDEPS),$(true))
$(call gb_LinkTarget_get_dep_target,$(1)) : T_CXXFLAGS += $(2)
endif
endef
--- cut ---

It looks like T_CXXFLAGS is initialized with CXXFLAGS and
gb_LinkTarget_add_cxxflags is added at the end. Though, in reality, they
are listed in the opposite order. So, I am lost :-)



More information about the LibreOffice mailing list