Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

On Wed, Jan 09, 2013 at 03:41:38PM +0100, Petr Mladek wrote:
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 :-)

The problem is in variable inheritance. gb_LinkTarget_add_cxxobject
contains:

$(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)

but there is _no_ T_CXXFLAGS variable defined on the target yet,
therefore make creates a new _recursive_ variable. When it is expanded,
it uses the current T_CXXFLAGS variable visible at the expansion point,
which is the one inherited from the CxxObject's LinkTarget. This is why
T_CXXFLAGS set on LinkTarget end up _before_ the flags passed to
gb_LinkTarget_add_cxxobject (these contain $(CXXFLAGS)).

I think all that is needed is
-$(call gb_CxxObject_get_target,$(2)) : T_CXXFLAGS += $(3)
+$(call gb_CxxObject_get_target,$(2)) : T_OBJECT_CXXFLAGS := $(3)

and then use both T_CXXFLAGS and T_OBJECT_CXXFLAGS in
gb_CxxObject__command. (The same think must then be done for other types
of objects--C, ObjC etc.)

There is still a problem with this: gb_LinkTarget_add_cxxobject can be
used directly in makefiles, in which case the passed flags are specific
for one or more cxx files and should (IMHO) override the LinkTarget
flags, which would not be the case here. On the other side,
gb_LinkTarget_add_cxxobject is mainly used to avoid passing optimization
flags, so hopefully this would not cause a problem.

D.

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.