* disable-pie build
@ 2023-11-11 2:39 Michael Tokarev
2023-11-11 16:09 ` Paolo Bonzini
2023-11-12 17:03 ` Paolo Bonzini
0 siblings, 2 replies; 7+ messages in thread
From: Michael Tokarev @ 2023-11-11 2:39 UTC (permalink / raw)
To: QEMU Developers, Paolo Bonzini
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.
The following change fixes it:
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()
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: disable-pie build
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 17:03 ` Paolo Bonzini
1 sibling, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2023-11-11 16:09 UTC (permalink / raw)
To: Michael Tokarev, Stefan Hajnoczi; +Cc: QEMU Developers
On Sat, Nov 11, 2023 at 3:40 AM Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> 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):
Looks good, if you can send a patch perhaps Stefan can apply it (or
someone else can handle it in my stead, because I'm away next week).
Paolo
> /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.
>
> The following change fixes it:
>
> 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()
>
>C
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: disable-pie build
2023-11-11 16:09 ` Paolo Bonzini
@ 2023-11-11 20:09 ` Volker Rümelin
2023-11-12 9:13 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Volker Rümelin @ 2023-11-11 20:09 UTC (permalink / raw)
To: Paolo Bonzini, Michael Tokarev, Stefan Hajnoczi; +Cc: QEMU Developers
Am 11.11.23 um 17:09 schrieb Paolo Bonzini:
> On Sat, Nov 11, 2023 at 3:40 AM Michael Tokarev <mjt@tls.msk.ru> wrote:
>> 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):
> Looks good, if you can send a patch perhaps Stefan can apply it (or
> someone else can handle it in my stead, because I'm away next week).
>
> Paolo
No, this doesn't look good. This patch again breaks the native Windows
build with MSYS2 and mingw64 cross compile probably too.
See
https://gitlab.com/qemu-project/qemu/-/issues/1664
https://lore.kernel.org/qemu-devel/20230522080816.66320-1-pbonzini@redhat.com/
https://lore.kernel.org/qemu-devel/20230523073029.19549-1-pbonzini@redhat.com/
and the big comment above the changed lines in meson.build.
With best regards,
Volker
>> /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.
>>
>> The following change fixes it:
>>
>> 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()
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: disable-pie build
2023-11-11 20:09 ` Volker Rümelin
@ 2023-11-12 9:13 ` Paolo Bonzini
2023-11-12 10:22 ` Michael Tokarev
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2023-11-12 9:13 UTC (permalink / raw)
To: Volker Rümelin; +Cc: Michael Tokarev, Stefan Hajnoczi, QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 1809 bytes --]
Il sab 11 nov 2023, 21:09 Volker Rümelin <vr_qemu@t-online.de> ha scritto:
> No, this doesn't look good. This patch again breaks the native Windows
> build with MSYS2 and mingw64 cross compile probably too.
>
Doh, you're right of course (
https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg05486.html). We
need to add qemu_ldflags by hand to all executable.
I will look into adding no-pie support to Meson natively.
Paolo
> See
>
> https://gitlab.com/qemu-project/qemu/-/issues/1664
>
>
> https://lore.kernel.org/qemu-devel/20230522080816.66320-1-pbonzini@redhat.com/
>
> https://lore.kernel.org/qemu-devel/20230523073029.19549-1-pbonzini@redhat.com/
>
> and the big comment above the changed lines in meson.build.
>
> With best regards,
> Volker
>
> >> /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.
> >>
> >> The following change fixes it:
> >>
> >> 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()
>
>
[-- Attachment #2: Type: text/html, Size: 3144 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: disable-pie build
2023-11-12 9:13 ` Paolo Bonzini
@ 2023-11-12 10:22 ` Michael Tokarev
0 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2023-11-12 10:22 UTC (permalink / raw)
To: Paolo Bonzini, Volker Rümelin; +Cc: Stefan Hajnoczi, QEMU Developers
On 12.11.2023 12:13, Paolo Bonzini wrote:
>
>
> Il sab 11 nov 2023, 21:09 Volker Rümelin <vr_qemu@t-online.de <mailto:vr_qemu@t-online.de>> ha scritto:
>
> No, this doesn't look good. This patch again breaks the native Windows
> build with MSYS2 and mingw64 cross compile probably too.
>
>
> Doh, you're right of course (https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg05486.html <https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg05486.html>). We need to add qemu_ldflags by hand to all executable.
Hmm? With the change I mentioned, it builds fine on linux, - *all* executables are being
built fine. Without the qemu_ldflags+= part, all executables fail to build with the
same error. I'm not sure what's going on here...
I haven't tried win32 build though.
Also, it all builds fine on fedora without any change, which puzzles me.
/mjt
> >> /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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: disable-pie build
2023-11-11 2:39 disable-pie build Michael Tokarev
2023-11-11 16:09 ` Paolo Bonzini
@ 2023-11-12 17:03 ` Paolo Bonzini
2023-11-12 19:11 ` Michael Tokarev
1 sibling, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2023-11-12 17:03 UTC (permalink / raw)
To: Michael Tokarev; +Cc: QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]
Il sab 11 nov 2023, 03:40 Michael Tokarev <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?
Paolo
The following change fixes it:
>
> 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()
>
>
>
[-- Attachment #2: Type: text/html, Size: 1995 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: disable-pie build
2023-11-12 17:03 ` Paolo Bonzini
@ 2023-11-12 19:11 ` Michael Tokarev
0 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2023-11-12 19:11 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU Developers
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()
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-11-12 19:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.