All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Vehlow <lkml@jv-coder.de>
To: Petr Vorel <pvorel@suse.cz>, ltp@lists.linux.it
Subject: Re: [LTP] [RFC] HOST_{CFLAGS,LDFLAGS} definition
Date: Thu, 27 Jan 2022 13:44:03 +0100	[thread overview]
Message-ID: <bc201166-e761-d23a-fa77-14f8552c0b13@jv-coder.de> (raw)
In-Reply-To: <YfJ6fIbFvN7rD0SR@pevik>

Hi Petr,
sorry for the resend, forgot the mailing list

Am 1/27/2022 um 11:57 AM schrieb Petr Vorel:
> Hi,
> 
> not sure what I do wrong, but due evaluation in include/mk/config.mk.in:
> 
> ifeq ($(strip $(HOST_CFLAGS)),)
> HOST_CFLAGS := $(CFLAGS)
> endif
> 
> ifeq ($(strip $(HOST_LDFLAGS)),)
> HOST_LDFLAGS := $(LDFLAGS)
> endif
> 
> HOST_CFLAGS and HOST_LDFLAGS must be defined for make (not for configure).
> Of course exporting variables works.
> 
> Also whole point of previous code was to have a default, but that's wrong.
> On some embedded platforms it fails as without properly defined HOST_CFLAGS it
> can inherit flags which aren't usable for host (e.g. -mlongcalls
> -mauto-litpools) and whole compilation fails.

Having the default is required for native builds.
The only problem I see with this is that empty HOST_CFLAGS passed
through the environment is not possible using the current
implementation. It is however possible passing en empte HOST_CFLAGS as
make parameter:

Makefile:
CFLAGS := cflags

ifeq ($(strip $(HOST_CFLAGS)),)
HOST_CFLAGS := $(CFLAGS)
endif

all:
	@echo "Value of HOST_CFLAGS: '${HOST_CFLAGS}'"


$ make
Value of HOST_CFLAGS: 'cflags'

$ make HOST_CFLAGS=host
Value of HOST_CFLAGS: 'host'

$ make HOST_CFLAGS=
Value of HOST_CFLAGS: ''


> IMHO we should change it to (i.e. not inherit anything):
> 
> HOST_CFLAGS := $(HOST_CFLAGS)
> HOST_LDFLAGS := $(HOST_LDFLAGS)
> 
> HOST_CFLAGS += $(WLDFLAGS)
> HOST_LDFLAGS += $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS)
> 
This wouldn't have any effect if HOST_CFLAGS is passed as parameter to
make and would be even worse than the current solution, if HOST_CFLAGS
is passed on the shell. You do not want any default switches, that are
not absolutely necessary, otherwise you can have the same problem as
before: Incompatibility with the host compiler.

Maybe we should learn from the kernel here. It doesn't have a
HOST_CFLAGS, just a HOSTCC. If you want to add CFLAGS for the host, you
just append it to the HOSTCC.

Joerg

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      reply	other threads:[~2022-01-27 12:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 10:57 [LTP] [RFC] HOST_{CFLAGS,LDFLAGS} definition Petr Vorel
2022-01-27 12:44 ` Joerg Vehlow [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc201166-e761-d23a-fa77-14f8552c0b13@jv-coder.de \
    --to=lkml@jv-coder.de \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.