* [PATCH] selftests: kvm: Fix libkvm build error
@ 2019-09-24 20:14 Shuah Khan
2019-09-25 7:48 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2019-09-24 20:14 UTC (permalink / raw)
To: pbonzini, rkrcmar, shuah; +Cc: Shuah Khan, kvm, linux-kselftest, linux-kernel
Fix the following build error:
libkvm.a(assert.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
Add -fPIC to CFLAGS to fix it.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
tools/testing/selftests/kvm/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 62c591f87dab..b4a55d300e75 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -44,7 +44,7 @@ INSTALL_HDR_PATH = $(top_srcdir)/usr
LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
- -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
+ -fno-stack-protector -fPIC -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
-I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: kvm: Fix libkvm build error
2019-09-24 20:14 [PATCH] selftests: kvm: Fix libkvm build error Shuah Khan
@ 2019-09-25 7:48 ` Paolo Bonzini
2019-09-25 16:47 ` Shuah Khan
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2019-09-25 7:48 UTC (permalink / raw)
To: Shuah Khan, rkrcmar, shuah; +Cc: kvm, linux-kselftest, linux-kernel
On 24/09/19 22:14, Shuah Khan wrote:
> Fix the following build error:
>
> libkvm.a(assert.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
>
> Add -fPIC to CFLAGS to fix it.
This is wrong, these testcases cannot be position-independent
executables. Can you include the failing command line from "V=1"
output?
The problem seems to be that these definitions are not working properly:
no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
LDFLAGS += -pthread $(no-pie-option)
Thanks,
Paolo
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
> ---
> tools/testing/selftests/kvm/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
> index 62c591f87dab..b4a55d300e75 100644
> --- a/tools/testing/selftests/kvm/Makefile
> +++ b/tools/testing/selftests/kvm/Makefile
> @@ -44,7 +44,7 @@ INSTALL_HDR_PATH = $(top_srcdir)/usr
> LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
> LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
> CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
> - -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
> + -fno-stack-protector -fPIC -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
> -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
>
> no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: kvm: Fix libkvm build error
2019-09-25 7:48 ` Paolo Bonzini
@ 2019-09-25 16:47 ` Shuah Khan
0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2019-09-25 16:47 UTC (permalink / raw)
To: Paolo Bonzini, rkrcmar, shuah
Cc: kvm, linux-kselftest, linux-kernel, Shuah Khan
On 9/25/19 1:48 AM, Paolo Bonzini wrote:
> On 24/09/19 22:14, Shuah Khan wrote:
>> Fix the following build error:
>>
>> libkvm.a(assert.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
>>
>> Add -fPIC to CFLAGS to fix it.
>
> This is wrong, these testcases cannot be position-independent
> executables. Can you include the failing command line from "V=1"
> output?
>
You are right. This isn't correct.
> The problem seems to be that these definitions are not working properly:
>
> no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
> $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
>
> LDFLAGS += -pthread $(no-pie-option)
>
Yup. That is what is happening, when I build using
"make TARGETS=kvm kselftest"
You can see this below:
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99
-fno-stack-protector -fno-PIE -I../../../../tools/include
-I../../../../usr/include/ -Iinclude -Ix86_64 -Iinclude/x86_64 -I..
-pthread x86_64/cr4_cpuid_sync_test.c
vs.
Running make in kvm directory:
gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99
-fno-stack-protector -fPIC -fno-PIE -I../../../../tools/include
-I../../../../usr/include/ -Iinclude -Ix86_64 -Iinclude/x86_64 -I..
-pthread -no-pie x86_64/cr4_cpuid_sync_test.c
I was playing with both options yesterday and totally confused myself
thinking that adding fPIC helps. It doesn't.
I am looking into this to see how we can make "make kselftest" work.
Once I figure it out, will send v2. I think for some reason in the
failing case, no-pie-option and pgste-option are null strings.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-25 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 20:14 [PATCH] selftests: kvm: Fix libkvm build error Shuah Khan
2019-09-25 7:48 ` Paolo Bonzini
2019-09-25 16:47 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).