From: Ivo Raisr Date: Wed, 10 May 2017 05:43:03 +0000 (+0000) Subject: Fix compilation problems with some unit tests on Ubuntu 16.10+. X-Git-Tag: svn/VALGRIND_3_13_0~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84ad3a82c247c9b15591b542307772f4c6767129;p=thirdparty%2Fvalgrind.git Fix compilation problems with some unit tests on Ubuntu 16.10+. Compiler produces position independent executables (PIE) by default which gets in the way of some unit tests. Fixes BZ#377066. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16349 --- diff --git a/NEWS b/NEWS index d65c4d0e21..869909c6e0 100644 --- a/NEWS +++ b/NEWS @@ -156,6 +156,8 @@ where XXXXXX is the bug number as listed below. == 371668 376956 syswrap of SNDDRV and DRM_IOCTL_VERSION causing some addresses to be wrongly marked as addressable +377066 Some Valgrind unit tests fail to compile on Ubuntu 16.10 with + PIE enabled by default 377376 memcheck/tests/linux/getregset fails with glibc2.24 377427 PPC64, lxv instruction failing on odd destination register 377478 PPC64: ISA 3.0 setup fixes diff --git a/configure.ac b/configure.ac index 51e3121323..810a769901 100644 --- a/configure.ac +++ b/configure.ac @@ -2177,6 +2177,28 @@ AC_MSG_RESULT([no]) AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes]) +# Does this compiler support -no-pie? +# On Ubuntu 16.10+, gcc produces position independent executables (PIE) by +# default. However this gets in the way with some tests, we use -no-pie +# for these. + +AC_MSG_CHECKING([if gcc accepts -no-pie]) + +safe_CFLAGS=$CFLAGS +CFLAGS="-no-pie" + +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ + return 0; +]])], [ +AC_SUBST([FLAG_NO_PIE], ["-no-pie"]) +AC_MSG_RESULT([yes]) +], [ +AC_SUBST([FLAG_NO_PIE], [""]) +AC_MSG_RESULT([no]) +]) +CFLAGS=$safe_CFLAGS + + # We want to use use the -Ttext-segment option to the linker. # GNU (bfd) ld supports this directly. Newer GNU gold linkers # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext diff --git a/exp-bbv/tests/amd64-linux/Makefile.am b/exp-bbv/tests/amd64-linux/Makefile.am index 7ff8966904..67bcc02beb 100644 --- a/exp-bbv/tests/amd64-linux/Makefile.am +++ b/exp-bbv/tests/amd64-linux/Makefile.am @@ -40,3 +40,10 @@ AM_CCASFLAGS += -Xassembler -I$(top_srcdir)/exp-bbv/tests check_PROGRAMS += ll ll_SOURCES = ll.S endif + +clone_test_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +complex_rep_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +fldcw_check_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +ll_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +million_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +rep_prefix_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ diff --git a/memcheck/tests/amd64-linux/Makefile.am b/memcheck/tests/amd64-linux/Makefile.am index 56a390be78..94f5d0f143 100644 --- a/memcheck/tests/amd64-linux/Makefile.am +++ b/memcheck/tests/amd64-linux/Makefile.am @@ -23,4 +23,4 @@ AM_CXXFLAGS += @FLAG_M64@ AM_CCASFLAGS += @FLAG_M64@ defcfaexpr_SOURCES = defcfaexpr.S - +defcfaexpr_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index ef085d0bd7..2b28dcee42 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -63,6 +63,7 @@ AM_CFLAGS += @FLAG_M64@ AM_CXXFLAGS += @FLAG_M64@ AM_CCASFLAGS += @FLAG_M64@ +fxsave_amd64_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ insn_pcmpistri_CFLAGS = $(AM_CFLAGS) if VGCONF_OS_IS_SOLARIS insn_pcmpistri_CFLAGS += --std=c99 @@ -70,4 +71,4 @@ endif more_x87_fp_CFLAGS = $(AM_CFLAGS) -O -ffast-math -mfpmath=387 \ -mfancy-math-387 more_x87_fp_LDADD = -lm - +shr_edx_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am index f0cd081d7a..11da02a068 100644 --- a/none/tests/amd64/Makefile.am +++ b/none/tests/amd64/Makefile.am @@ -172,7 +172,9 @@ allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@ # generic C ones amd64locked_CFLAGS = $(AM_CFLAGS) -O bug132918_LDADD = -lm -fxtract_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_OVERFLOW@ +cmpxchg_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +fcmovnu_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +fxtract_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_OVERFLOW@ @FLAG_NO_PIE@ insn_basic_SOURCES = insn_basic.def insn_basic_LDADD = -lm insn_mmx_SOURCES = insn_mmx.def @@ -194,6 +196,10 @@ if VGCONF_OS_IS_SOLARIS fma4_CFLAGS += -D__EXTENSIONS__ endif fma4_LDADD = -lm +jrcxz_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +looper_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +sbbmisc_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ +shrld_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@ .def.c: $(srcdir)/gen_insn_test.pl $(PERL) $(srcdir)/gen_insn_test.pl < $< > $@