Linux Documentation
 help / color / mirror / Atom feed
From: Nicolas Schier <nsc@kernel.org>
To: Trevor Woerner <twoerner@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Gang Yan" <yangang@kylinos.cn>,
	"David Disseldorp" <ddiss@suse.de>,
	"Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Luis Augenstein" <luis.augenstein@tngtech.com>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Andrew Jones" <andrew.jones@linux.dev>,
	linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH] kbuild: let the environment set HOSTPKG_CONFIG
Date: Sat, 8 Aug 2026 07:31:17 +0200	[thread overview]
Message-ID: <ana_JYJJY5Gqycj6@levanger> (raw)
In-Reply-To: <20260805055438.3482019-1-twoerner@gmail.com>

[resending from 2026-08-05, as my mail client broke the reply recipient
 list]

On Wed, Aug 05, 2026 at 01:54:35AM -0400, Trevor Woerner wrote:
> HOSTPKG_CONFIG was added so that "tooling that builds the kernel" could
> choose which pkg-config the host tools ask about their dependencies, but
> it is assigned with '=', so only a make command line assignment takes
> effect. Exporting it does nothing, silently.
> 
> That is surprising, because the other inputs to host program builds do
> honour the environment: HOSTCFLAGS, HOSTCXXFLAGS, HOSTLDFLAGS and
> HOSTLDLIBS are all read from it and documented in kbuild.rst as such.
> 
> It also matters. A cross development environment sets
> PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH so that pkg-config answers
> for the target rather than the build machine. Those settings are correct
> for everything that will run on the target and wrong for a program that
> has to run on the build machine. objtool asks pkg-config where libelf is,
> gets the target's include directory, and compiles a host tool against
> the target's C library headers. Because the directory arrives as -I it
> is not treated as a system header directory, -Wno-system-headers no
> longer covers it, and the build stops on warnings that would otherwise
> be suppressed:
> 
>   usr/include/sys/cdefs.h:486: error: "__attribute_const__" redefined [-Werror]
>   tools/include/linux/compiler.h:123: note: previous definition
>   usr/include/stdio.h:449: error: redundant redeclaration of 'fscanf'
> 
> An environment that knows it is cross building can then say
> 
>   export HOSTPKG_CONFIG="env -u PKG_CONFIG_SYSROOT_DIR \
>                              -u PKG_CONFIG_PATH pkg-config"
> 
> once, in the shell it hands to the user, instead of every make command
> line growing an override.

Thank for the patch with the detailed description.  This sounds to be
consistent, but looking at the other variables that effectively can be
set via environment it looks differently to me:  Environment variables
are honoured especially for _flags_, while most variables for _tooling
paths_ (e.g. HOSTCC) are to be overriden via make command line (w/
exceptions e.g. CROSS_COMPILE, LLVM).  Right now, I am not aware of the
reason for this distinction, but before opening the gate for tooling
overrides via environment, we should think it through (aka Chesterton's
Fence).

Another simple way of not piling up overrides could be something like:

    cat <<-eof >Makefile.cross
    override HOSTPKG_CONFIG := env -u PKG_CONFIG_SYSROOT_DIR -u PKG_CONFIG_PATH pkg-config
    include Makefile
    eof

    make -f Makefile.cross

So, I suggest to wait a bit and see if further arguments come up.

Kind regards,
Nicolas

      reply	other threads:[~2026-08-08  5:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  5:54 [PATCH] kbuild: let the environment set HOSTPKG_CONFIG Trevor Woerner
2026-08-08  5:31 ` Nicolas Schier [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=ana_JYJJY5Gqycj6@levanger \
    --to=nsc@kernel.org \
    --cc=andrew.jones@linux.dev \
    --cc=corbet@lwn.net \
    --cc=ddiss@suse.de \
    --cc=gary@garyguo.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=luis.augenstein@tngtech.com \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=twoerner@gmail.com \
    --cc=yangang@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox