Re: Problem with static const objects and LTO

2020-10-09 Thread Jeff Law via Gcc-patches
On 10/7/20 5:12 PM, H.J. Lu wrote: > On Wed, Oct 7, 2020 at 3:09 PM Jeff Law via Gcc-patches > wrote: >> Adding the testcase... >> >> On 10/7/20 4:08 PM, Jeff Law wrote: >>> On 9/17/20 1:03 PM, Jakub Jelinek wrote: >>> [ ... Big snip, starting over ... ] >>> >>> I may have not explained things

Re: Problem with static const objects and LTO

2020-10-07 Thread Jeff Law via Gcc-patches
On 10/7/20 5:12 PM, H.J. Lu wrote: > On Wed, Oct 7, 2020 at 3:09 PM Jeff Law via Gcc-patches > wrote: >> Adding the testcase... >> >> On 10/7/20 4:08 PM, Jeff Law wrote: >>> On 9/17/20 1:03 PM, Jakub Jelinek wrote: >>> [ ... Big snip, starting over ... ] >>> >>> I may have not explained things

Re: Problem with static const objects and LTO

2020-10-07 Thread H.J. Lu via Gcc-patches
On Wed, Oct 7, 2020 at 3:09 PM Jeff Law via Gcc-patches wrote: > > Adding the testcase... > > On 10/7/20 4:08 PM, Jeff Law wrote: > > On 9/17/20 1:03 PM, Jakub Jelinek wrote: > > [ ... Big snip, starting over ... ] > > > > I may have not explained things too well. So I've put together a small >

Re: Problem with static const objects and LTO

2020-10-07 Thread Jeff Law via Gcc-patches
Adding the testcase... On 10/7/20 4:08 PM, Jeff Law wrote: > On 9/17/20 1:03 PM, Jakub Jelinek wrote: > [ ... Big snip, starting over ... ] > > I may have not explained things too well.  So I've put together a small > example that folks can play with to show the underlying issue. > > > There's a

Re: Problem with static const objects and LTO

2020-10-07 Thread Jeff Law via Gcc-patches
On 9/17/20 1:03 PM, Jakub Jelinek wrote: [ ... Big snip, starting over ... ] I may have not explained things too well.  So I've put together a small example that folks can play with to show the underlying issue. There's a static library libfu.a.  In this static library we have a hunk of local

Re: Problem with static const objects and LTO

2020-09-17 Thread Jakub Jelinek via Gcc-patches
On Thu, Sep 17, 2020 at 12:18:40PM -0600, Jeff Law via Gcc-patches wrote: > >> In an LTO world the TU isn't indivisible anymore. LTO will happily > >> discard things which don't appear to be used. So parts of the TU may > >> be in the main program, other parts may be in DSOs used by the main >

Re: Problem with static const objects and LTO

2020-09-17 Thread Jeff Law via Gcc-patches
On 9/17/20 1:04 AM, Richard Biener wrote: > On Wed, Sep 16, 2020 at 10:24 PM Jeff Law via Gcc-patches > wrote: >> >> On 9/16/20 11:52 AM, Joseph Myers wrote: >>> On Wed, 16 Sep 2020, Jeff Law via Gcc-patches wrote: >>> ISTM this is a lot like the problem we have where we inline functions

Re: Problem with static const objects and LTO

2020-09-17 Thread Richard Biener via Gcc-patches
On Wed, Sep 16, 2020 at 10:24 PM Jeff Law via Gcc-patches wrote: > > > On 9/16/20 11:52 AM, Joseph Myers wrote: > > On Wed, 16 Sep 2020, Jeff Law via Gcc-patches wrote: > > > >> ISTM this is a lot like the problem we have where we inline functions > >> with static data. To fix those we use

Re: Problem with static const objects and LTO

2020-09-16 Thread Jeff Law via Gcc-patches
On 9/16/20 11:52 AM, Joseph Myers wrote: > On Wed, 16 Sep 2020, Jeff Law via Gcc-patches wrote: > >> ISTM this is a lot like the problem we have where we inline functions >> with static data.   To fix those we use STB_GNU_UNIQUE.  But I don't see >> any code in the C front-end which would utilize

