Bug 11071

Summary: Building postgresql package on Debian 9.4 x64 for armel target fails
Product: buildroot Reporter: dde
Component: OtherAssignee: unassigned
Status: RESOLVED INVALID    
Severity: major CC: buildroot
Priority: P5    
Version: 2018.02.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: config.log of postgresql
build.log of buildroot postgresql
Patch for the postgresql.mk to support libxml2 if selected

Description dde 2018-06-06 10:23:18 UTC
I'm currently trying to build buildroot with the postgresql package.
I'm building on Debian Stretch x86_64.

The target configuration in buildroot is for armel:
BR2_ARCH="arm"
BR2_ENDIAN="LITTLE"
BR2_GCC_TARGET_ABI="aapcs-linux"
BR2_GCC_TARGET_CPU="arm926ej-s"
BR2_GCC_TARGET_FLOAT_ABI="soft"
BR2_GCC_TARGET_MODE="arm"
BR2_BINFMT_SUPPORTS_SHARED=y
BR2_READELF_ARCH_NAME="ARM"
BR2_BINFMT_ELF=y
BR2_ARM_CPU_MAYBE_HAS_VFPV2=y
BR2_ARM_CPU_HAS_ARM=y
BR2_ARM_CPU_HAS_THUMB=y

The configure script of postgresql throws an error for libxml2 (I build with --with-libxml as a custom option) and libz (this is standard, not changed by me):

output/host/lib/libz.so: file not recognized: File format not recognized
output/host/lib/libxml2.so: file not recognized: File format not recognized

Seems as if the host libraries are wrong.
If I replace these two libraries with the libs found in output/target/usr/lib, the build finishes without an error.

I do not have this issue on Debian Stretch x86 (32bit).

Greetings,
Daniel
Comment 1 dde 2018-06-06 10:24:12 UTC
Created attachment 7606 [details]
config.log of postgresql
Comment 2 Thomas Petazzoni 2018-06-06 11:29:41 UTC
Thanks for this report. Could you attach the build log of the postgresql package, from the extract step to the failure, and also the config.log file generated by postgresql's configure script ?

Thanks!
Comment 3 dde 2018-06-06 12:01:12 UTC
Created attachment 7611 [details]
build.log of buildroot postgresql
Comment 4 dde 2018-06-06 12:01:47 UTC
(In reply to Thomas Petazzoni from comment #2)

The config.log is already attached (it's a zip file) and I attached the build.log now.
Comment 5 Thomas Petazzoni 2018-06-06 12:32:31 UTC
Could you please build without your custom --with-libxml option ?

That's the reason for the failure. It ends up using xml2-config from your host machine, which returns bogus linker flags, which breaks the build.

So it's basically your custom addition that breaks the build, the code in Buildroot builds fine.

Please add:

POSTGRESQL_CONF_ENV += XML2_CONFIG=$(STAGING_DIR)/usr/bin/xml2-config

when enabling libxml2 support (i.e when you're passing --with-libxml). This should solve your problem.

And please submit a Buildroot patch adding this, once everything works fine. Thanks!
Comment 6 dde 2018-06-06 13:26:10 UTC
Created attachment 7616 [details]
Patch for the postgresql.mk to support libxml2 if selected

This patch enables the configure option --with-libxml for PostgreSQL if libxml is enabled.
Comment 7 dde 2018-06-06 13:29:25 UTC
(In reply to Thomas Petazzoni from comment #5)

Thanks for your reply! This solved the issue. I wouldn't have guessed something like this, but I'm not really familiar to buildroot backgrounds ;)

I attached a patch with the changes of package/postgresql.mk and this patch adds --with-libxml just if libxml is enabled. 
I hope this is ok like this ...

Greetings,
Daniel
Comment 8 Thomas Petazzoni 2018-06-06 18:52:33 UTC
Thanks! Could you submit this patch on the Buildroot mailing list ? See https://buildroot.org/downloads/manual/manual.html#submitting-patches for details on how to do that.
Comment 9 Peter Seiderer 2018-06-06 19:33:56 UTC
(In reply to dde from comment #6)
Thanks for the patch, looks good, the only missing thing
is the dependency on libxml2, e.g.:

POSTGRESQL_DEPENDENCIES += libxml2

Regards,
Peter
Comment 10 Peter Seiderer 2018-06-06 19:43:34 UTC
(In reply to Peter Seiderer from comment #9)
..and for consistency with the other options (or buildroot style) the
else branch:

ifeq ($(BR2_PACKAGE_LIBXML2),y)
POSTGRESQL_DEPENDENCIES += libxml2
POSTGRESQL_CONF_OPTS += --with-libxml
POSTGRESQL_CONF_ENV += XML2_CONFIG=$(STAGING_DIR)/usr/bin/xml2-config
else
POSTGRESQL_CONF_OPTS += --without-libxml
endif
Comment 11 dde 2018-06-07 06:16:49 UTC
(In reply to Peter Seiderer from comment #10)
Thanks for your hints! I submitted the patch to the mailing list, at least I hope that it worked ;)
Comment 12 Peter Seiderer 2018-06-07 21:02:23 UTC
(In reply to dde from comment #11)
Patch did not hit the mailing list (yet)...
Comment 13 dde 2018-06-08 06:50:06 UTC
(In reply to Peter Seiderer from comment #12)
Yes, I figured out that the mail hasn't been sent although I thought so.
I didn't manage to get the sendmail config running with our internal SMTP server so I sent the mail now manually through my private mail account.
I hope the format is correct.