From: Richard Palethorpe via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: mdoucha@suse.com, Richard Palethorpe <rpalethorpe@suse.com>
Subject: [LTP] [PATCH] kvm: Fix Nix build failure by moving -fno-stack-protector to CFLAGS
Date: Tue, 19 Sep 2023 09:38:27 +0100 [thread overview]
Message-ID: <20230919083827.8423-1-rpalethorpe@suse.com> (raw)
Nix (and by extension NixOS) uses a binutils wrapper of some sort to
allow switching between toolchains. This seems to be causing a problem
for the KVM tests although it may not be unique to Nix.
gcc -I/home/rich/kernel/ltp/testcases/kernel/kvm/include -DCOMPILE_PAYLOAD -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx\
-mno-sse -fno-pie -c -o lib_guest.o lib_guest.c
as -c -o bootstrap_x86_64.o bootstrap_x86_64.S
gcc -I/home/rich/kernel/ltp/testcases/kernel/kvm/include -DCOMPILE_PAYLOAD -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx\
-mno-sse -fno-pie -c -o lib_x86.o lib_x86.c
gcc -I/home/rich/kernel/ltp/testcases/kernel/kvm/include -I../../../include -I../../../include -I../../../include/old/ -DCOMPILE_PAYLOAD -ff\
reestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse -fno-pie -nostdlib -Wl,--build-id=none -fno-stack-protector -z noexe\
cstack -no-pie -Wl,-T/home/rich/kernel/ltp/testcases/kernel/kvm/linker/x86_64.lds -o kvm_pagefault01-payload.elf kvm_pagefault01.c lib_guest\
.o bootstrap_x86_64.o lib_x86.o
/nix/store/inq79dwl8sz1ygmfbgsmg77i5cwmdjpz-binutils-2.40/bin/ld: lib_x86.o: in function `kvm_init_guest_vmcb':
lib_x86.c:(.text+0x7b3): undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
make: *** [Makefile:58: kvm_pagefault01-payload.o] Error 1
__stack_chk_fail is added to lib_x86.o which means that
-fstack-protector somehow gets added to the compilation of lib_x86.o.
Swapping -fno-stack-protector from the LD flags to the C flags ensures
it is disabled when compiling lib_x86.o.
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
testcases/kernel/kvm/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
index d9eb10728..ce4a5ede2 100644
--- a/testcases/kernel/kvm/Makefile
+++ b/testcases/kernel/kvm/Makefile
@@ -8,8 +8,8 @@ include $(top_srcdir)/include/mk/testcases.mk
ASFLAGS =
CPPFLAGS += -I$(abs_srcdir)/include
GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD
-GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse
-GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none -fno-stack-protector -z noexecstack
+GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -fno-stack-protector -mno-mmx -mno-sse
+GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none -z noexecstack
GUEST_LDLIBS =
KVM_LD ?= $(LD)
--
2.42.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2023-09-19 8:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 8:38 Richard Palethorpe via ltp [this message]
2023-09-19 12:51 ` [LTP] [PATCH] kvm: Fix Nix build failure by moving -fno-stack-protector to CFLAGS Martin Doucha
2023-09-20 7:41 ` Richard Palethorpe
2023-09-20 7:56 ` Petr Vorel
2023-09-22 7:56 ` Petr Vorel
2023-09-22 8:20 ` Richard Palethorpe
2023-09-22 9:03 ` Petr Vorel
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=20230919083827.8423-1-rpalethorpe@suse.com \
--to=ltp@lists.linux.it \
--cc=mdoucha@suse.com \
--cc=rpalethorpe@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox