All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: disable-pie build
Date: Sun, 12 Nov 2023 22:11:45 +0300	[thread overview]
Message-ID: <2c07a981-beae-4ade-91a5-99f989de4b7d@tls.msk.ru> (raw)
In-Reply-To: <CABgObfYYnwD+hP2kh=O0jWG5soVno4hNy2iicszgXm--5CyFUg@mail.gmail.com>

12.11.2023 20:03, Paolo Bonzini пишет:
> 
> 
> Il sab 11 nov 2023, 03:40 Michael Tokarev <mjt@tls.msk.ru <mailto:mjt@tls.msk.ru>> ha scritto:
> 
>     Hi!
> 
>     It looks like --disable-pie configure, which uses -fno-pie -no-pie flags
>     for the compiler, is broken: it does not not tell the *linker* about the
>     option, so the link fails (at least on debian bookworm):
> 
>     /usr/bin/ld: libcommon.fa.p/hw_core_cpu-common.c.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with
>     -fPIE
>     /usr/bin/ld: failed to set dynamic section sizes: bad value
> 
>     This is failing for *all* executables, including tests, qemu-img, etc.
> 
> 
> Is this new in bookworm? And also can you compare 8.0, 8.1 and 8.2?

First I observed this with 7.2, but the same happens with 8.1 and current master
(8.2-tobe).

cc -m64 -mcx16  -o subprojects/libvhost-user/link-test subprojects/libvhost-user/link-test.p/link-test.c.o -Wl,--as-needed -Wl,--no-undefined 
-Wl,--whole-archive -Wl,--start-group subprojects/libvhost-user/libvhost-user.a -Wl,--end-group -Wl,--no-whole-archive -fstack-protector-strong 
-Wl,-z,relro -Wl,-z,now -Wl,--warn-common -pthread
/usr/bin/ld: subprojects/libvhost-user/link-test.p/link-test.c.o: relocation R_X86_64_32 against `.text.unlikely' can not be used when making a PIE 
object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value

Note: there's no -no-pie in there.  With the change to add -no-pie to qemu_ldflags,
it is there and the link succeeds:

cc -m64 -mcx16  -o subprojects/libvhost-user/link-test subprojects/libvhost-user/link-test.p/link-test.c.o -Wl,--as-needed -Wl,--no-undefined 
-Wl,--whole-archive -Wl,--start-group subprojects/libvhost-user/libvhost-user.a -Wl,--end-group -Wl,--no-whole-archive -no-pie 
-fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--warn-common -pthread


And nope, this is not new in bookworm, -- it fails to build on bullseye
exactly the same way.  And it succeeds with the same change applied,
adding -no-pie to qemu_ldflags.

It looks like debian enabled pie by default in around 2018 or so.

I stumbled across this issue (with qemu can't be built on debian with --disable-pie)
several times just because I tried to run one or another CI test to reproduce some
issue, and it happened the test used --disable-pie (and most of that is executed on
redhat).

/mjt


>     diff --git a/meson.build b/meson.build
>     index a9c4f28247..0b7ca45d48 100644
>     --- a/meson.build
>     +++ b/meson.build
>     @@ -278,7 +278,8 @@ endif
>        # tries to build an executable instead of a shared library and fails.  So
>        # don't add -no-pie anywhere and cross fingers. :(
>        if not get_option('b_pie')
>     -  qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie')
>     +  qemu_common_flags += cc.get_supported_arguments('-fno-pie')
>     +  qemu_ldflags += cc.get_supported_arguments('-no-pie')
>        endif
> 
>        if not get_option('stack_protector').disabled()




      reply	other threads:[~2023-11-12 19:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-11  2:39 disable-pie build Michael Tokarev
2023-11-11 16:09 ` Paolo Bonzini
2023-11-11 20:09   ` Volker Rümelin
2023-11-12  9:13     ` Paolo Bonzini
2023-11-12 10:22       ` Michael Tokarev
2023-11-12 17:03 ` Paolo Bonzini
2023-11-12 19:11   ` Michael Tokarev [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=2c07a981-beae-4ade-91a5-99f989de4b7d@tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.