[Buildroot] [PATCH 3/3] pkgconf: Configure using pkgconf-personality

Arnout Vandecappelle arnout at mind.be
Sat Oct 19 21:37:47 UTC 2019


 In addition to the discussion we had earlier, I have some more thoughts about this.

On 01/10/2019 14:41, Thomas Preston wrote:
> The correct way to configure pkgconf when cross-compiling is to use
> pkgconf-personality, rather than using environment variables. The
> personality is selected with a symbolic link mechanism, which we now use
> in the pkg-config wrapper script.

 I think that as a transient measure, we should still use an environment
variable, but just one this time. E.g. BR2_PKGCONF_PERSONALITY, which is set to
the proper personality (and defaults to the cross personality, like is the case
now).

 Then, when we have a solution for the @STATIC@ thing so even that is no longer
needed, we can add the personality symlinks. When those exist, they can be used
by the smart build systems (i.e. autotools and meson, and cmake by setting
PKG_CONFIG in the environment). And finally we can move the wrapper script to
the cross-dir that I proposed, if we feel like it.

 So in summary, to properly use the personality feature, we should find a
solution for @STATIC at . But until then, I do think it makes sense to use is as
much as possible, like in this patch.

 So I'm just going to give some nitpicking feedback here.

> 
> Signed-off-by: Thomas Preston <thomas.preston at codethink.co.uk>
> ---
>  package/pkgconf/pkg-config.in      | 11 +----------
>  package/pkgconf/pkgconf.mk         | 12 +++++++++++-
>  package/pkgconf/target.personality |  5 +++++
>  3 files changed, 17 insertions(+), 11 deletions(-)
>  create mode 100644 package/pkgconf/target.personality
> 
> diff --git a/package/pkgconf/pkg-config.in b/package/pkgconf/pkg-config.in
> index 894069c492..51db4d87e1 100644
> --- a/package/pkgconf/pkg-config.in
> +++ b/package/pkgconf/pkg-config.in
> @@ -1,12 +1,3 @@
>  #!/bin/sh
>  PKGCONFDIR=$(dirname $0)
> -DEFAULT_PKG_CONFIG_SYSTEM_LIBRARY_PATH=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/lib
> -DEFAULT_PKG_CONFIG_SYSTEM_INCLUDE_PATH=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/include
> -DEFAULT_PKG_CONFIG_LIBDIR=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/lib/pkgconfig:${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/share/pkgconfig
> -DEFAULT_PKG_CONFIG_SYSROOT_DIR=${PKGCONFDIR}/../@STAGING_SUBDIR@
> -
> -PKG_CONFIG_SYSTEM_LIBRARY_PATH=${PKG_CONFIG_SYSTEM_LIBRARY_PATH:-${DEFAULT_PKG_CONFIG_SYSTEM_LIBRARY_PATH}} \
> -	PKG_CONFIG_SYSTEM_INCLUDE_PATH=${PKG_CONFIG_SYSTEM_INCLUDE_PATH:-${DEFAULT_PKG_CONFIG_SYSTEM_INCLUDE_PATH}} \
> -	PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-${DEFAULT_PKG_CONFIG_LIBDIR}} \
> -	PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-${DEFAULT_PKG_CONFIG_SYSROOT_DIR}} \
> -	exec ${PKGCONFDIR}/pkgconf @STATIC@ "$@"
> +exec ${PKGCONFDIR}/@GNU_TARGET_NAME at -pkg-config @STATIC@ "$@"

 As long as the @STATIC@ is needed, I wouldn't create
@GNU_TARGET_NAME at -pkg-config, but instead use the --personality command-line option.

 And to properly support host personality, I'd allow an override through the
environment.

> diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
> index 1851ecfca4..66bc61d797 100644
> --- a/package/pkgconf/pkgconf.mk
> +++ b/package/pkgconf/pkgconf.mk
> @@ -11,15 +11,25 @@ PKGCONF_LICENSE = pkgconf license
>  PKGCONF_LICENSE_FILES = COPYING
>  
>  PKG_CONFIG_HOST_BINARY = $(HOST_DIR)/bin/pkg-config
> +PKG_CONFIG_HOST_PERSONALITYD = $(HOST_DIR)/usr/share/pkgconfig/personality.d

 We don't use $(HOST_DIR)/usr any more, it should just be $(HOST_DIR)/share/...

 More importantly, however, there's a problem here. This path is hardcoded in
the executable, which makes it non-relocatable. We try to make the SDK
relocatable. With the wrapper script, it's OK because we use relative paths
there. But it seems that the pkgconf binary encodes a few absolute paths. I
think fixing that will require some pretty invasive modifications to pkgconf...


>  
>  define PKGCONF_LINK_PKGCONFIG
>  	ln -sf pkgconf $(TARGET_DIR)/usr/bin/pkg-config
>  endef
>  
>  define HOST_PKGCONF_INSTALL_WRAPPER
> +	$(INSTALL) -m 0775 -D package/pkgconf/target.personality \

 Why is it executable? And why writable by group?

> +		$(PKG_CONFIG_HOST_PERSONALITYD)/$(GNU_TARGET_NAME).personality
> +	$(SED) 's, at STAGING_DIR@,$(STAGING_DIR),g' \
> +		$(PKG_CONFIG_HOST_PERSONALITYD)/$(GNU_TARGET_NAME).personality
> +	$(SED) 's, at GNU_TARGET_NAME@,$(GNU_TARGET_NAME),g' \
> +		$(PKG_CONFIG_HOST_PERSONALITYD)/$(GNU_TARGET_NAME).personality

 Assuming it doesn't need to be executable, the three commands above can be done
with a single sed command.

	sed -e 's, at STAGING_DIR@,$(STAGING_DIR),g' \
		-e 's, at GNU_TARGET_NAME@,$(GNU_TARGET_NAME),g' \
		package/pkgconf/target.personality \
		> $(PKG_CONFIG_HOST_PERSONALITYD)/$(GNU_TARGET_NAME).personality

But then you do need an explicit mkdir.

> +	ln -sf $(HOST_DIR)/bin/pkgconf \
> +		$(HOST_DIR)/bin/$(GNU_TARGET_NAME)-pkg-config
> +
>  	$(INSTALL) -m 0755 -D package/pkgconf/pkg-config.in \
>  		$(HOST_DIR)/bin/pkg-config
> -	$(SED) 's, at STAGING_SUBDIR@,$(STAGING_SUBDIR),g' \
> +	$(SED) 's, at GNU_TARGET_NAME@,$(GNU_TARGET_NAME),g' \
>  		$(HOST_DIR)/bin/pkg-config
>  endef
>  
> diff --git a/package/pkgconf/target.personality b/package/pkgconf/target.personality
> new file mode 100644
> index 0000000000..cee4d236c4
> --- /dev/null
> +++ b/package/pkgconf/target.personality
> @@ -0,0 +1,5 @@
> +Triplet: @GNU_TARGET_NAME@
> +SysrootDir: @STAGING_DIR@
> +DefaultSearchPaths: @STAGING_DIR@/usr/lib/pkgconfig:@STAGING_DIR@/usr/share/pkgconfig
> +SystemIncludePaths: @STAGING_DIR@/usr/include
> +SystemLibraryPaths: @STAGING_DIR@/usr/lib

 Here as well, the paths are absolute... But in this case, I think they'll get
fixed up by relocate-sdk.sh.

 Regards,
 Arnout


More information about the buildroot mailing list