[PATCH v2 06/11] tests/tcg/i386: force -fno-pie for test-i386

Alex Bennée posted 11 patches 4 years, 10 months ago
[PATCH v2 06/11] tests/tcg/i386: force -fno-pie for test-i386
Posted by Alex Bennée 4 years, 10 months ago
The containerised compiler defaults to no-pie anyway but if we are
relying on the users installed cross compiler we need to check it
works for building 16 bit code first.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/configure.sh         |  6 ++++++
 tests/tcg/i386/Makefile.target | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh
index 90fd81f506..46bc8634bb 100755
--- a/tests/tcg/configure.sh
+++ b/tests/tcg/configure.sh
@@ -281,6 +281,12 @@ for target in $target_list; do
                 echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
             fi
         ;;
+        i386-linux-user)
+            if do_compiler "$target_compiler" $target_compiler_cflags \
+                -Werror -fno-pie -no-pie -o $TMPE $TMPC; then
+                echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
+            fi
+        ;;
     esac
 
     enabled_cross_compilers="$enabled_cross_compilers $target_compiler"
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index c4a6f91966..f7efaab918 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -27,13 +27,23 @@ run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max
 hello-i386: CFLAGS+=-ffreestanding
 hello-i386: LDFLAGS+=-nostdlib
 
-#
-# test-386 includes a couple of additional objects that need to be linked together
-#
+# test-386 includes a couple of additional objects that need to be
+# linked together, we also need a no-pie capable compiler due to the
+# non-pic calls into 16-bit mode
+ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_I386_NOPIE),)
+test-i386: CFLAGS += -fno-pie
 
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h
 	$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \
 	   $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
+else
+test-i386:
+	$(call skip-test, "BUILD of $@", "missing -no-pie compiler support")
+run-test-i386:
+	$(call skip-test, "RUN of test-i386", "not built")
+run-plugin-test-i386-with-%:
+	$(call skip-test, "RUN of test-i386 ($*)", "not built")
+endif
 
 ifeq ($(SPEED), slow)
 
-- 
2.20.1


Re: [PATCH v2 06/11] tests/tcg/i386: force -fno-pie for test-i386
Posted by Richard Henderson 4 years, 10 months ago
On 4/1/21 3:25 AM, Alex Bennée wrote:
> +                -Werror -fno-pie -no-pie -o $TMPE $TMPC; then

What is -no-pie?  That isn't a compiler option, afaik.

r~

Re: [PATCH v2 06/11] tests/tcg/i386: force -fno-pie for test-i386
Posted by Alex Bennée 4 years, 10 months ago
Richard Henderson <richard.henderson@linaro.org> writes:

> On 4/1/21 3:25 AM, Alex Bennée wrote:
>> +                -Werror -fno-pie -no-pie -o $TMPE $TMPC; then
>
> What is -no-pie?  That isn't a compiler option, afaik.

No it's a c&p error from the main test in configure:

  # Check we support --no-pie first; we will need this for building ROMs.
  if compile_prog "-Werror -fno-pie" "-no-pie"; then
    CFLAGS_NOPIE="-fno-pie"
  fi

dropping it now.

>
> r~


-- 
Alex Bennée