Message ID | 20210329110303.15235-7-alex.bennee@linaro.org |
---|---|
State | New |
Headers | show |
Series | check-tcg for non-x86 hosts | expand |
On 3/29/21 5:03 AM, Alex Bennée wrote: > Newer compilers complain about non-matching constraints: > > test-i386.c:1393:5: error: asm operand 2 probably doesn’t match constraints [-Werror] > 1393 | asm volatile ("lcall %1, %2" > | ^~~ The problem is that the newer compiler is defaulting to -fpie, so &code16_func1 is not a constant. Need to add -fno-pie to compile this. Which of course adds the confusion of old compilers that don't support that. We have CFLAGS_NOPIE in configure, but that doesn't directly help cross-compile. r~
Hmm actually the fedora-i386-cross image is: gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9) with CROSS_CC_GUEST_CFLAGS=-m32 so I wonder what the difference is between that and: i686-linux-gnu-gcc -m32 i686-linux-gnu-gcc --version i686-linux-gnu-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. They are both pretty new. On Tue, 30 Mar 2021 at 16:58, Richard Henderson <richard.henderson@linaro.org> wrote: > > On 3/29/21 5:03 AM, Alex Bennée wrote: > > Newer compilers complain about non-matching constraints: > > > > test-i386.c:1393:5: error: asm operand 2 probably doesn’t match constraints [-Werror] > > 1393 | asm volatile ("lcall %1, %2" > > | ^~~ > > The problem is that the newer compiler is defaulting to -fpie, so &code16_func1 > is not a constant. > > Need to add -fno-pie to compile this. Which of course adds the confusion of > old compilers that don't support that. We have CFLAGS_NOPIE in configure, but > that doesn't directly help cross-compile. > > > r~ -- Alex Bennée KVM/QEMU Hacker for Linaro
On 3/30/21 12:20 PM, Alex Bennée wrote: > Hmm actually the fedora-i386-cross image is: > > gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9) > > with CROSS_CC_GUEST_CFLAGS=-m32 so I wonder what the difference is > between that and: > > i686-linux-gnu-gcc -m32 > > i686-linux-gnu-gcc --version > i686-linux-gnu-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 > Copyright (C) 2019 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > They are both pretty new. The difference, I'm sure, is a local distro patch enabling -fpie by default. I'm hoping that we can just use --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -10,6 +10,9 @@ ALL_X86_TESTS=$(I386_SRCS:.c=) SKIP_I386_TESTS=test-i386-ssse3 X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS)) +# test-i386 has non-pic calls into 16-bit mode +test-i386: CFLAGS += -fno-pie + test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse run-test-i386-sse-exceptions: QEMU_OPTS += -cpu max run-plugin-test-i386-sse-exceptions-%: QEMU_OPTS += -cpu max Checking with gitlab to see if our oldest host compiler accepts it. r~
On Tue, 30 Mar 2021 at 21:27, Richard Henderson <richard.henderson@linaro.org> wrote: > > On 3/30/21 12:20 PM, Alex Bennée wrote: > > Hmm actually the fedora-i386-cross image is: > > > > gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9) > > > > with CROSS_CC_GUEST_CFLAGS=-m32 so I wonder what the difference is > > between that and: > > > > i686-linux-gnu-gcc -m32 > > > > i686-linux-gnu-gcc --version > > i686-linux-gnu-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 > > Copyright (C) 2019 Free Software Foundation, Inc. > > This is free software; see the source for copying conditions. There is NO > > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > > > They are both pretty new. > > The difference, I'm sure, is a local distro patch enabling -fpie by default. > > I'm hoping that we can just use > > --- a/tests/tcg/i386/Makefile.target > +++ b/tests/tcg/i386/Makefile.target > @@ -10,6 +10,9 @@ ALL_X86_TESTS=$(I386_SRCS:.c=) > SKIP_I386_TESTS=test-i386-ssse3 > X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS)) > > +# test-i386 has non-pic calls into 16-bit mode > +test-i386: CFLAGS += -fno-pie > + > test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse > run-test-i386-sse-exceptions: QEMU_OPTS += -cpu max > run-plugin-test-i386-sse-exceptions-%: QEMU_OPTS += -cpu max configure will set CFLAGS_NOPIE in config-host.mak, but I don't know if you have access to that here. (It does suggest that there are cases where -fno-pie isn't available, though I guess they might be non-x86.) -- PMM
On 3/30/21 2:46 PM, Peter Maydell wrote: > On Tue, 30 Mar 2021 at 21:27, Richard Henderson > <richard.henderson@linaro.org> wrote: >> >> On 3/30/21 12:20 PM, Alex Bennée wrote: >>> Hmm actually the fedora-i386-cross image is: >>> >>> gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9) >>> >>> with CROSS_CC_GUEST_CFLAGS=-m32 so I wonder what the difference is >>> between that and: >>> >>> i686-linux-gnu-gcc -m32 >>> >>> i686-linux-gnu-gcc --version >>> i686-linux-gnu-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 >>> Copyright (C) 2019 Free Software Foundation, Inc. >>> This is free software; see the source for copying conditions. There is NO >>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >>> >>> They are both pretty new. >> >> The difference, I'm sure, is a local distro patch enabling -fpie by default. >> >> I'm hoping that we can just use >> >> --- a/tests/tcg/i386/Makefile.target >> +++ b/tests/tcg/i386/Makefile.target >> @@ -10,6 +10,9 @@ ALL_X86_TESTS=$(I386_SRCS:.c=) >> SKIP_I386_TESTS=test-i386-ssse3 >> X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS)) >> >> +# test-i386 has non-pic calls into 16-bit mode >> +test-i386: CFLAGS += -fno-pie >> + >> test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse >> run-test-i386-sse-exceptions: QEMU_OPTS += -cpu max >> run-plugin-test-i386-sse-exceptions-%: QEMU_OPTS += -cpu max > > configure will set CFLAGS_NOPIE in config-host.mak, but I don't know > if you have access to that here. (It does suggest that there are cases > where -fno-pie isn't available, though I guess they might be non-x86.) I think it's merely old compilers. We do have to be worried about old host compilers here. I'm hoping that gitlab will find out if our oldest docker build will find out one way or another. r~
diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c index 18d5609665..6d8aeccfb5 100644 --- a/tests/tcg/i386/test-i386.c +++ b/tests/tcg/i386/test-i386.c @@ -1392,15 +1392,15 @@ void test_code16(void) /* call the first function */ asm volatile ("lcall %1, %2" : "=a" (res) - : "i" (MK_SEL(1)), "i" (&code16_func1): "memory", "cc"); + : "i" (MK_SEL(1)), "Ts" (&code16_func1): "memory", "cc"); printf("func1() = 0x%08x\n", res); asm volatile ("lcall %2, %3" : "=a" (res), "=c" (res2) - : "i" (MK_SEL(1)), "i" (&code16_func2): "memory", "cc"); + : "i" (MK_SEL(1)), "Ts" (&code16_func2): "memory", "cc"); printf("func2() = 0x%08x spdec=%d\n", res, res2); asm volatile ("lcall %1, %2" : "=a" (res) - : "i" (MK_SEL(1)), "i" (&code16_func3): "memory", "cc"); + : "i" (MK_SEL(1)), "Ts" (&code16_func3): "memory", "cc"); printf("func3() = 0x%08x\n", res); } #endif
Newer compilers complain about non-matching constraints: test-i386.c:1393:5: error: asm operand 2 probably doesn’t match constraints [-Werror] 1393 | asm volatile ("lcall %1, %2" | ^~~ It seems the plain "i" immediate constraint is a little too lax here. What we are actually dealing with is a 32 bit offset into a particular segment. I think that is "Ts" (Address operand without segment register). [AJB: however this just seems to push it a bit further down the road: test-i386.c:1393: Error: operand type mismatch for `lcall' Inline ASM constraints are hard :-/] Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- tests/tcg/i386/test-i386.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.1