Wrong prefix checking of global variables
Pavel Kopyl
p.kopyl at samsung.com
Tue Jan 26 15:55:42 UTC 2016
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?
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_wrong_var_prefix_posix.patch
Type: text/x-patch
Size: 896 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20160126/568ff1b3/attachment.bin>
More information about the gmp-bugs
mailing list