On 26-02-19 13:00, Thomas Schwinge wrote:
> Hi Tom!
>
> On Tue, 26 Feb 2019 12:28:34 +0100, Tom de Vries <[email protected]> wrote:
>> On 26-02-19 10:40, Thomas Schwinge wrote:
>>> On Mon, 25 Feb 2019 18:11:23 +0100, Tom de Vries <[email protected]> wrote:
>>>> On 25-02-19 11:48, Thomas Schwinge wrote:
>>>>> On Fri, 8 Feb 2019 10:42:24 +0100, Tom de Vries <[email protected]> wrote:
>>>>>> Add libbacktrace test-case using -flto.
>>>>>
>>>>> I'm seeing this one fail is some configurations, but only in the
>>>>> 'build-gcc/libbacktrace/btest_lto.log' variant:
>>>
>>>> Meaning, compiling libbacktrace using the host compiler, so it would be
>>>> useful to known which compiler that is.
>>>>
>>>> [ I've tried a gcc-4.8 and gcc-6 and gcc-7 as host compiler, and a
>>>> couple of CFLAGS settings (-O2, -O3) to reproduce this, but didn't manage.
>>>> ]
>>>
>>> Years old:
>>>
>>> $ gcc --version
>>> gcc (Sourcery CodeBench 2014.05-45) 4.8.3 20140320 (prerelease)
>>> [...]
>>> $ ld --version
>>> GNU ld (Sourcery CodeBench 2014.05-45) 2.24.51.20140217
>>> [...]
>>>
>>> (It'll be fine for me if you just declare that unsupported.)
>>
>> I see. The 4.8 I tried is a 4.8.5.
>>
>>>>> test5: unexpected syminfo name got global.2537 expected global
>>>>> PASS: backtrace_full noinline
>>>>> PASS: backtrace_full inline
>>>>> PASS: backtrace_simple noinline
>>>>> PASS: backtrace_simple inline
>>>>> FAIL: backtrace_syminfo variable
>>>>> FAIL btest_lto (exit status: 1)
>>>>>
>>>>> I haven't looked yet which details about these GCC build configurations
>>>>> might be different/important; maybe you've got an idea already?
>>>
>>> I can reproduce this with '-O0' ("unexpected syminfo name got global.2528
>>> expected global", in that case). With '-O0 -fdump-tree-all
>>> -fdump-ipa-all -save-temps', the 'global.2528' name appears only in
>>> 'btest_lto.ltrans0.000i.cgraph', and 'btest_lto.ltrans0.s':
>>>
>>> ./btest_lto.ltrans0.000i.cgraph: References: global.2528/12
>>> (addr)state.2526/56 (read)callback_three.2389/64
>>> (addr)error_callback_three.2384/65 (addr)stderr/20 (read)stderr/20
>>> (read)stderr/20 (read)global.2528/12 (addr)global.2528/12 (addr)stderr/20
>>> (read)stderr/20 (read)failures.2527/57 (read)failures.2527/57
>>> (write)failures.2527/57 (read)
>>> ./btest_lto.ltrans0.000i.cgraph:global.2528/12 (global) @0xf7454118
>>> ./btest_lto.ltrans0.000i.cgraph:global.2528/12 (global) @0xf7454118
>>> ./btest_lto.ltrans0.000i.cgraph: References: global.2528/12
>>> (addr)state.2526/56 (read)callback_three.2389/64
>>> (addr)error_callback_three.2384/65 (addr)stderr/20 (read)stderr/20
>>> (read)stderr/20 (read)global.2528/12 (addr)global.2528/12 (addr)stderr/20
>>> (read)stderr/20 (read)failures.2527/57 (read)failures.2527/57
>>> (write)failures.2527/57 (read)
>>> ./btest_lto.ltrans0.000i.cgraph:global.2528/12 (global) @0xf7454118
>>> ./btest_lto.ltrans0.000i.cgraph: References: global.2528/12
>>> (addr)state.2526/56 (read)callback_three.2389/64
>>> (addr)error_callback_three.2384/65 (addr)stderr/20 (read)stderr/20
>>> (read)stderr/20 (read)global.2528/12 (addr)global.2528/12 (addr)stderr/20
>>> (read)stderr/20 (read)failures.2527/57 (read)failures.2527/57
>>> (write)failures.2527/57 (read)
>>> ./btest_lto.ltrans0.s: .type global.2528, @object
>>> ./btest_lto.ltrans0.s: .size global.2528, 4
>>> ./btest_lto.ltrans0.s:global.2528:
>>> ./btest_lto.ltrans0.s: movq $global.2528, -8(%rbp) #, addr
>>> ./btest_lto.ltrans0.s: movl $global.2528, %eax #, global.22
>>> ./btest_lto.ltrans0.s: movl $global.2528, %ecx #, global.23
>>> ./btest_lto.ltrans0.s: .quad global.2528
>
> With '-fdump-rtl-all' added, I see it appear in
> 'btest_lto.ltrans0.166r.expand':
>
> ./btest_lto.ltrans0.166r.expand: (symbol_ref:DI ("global.2528")
> [flags 0x2] <var_decl 0xf7400170 global>)) [...]/libbacktrace/btest.c:399 -1
> ./btest_lto.ltrans0.166r.expand: (symbol_ref:DI ("global.2528")
> [flags 0x2] <var_decl 0xf7400170 global>)) [...]/libbacktrace/btest.c:433 -1
> ./btest_lto.ltrans0.166r.expand: (symbol_ref:DI ("global.2528")
> [flags 0x2] <var_decl 0xf7400170 global>)) [...]/libbacktrace/btest.c:435 -1
>
>> How about:
>> ...
>> - int global;
>> + static int global;
>> ...
>>
>> Does that fix the failure?
>
> No, that gets us "unexpected syminfo name got global.2479.2528 expected
> global". ;-\
>
Ian,
Is this approach OK?
Thanks,
- Tom
[libbacktrace] Fix btest-lto for older gcc
With gcc 4.8.5, btest_lto ends up with a privatized name for the variable with
name 'global':
...
$ nm btest_lto | grep ' d ' | grep global
0000000000617150 d global.2530
...
which makes test5 fail:
...
test5: unexpected syminfo name got global.2530 expected global
...
Fix this failure by accepting this type of name as a valid name in btest_lto.
2019-02-26 Tom de Vries <[email protected]>
* Makefile.am (btest_lto_CFLAGS): Add -DHAVE_LTO.
* Makefile.in: Regenerate.
* btest.c (test5) [HAVE_LTO]: Allow global.* as minimal symbol name
for global.
---
libbacktrace/Makefile.am | 2 +-
libbacktrace/Makefile.in | 2 +-
libbacktrace/btest.c | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 7ddee4962ec..0798583eebe 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -229,7 +229,7 @@ BUILDTESTS += btest
if HAVE_ELF
btest_lto_SOURCES = btest.c testlib.c
-btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto
+btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto -DHAVE_LTO
btest_lto_LDADD = libbacktrace.la
BUILDTESTS += btest_lto
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index a896a26dff8..0844adae087 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -896,7 +896,7 @@ BUILDTESTS = $(am__append_2) $(am__append_9) $(am__append_10) \
@NATIVE_TRUE@btest_CFLAGS = $(AM_CFLAGS) -g -O
@NATIVE_TRUE@btest_LDADD = libbacktrace.la
@HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_SOURCES = btest.c testlib.c
-@HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto
+@HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto -DHAVE_LTO
@HAVE_ELF_TRUE@@NATIVE_TRUE@btest_lto_LDADD = libbacktrace.la
@NATIVE_TRUE@btest_alloc_SOURCES = $(btest_SOURCES)
@NATIVE_TRUE@btest_alloc_CFLAGS = $(btest_CFLAGS)
diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c
index b1c2a2a860d..b624ba1f0cc 100644
--- a/libbacktrace/btest.c
+++ b/libbacktrace/btest.c
@@ -423,7 +423,14 @@ test5 (void)
fprintf (stderr, "test5: NULL syminfo name\n");
symdata.failed = 1;
}
+#ifdef HAVE_LTO
+ else if (!(strlen (symdata.name) >= 6
+ && strncmp (symdata.name, "global", 6) == 0
+ && (symdata.name[6] == '\0'
+ || symdata.name[6] == '.')))
+#else
else if (strcmp (symdata.name, "global") != 0)
+#endif
{
fprintf (stderr,
"test5: unexpected syminfo name got %s expected %s\n",