From: John Snow <jsnow@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Cc: "bonzini >> Paolo Bonzini" <pbonzini@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] issue: linking 64bit glib when building for cpu=i386
Date: Tue, 23 Sep 2014 14:52:18 -0400 [thread overview]
Message-ID: <5421C162.3080503@redhat.com> (raw)
In-Reply-To: <CAJSP0QVe5Oj5PxhYo4cix_63PLy0w4J4crHMBi7EGT9yUZ3D-A@mail.gmail.com>
On 08/22/2014 05:05 AM, Stefan Hajnoczi wrote:
> On Fri, Aug 22, 2014 at 9:20 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
>> On Thu, Aug 21, 2014 at 08:10:54PM -0400, John Snow wrote:
>>> I was running a series of tests on 32 and 64 bit hosts to test for
>>> endianness and variable width issues when I noticed that I couldn't properly
>>> perform a build of "make check" against a 32bit target from a 64bit host:
>>>
>>> ../../configure --cpu=i386 && make -j4 && make check
>>>
>>> This produces some warnings in tests-cutils about overflowing variables that
>>> are of type guint64. It's been mentioned on the mailing lists before,
>>> actually: http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg00452.html
>>>
>>> The problem is that guint64 is being aliased against "unsigned long", which
>>> is only 4 bytes instead of the implied 8. This occurs because we link
>>> against the 64bit headers for glib instead of the 32bit ones when we're
>>> building for i386 from an x86_64 host.
>>>
>>> Our include flags wind up looking like: -I/usr/include/glib-2.0 but
>>> -I/usr/lib64/glib-2.0/include
>>>
>>> I was discussing the problem with Stefan:
>>>
>>> On 08/21/2014 05:03 AM, Stefan Hajnoczi wrote:
>>>> The problem is that pkg-config uses libdir=/usr/lib64 by default on
>>>> amd64 hosts. It doesn't know that gcc -m32 is being used.
>>>>
>>>> This results in glib's 64-bit headers being used where guint64 is just
>>>> unsigned long. On 32-bit hosts this is incorrect.
>>>>
>>>> Two workarounds:
>>>>
>>>> 1. yum install pkgconfig.i686 and run it instead of pkgconfig.x86_64
>>>>
>>>> 2. Use the pkg-config --define-variable libdir=/usr/lib option
>>>>
>>>> You can set PKG_CONFIG=path/to/pkg-config.i686 on QEMU's ./configure
>>>> command-line.
>>>>
>>>> This is all distro-specific :(. Any other solutions?
>>>>
>>>> Stefan
>>>>
>>>
>>> I am not extremely well versed in configure or pkg-config ninjutsu, but I
>>> must imagine that the ARCH/cpu variables we are setting in configure could
>>> help us know to call the 32bit pkg-config instead of the native 64bit
>>> version and fix this issue.
>>>
>>> Does anyone have any good ideas? Surely other projects must have run into
>>> this elsewhere.
>>
>> Distros will install pkg-config .pc files for non-native architectures
>> in a different location normally. The supported / recommended way to
>> tell pkg-config to look in these alternative dirs is to set the env
>> variable PKG_CONFIG_LIBDIR. This replaces the built-in default search
>> directory that looks for native.
>>
>> So on a Fedora / RHELL system, to make pkg-config use 32-bit libs you
>> want to set
>>
>> PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig
>>
>> which replaces the default location of /usr/lib64/pkgconfig.
>
> Nice, and Paolo sent me an automated way of doing that:
>
> On Fri, Aug 22, 2014 at 12:14:28AM +0200, Paolo Bonzini wrote:
>> You need to set PKG_CONFIG_LIBDIR to
>>
>> /usr/lib/$MULTILIBDIR/pkgconfig
>>
>> where MULTILIBDIR is
>>
>> if $CC -print-multiarch >/dev/null 2>&1; then
>> MULTILIBDIR=`$CC -print-multiarch $CFLAGS $CPPFLAGS`
>> fi
>> if test -z "$MULTILIBDIR"; then
>> MULTILIBDIR=`$CC --print-multi-os-directory $CFLAGS $CPPFLAGS`
>> fi
>>
>> This will point at /usr/lib/pkgconfig/glib-2.0.pc instead of
>> /usr/lib64/pkgconfig/glib-2.0.pc
>
> I tested that it works.
>
> Stefan
>
A barrier into introducing this into the configuration script is that
clang, used on OSX hosts, does not support these print flags.
Even worse, clang --print-multi-os-directory produces "x86_64" on Fedora
20, which will lead to an erroneous configuration.
So we'll have to look into another way to support cross-compilation for
i386 on x86_64 to avoid script breakage on other platforms.
Any other ideas? It looks as if there have been proposals in the past to
add some multi-arch awareness into pkg-config, but they haven't gone
anywhere. So some tool needs to tell pkg-config where to look, but clang
is apparently not up to the job.
Where does gcc/g++ find out about the lib directories? Or are they
baked-in per distro?
Any ideas?
--j
next prev parent reply other threads:[~2014-09-23 18:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <53F55173.6070704@redhat.com>
[not found] ` <20140821090328.GA32580@stefanha-thinkpad.redhat.com>
2014-08-22 0:10 ` [Qemu-devel] issue: linking 64bit glib when building for cpu=i386 John Snow
2014-08-22 7:40 ` Markus Armbruster
2014-08-22 7:50 ` Peter Maydell
2014-08-22 8:20 ` Daniel P. Berrange
2014-08-22 8:28 ` Peter Maydell
2014-08-22 8:34 ` Daniel P. Berrange
2014-08-22 8:46 ` Peter Maydell
2014-08-22 9:05 ` Stefan Hajnoczi
2014-09-23 18:52 ` John Snow [this message]
2014-09-23 20:20 ` Peter Maydell
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=5421C162.3080503@redhat.com \
--to=jsnow@redhat.com \
--cc=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
/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.