Re: Problem with static const objects and LTO

2020-09-16 Thread Joseph Myers
On Wed, 16 Sep 2020, Jeff Law via Gcc-patches wrote: > ISTM this is a lot like the problem we have where we inline functions > with static data.   To fix those we use STB_GNU_UNIQUE.  But I don't see > any code in the C front-end which would utilize STB_GNU_UNIQUE.  It's > support seems limited

Re: Problem with static const objects and LTO

2020-09-16 Thread Jeff Law via Gcc-patches
On 9/16/20 11:32 AM, H.J. Lu wrote: > On Wed, Sep 16, 2020 at 10:24 AM Jeff Law wrote: >> >> On 9/16/20 11:13 AM, H.J. Lu wrote: >>> On Wed, Sep 16, 2020 at 10:10 AM Jeff Law wrote: On 9/16/20 11:05 AM, H.J. Lu wrote: > On Wed, Sep 16, 2020 at 9:53 AM Jeff Law via Gcc-patches >

Re: Problem with static const objects and LTO

2020-09-16 Thread H.J. Lu via Gcc-patches
On Wed, Sep 16, 2020 at 10:24 AM Jeff Law wrote: > > > On 9/16/20 11:13 AM, H.J. Lu wrote: > > On Wed, Sep 16, 2020 at 10:10 AM Jeff Law wrote: > >> > >> On 9/16/20 11:05 AM, H.J. Lu wrote: > >>> On Wed, Sep 16, 2020 at 9:53 AM Jeff Law via Gcc-patches > >>> wrote: > Consider a TU with

Re: Problem with static const objects and LTO

2020-09-16 Thread Jeff Law via Gcc-patches
On 9/16/20 11:13 AM, H.J. Lu wrote: > On Wed, Sep 16, 2020 at 10:10 AM Jeff Law wrote: >> >> On 9/16/20 11:05 AM, H.J. Lu wrote: >>> On Wed, Sep 16, 2020 at 9:53 AM Jeff Law via Gcc-patches >>> wrote: Consider a TU with file scoped "static const object utf8_sb_map". A routine within

Re: Problem with static const objects and LTO

2020-09-16 Thread H.J. Lu via Gcc-patches
On Wed, Sep 16, 2020 at 10:10 AM Jeff Law wrote: > > > On 9/16/20 11:05 AM, H.J. Lu wrote: > > On Wed, Sep 16, 2020 at 9:53 AM Jeff Law via Gcc-patches > > wrote: > >> > >> Consider a TU with file scoped "static const object utf8_sb_map". A > >> routine within the TU will stuff _sb_map into an

Re: Problem with static const objects and LTO

2020-09-16 Thread Jeff Law via Gcc-patches
On 9/16/20 11:05 AM, H.J. Lu wrote: > On Wed, Sep 16, 2020 at 9:53 AM Jeff Law via Gcc-patches > wrote: >> >> Consider a TU with file scoped "static const object utf8_sb_map". A >> routine within the TU will stuff _sb_map into an object, something >> like: >> >> fu (...) >> >> { >> >> if

Re: Problem with static const objects and LTO

2020-09-16 Thread H.J. Lu via Gcc-patches
On Wed, Sep 16, 2020 at 9:53 AM Jeff Law via Gcc-patches wrote: > > > Consider a TU with file scoped "static const object utf8_sb_map". A > routine within the TU will stuff _sb_map into an object, something > like: > > fu (...) > > { > > if (cond) > > dfa->sb_char = utf8_sb_map; > >

Problem with static const objects and LTO

2020-09-16 Thread Jeff Law via Gcc-patches
Consider a TU with file scoped "static const object utf8_sb_map".   A routine within the TU will stuff _sb_map into an object, something like: fu (...) {   if (cond)     dfa->sb_char = utf8_sb_map;   else     dfa->sb_char = malloc (...); } There is another routine in the TU which looks