Hello,

I agree, better to use POSIX compatible features.

-Pavel

On 01/25/2016 11:40 PM, Marc Glisse wrote:
On Mon, 25 Jan 2016, Pavel Kopyl wrote:

Hello,

I faced with the situation where ./configure makes wrong decision about if global variables should be prefixed or not.

Conditions.

Version:             trunk (GNU MP 6.1.99)
Host type:         armv7l-unknown-linux-gnueabi
Compiler:          Linaro GCC 4.9.2

./configure \
   --prefix=/usr \
   --includedir=/usr/include \
   --libdir=/usr/lib \
   --enable-cxx \


To check if a global variable should be prefixed with underscore ./configure "greps" variable's name in object file in the following test:

cat conftest.c
int gurkmacka;


cat configure
..
$NM conftest.$OBJEXT >conftest.out
 if grep _gurkmacka conftest.out >/dev/null; then
   gmp_cv_asm_underscore=yes
 elif grep gurkmacka conftest.out >/dev/null; then
   gmp_cv_asm_underscore=no
 else
   echo "configure: $NM doesn't have gurkmacka:" >&5
   cat conftest.out >&5
...

Generally it works fine, but being built with enabled AddressSanitizer (-fsanitize=address, -fno-common), compiler generates instrumented code and object file contains additional symbols whose names may incorporate "_gurkmacka" as a substring, though actually global variable is not prefixed.

Lets see an example:

Without AddressSanitizer:

cat conftest.out
00000004 C gurkmacka


With AddressSanitizer:

cat conftest.out
00000000 t _GLOBAL__sub_D_00099_0_gurkmacka
00000000 t _GLOBAL__sub_I_00099_1_gurkmacka
        U __aeabi_unwind_cpp_pr0
        U __asan_init
        U __asan_register_globals
        U __asan_unregister_globals
        U __asan_version_mismatch_check_v6
00000000 B gurkmacka

Based on the former example ./configure erroneously assumes that global variables should be prefixed.**

Attached patch fixes this issue.

Hello,

thank you for the description and the patch. IIRC, \<\> is not a standard feature of grep but a GNU extension. How portable is it?


changeset:   17030:df4ce002502d
tag:         tip
user:        Pavel Kopyl <[email protected]>
date:        Tue Jan 26 18:48:55 2016 +0300
summary:     Fix wrong prefix checking of global variables.

diff -r 7421da954a7b -r df4ce002502d acinclude.m4
--- a/acinclude.m4	Fri Jan 15 22:42:22 2016 +0100
+++ b/acinclude.m4	Tue Jan 26 18:48:55 2016 +0300
@@ -1754,9 +1754,9 @@
 gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC"
 if AC_TRY_EVAL(gmp_compile); then
   $NM conftest.$OBJEXT >conftest.out
-  if grep _gurkmacka conftest.out >/dev/null; then
+  if grep -E "(^|[[[:blank:]]])_gurkmacka$" conftest.out >/dev/null; then
     gmp_cv_asm_underscore=yes
-  elif grep gurkmacka conftest.out >/dev/null; then
+  elif grep -E "(^|[[[:blank:]]])gurkmacka$" conftest.out >/dev/null; then
     gmp_cv_asm_underscore=no
   else
     echo "configure: $NM doesn't have gurkmacka:" >&AC_FD_CC

_______________________________________________
gmp-bugs mailing list
[email protected]
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to