[PATCH] tests/tcg/meson.build: compile test with -fno-stack-protector by default

Pierrick Bouvier posted 1 patch 1 day, 22 hours ago
tests/tcg/meson.build | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] tests/tcg/meson.build: compile test with -fno-stack-protector by default
Posted by Pierrick Bouvier 1 day, 22 hours ago
Some compilers enable stack protection by default (for instance, on
archlinux). This produce a compilation error on some of our tests:

/usr/sbin/x86_64-linux-gnu-gcc tests/tcg/multiarch/system/interrupt.c -o tests/tcg/x86_64-softmmu-interrupt.test -static -MMD -MF tests/tcg/x86_64-softmmu-interrupt.d -Wall -Werror -O0 -g -fno-strict-aliasing -nostdlib -ffreestanding -Wa,--noexecstack -I tests/tcg/x86_64/system/../../minilib tests/tcg/x86_64/system/../../minilib/printf.c ../tests/tcg/x86_64/system/boot.S -Wl,-T ../tests/tcg/x86_64/system/kernel.ld -Wl,-melf_x86_64 -Wl,--no-warn-rwx-segments -Wl,--build-id=none -lgcc
/usr/bin/ld: /tmp/ccs11W6S.o: in function `print_num':
tests/tcg/x86_64/system/../../minilib/printf.c:45:(.text+0xec): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccs11W6S.o: in function `ml_printf':
tests/tcg/x86_64/system/../../minilib/printf.c:136:(.text+0x549): undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status

This flag has been previously added, but was removed when moving tcg
tests to meson, with the goal to identify which systems require it.
https://gitlab.com/qemu-project/qemu/-/commit/580731dcc87eb27a2b0dc20ec331f1ce51864c97
One of these system is archlinux.

Thus, disable stack protection by default. It has no impact on tests
results.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
 tests/tcg/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
index 75f0a52fd22..35b3dff4ef2 100644
--- a/tests/tcg/meson.build
+++ b/tests/tcg/meson.build
@@ -426,6 +426,12 @@ foreach target, plan: tcg_tests
                                       '-MMD', '-MF', '@DEPFILE@',
                                       '-Wall', '-Werror',
                                       '-O0', '-g', '-fno-strict-aliasing',
+                                      # Some host compilers (like archlinux)
+                                      # have stack protection enabled by default.
+                                      # This results in a linking error for some
+                                      # of our tests due to missing symbol
+                                      # __stack_chk_fail. Thus, disable it.
+                                      '-fno-stack-protector',
                                       cflags],
                             depfile: exe_name + '.d',
                             output: exe_name + '.test',
-- 
2.43.0
Re: [PATCH] tests/tcg/meson.build: compile test with -fno-stack-protector by default
Posted by Pierrick Bouvier 20 hours ago
On 9/24/2026 1:20 PM, Pierrick Bouvier wrote:
> Some compilers enable stack protection by default (for instance, on
> archlinux). This produce a compilation error on some of our tests:
> 
> /usr/sbin/x86_64-linux-gnu-gcc tests/tcg/multiarch/system/interrupt.c -o tests/tcg/x86_64-softmmu-interrupt.test -static -MMD -MF tests/tcg/x86_64-softmmu-interrupt.d -Wall -Werror -O0 -g -fno-strict-aliasing -nostdlib -ffreestanding -Wa,--noexecstack -I tests/tcg/x86_64/system/../../minilib tests/tcg/x86_64/system/../../minilib/printf.c ../tests/tcg/x86_64/system/boot.S -Wl,-T ../tests/tcg/x86_64/system/kernel.ld -Wl,-melf_x86_64 -Wl,--no-warn-rwx-segments -Wl,--build-id=none -lgcc
> /usr/bin/ld: /tmp/ccs11W6S.o: in function `print_num':
> tests/tcg/x86_64/system/../../minilib/printf.c:45:(.text+0xec): undefined reference to `__stack_chk_fail'
> /usr/bin/ld: /tmp/ccs11W6S.o: in function `ml_printf':
> tests/tcg/x86_64/system/../../minilib/printf.c:136:(.text+0x549): undefined reference to `__stack_chk_fail'
> collect2: error: ld returned 1 exit status
> 
> This flag has been previously added, but was removed when moving tcg
> tests to meson, with the goal to identify which systems require it.
> https://gitlab.com/qemu-project/qemu/-/commit/580731dcc87eb27a2b0dc20ec331f1ce51864c97
> One of these system is archlinux.
> 
> Thus, disable stack protection by default. It has no impact on tests
> results.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> ---
>  tests/tcg/meson.build | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

This was merged into master (efa3b9d5ac8024078225e1ab434411fdfe53b457).

Regards,
Pierrick
Re: [PATCH] tests/tcg/meson.build: compile test with -fno-stack-protector by default
Posted by Bernhard Beschow 1 day, 21 hours ago

