Skip to content
Commit 04b0a0bd authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin
Browse files

make: keep HOSTCFLAGS clean from target cflags

HOSTCFLAGS are populated with CFLAGS if they are set from environment:
    CFLAGS=-O1 make

But it turns out that =? operator, which sets variable iff it was unset
previously - is recursive expanded operator.
Which means that value of HOSTCFLAGS is evaluated every time it's used.

Which is wrong with the current flaw in Makefile:
    1. it assigns HOSTCFLAGS with CFLAGS from environment as recursive
    2. it assigns target-related options to CFLAGS such as -march.
    3. HOSTCFLAGS are used (with the current code - here they are expanded
       from CFLAGS).

Which results in target-related options supplied to host objects building,
which breaks cross-compilation.
Fix by omitting recursive expansion for HOSTCFLAGS.
Still we need to keep $(WARNINGS) and $(DEFINES) in HOSTCFLAGS.

Link: https://lists.openvz.org/pipermail/criu/2017-April/037109.html


Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Reported-by: default avatar"Brinkmann, Harald" <Harald.Brinkmann@bst-international.com>
Reviewed-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: default avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: default avatarAndrei Vagin <avagin@virtuozzo.com>
parent 578d57fb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment