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
This commit is contained in:
Ivo Raisr 2017-05-10 05:43:03 +00:00
parent d8de8b8beb
commit 84ad3a82c2
6 changed files with 41 additions and 3 deletions

2
NEWS
View File

@ -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

View File

@ -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

View File

@ -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@

View File

@ -23,4 +23,4 @@ AM_CXXFLAGS += @FLAG_M64@
AM_CCASFLAGS += @FLAG_M64@
defcfaexpr_SOURCES = defcfaexpr.S
defcfaexpr_CFLAGS = $(AM_CFLAGS) @FLAG_NO_PIE@

View File

@ -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@

View File

@ -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 < $< > $@