Am 24. September 2026 20:20:12 UTC schrieb Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>:
>Some compilers enable stack protection by default (for instance, on
>archlinux). This produce a compilation error on some of our tests:
>
>/usr/sbin/x86_64-linux-gnu-gcc tests/tcg/multiarch/system/interrupt.c -o tests/tcg/x86_64-softmmu-interrupt.test -static -MMD -MF tests/tcg/x86_64-softmmu-interrupt.d -Wall -Werror -O0 -g -fno-strict-aliasing -nostdlib -ffreestanding -Wa,--noexecstack -I tests/tcg/x86_64/system/../../minilib tests/tcg/x86_64/system/../../minilib/printf.c ../tests/tcg/x86_64/system/boot.S -Wl,-T ../tests/tcg/x86_64/system/kernel.ld -Wl,-melf_x86_64 -Wl,--no-warn-rwx-segments -Wl,--build-id=none -lgcc
>/usr/bin/ld: /tmp/ccs11W6S.o: in function `print_num':
>tests/tcg/x86_64/system/../../minilib/printf.c:45:(.text+0xec): undefined reference to `__stack_chk_fail'
>/usr/bin/ld: /tmp/ccs11W6S.o: in function `ml_printf':
>tests/tcg/x86_64/system/../../minilib/printf.c:136:(.text+0x549): undefined reference to `__stack_chk_fail'
>collect2: error: ld returned 1 exit status
>
>This flag has been previously added, but was removed when moving tcg
>tests to meson, with the goal to identify which systems require it.
>https://gitlab.com/qemu-project/qemu/-/commit/580731dcc87eb27a2b0dc20ec331f1ce51864c97
>One of these system is archlinux.
>
>Thus, disable stack protection by default. It has no impact on tests
>results.

Thanks for providing the working patch so blazingly fast!

Tested-by: Bernhard Beschow <shentey@gmail.com>

>
>Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
>---
> tests/tcg/meson.build | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
>index 75f0a52fd22..35b3dff4ef2 100644
>--- a/tests/tcg/meson.build
>+++ b/tests/tcg/meson.build
>@@ -426,6 +426,12 @@ foreach target, plan: tcg_tests
>                                       '-MMD', '-MF', '@DEPFILE@',
>                                       '-Wall', '-Werror',
>                                       '-O0', '-g', '-fno-strict-aliasing',
>+                                      # Some host compilers (like archlinux)
>+                                      # have stack protection enabled by default.
>+                                      # This results in a linking error for some
>+                                      # of our tests due to missing symbol
>+                                      # __stack_chk_fail. Thus, disable it.
>+                                      '-fno-stack-protector',
>                                       cflags],
>                             depfile: exe_name + '.d',
>                             output: exe_name + '.test',
Re: [PATCH] tests/tcg/meson.build: compile test with -fno-stack-protector by default
Posted by Pierrick Bouvier 1 day, 21 hours ago
On 9/24/2026 1:43 PM, Bernhard Beschow wrote:
> 
> 
> Am 24. September 2026 20:20:12 UTC schrieb Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>:
>> Some compilers enable stack protection by default (for instance, on
>> archlinux). This produce a compilation error on some of our tests:
>>
>> /usr/sbin/x86_64-linux-gnu-gcc tests/tcg/multiarch/system/interrupt.c -o tests/tcg/x86_64-softmmu-interrupt.test -static -MMD -MF tests/tcg/x86_64-softmmu-interrupt.d -Wall -Werror -O0 -g -fno-strict-aliasing -nostdlib -ffreestanding -Wa,--noexecstack -I tests/tcg/x86_64/system/../../minilib tests/tcg/x86_64/system/../../minilib/printf.c ../tests/tcg/x86_64/system/boot.S -Wl,-T ../tests/tcg/x86_64/system/kernel.ld -Wl,-melf_x86_64 -Wl,--no-warn-rwx-segments -Wl,--build-id=none -lgcc
>> /usr/bin/ld: /tmp/ccs11W6S.o: in function `print_num':
>> tests/tcg/x86_64/system/../../minilib/printf.c:45:(.text+0xec): undefined reference to `__stack_chk_fail'
>> /usr/bin/ld: /tmp/ccs11W6S.o: in function `ml_printf':
>> tests/tcg/x86_64/system/../../minilib/printf.c:136:(.text+0x549): undefined reference to `__stack_chk_fail'
>> collect2: error: ld returned 1 exit status
>>
>> This flag has been previously added, but was removed when moving tcg
>> tests to meson, with the goal to identify which systems require it.
>> https://gitlab.com/qemu-project/qemu/-/commit/580731dcc87eb27a2b0dc20ec331f1ce51864c97
>> One of these system is archlinux.
>>
>> Thus, disable stack protection by default. It has no impact on tests
>> results.
> 
> Thanks for providing the working patch so blazingly fast!
> 
> Tested-by: Bernhard Beschow <shentey@gmail.com>
>

I'll pull it tomorrow with other series on tcg-tests 👍

>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
>> ---
>> tests/tcg/meson.build | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
>> index 75f0a52fd22..35b3dff4ef2 100644
>> --- a/tests/tcg/meson.build
>> +++ b/tests/tcg/meson.build
>> @@ -426,6 +426,12 @@ foreach target, plan: tcg_tests
>>                                       '-MMD', '-MF', '@DEPFILE@',
>>                                       '-Wall', '-Werror',
>>                                       '-O0', '-g', '-fno-strict-aliasing',
>> +                                      # Some host compilers (like archlinux)
>> +                                      # have stack protection enabled by default.
>> +                                      # This results in a linking error for some
>> +                                      # of our tests due to missing symbol
>> +                                      # __stack_chk_fail. Thus, disable it.
>> +                                      '-fno-stack-protector',
>>                                       cflags],
>>                             depfile: exe_name + '.d',
>>                             output: exe_name + '.test',