Bug 105710 - ICE on powerpc darwin with TLS enabled
Summary: ICE on powerpc darwin with TLS enabled
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-24 02:30 UTC by Sergey Fedorov
Modified: 2022-05-24 14:14 UTC (History)
2 users (show)

See Also:
Host:
Target: powerpc-apple-darwin
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
ii file produced with -v -save-temps (18.42 KB, text/plain)
2022-05-24 02:30 UTC, Sergey Fedorov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Fedorov 2022-05-24 02:30:10 UTC
Created attachment 53026 [details]
ii file produced with -v -save-temps

I have tried to rebuild gcc11 @11.3.0 with TLS enabled on 10.6 PPC, and it failed in stage 3 on libitm:

checking for freelocale... /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/gcc-11.3.0/libitm/alloc_c.cc: In function 'void* _ITM_malloc(size_t)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/gcc-11.3.0/libitm/alloc_c.cc:40:1: error: unrecognizable insn:
   40 | }
      | ^
(insn 23 22 24 4 (set (reg:SI 3 r3)
        (unspec:SI [
                (symbol_ref:SI ("_ZN3GTM12_gtm_thr_tlsE") [flags 0x1252] <var_decl 0x1c66054 _gtm_thr_tls>)
                (reg:SI 126)
            ] UNSPEC_TLSGD)) "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/gcc-11.3.0/libitm/config/generic/tls.h":52:59 -1
     (nil))
during RTL pass: vregs
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/gcc-11.3.0/libitm/alloc_c.cc:40:1: internal compiler error: in extract_insn, at recog.c:2770
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.
make[4]: *** [alloc_c.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
yes
mv -f .deps/alloc.Tpo .deps/alloc.Plo
checking for uselocale... mv -f .deps/aatree.Tpo .deps/aatree.Plo
make[4]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/build/ppc-apple-darwin10/libitm'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/build/ppc-apple-darwin10/libitm'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/build/ppc-apple-darwin10/libitm'
make[1]: *** [all-target-libitm] Error 2

P. S. Yes, this is a non-standard OS version, but the same version of gcc11 built just fine with TLS disabled on it.
Comment 1 Andrew Pinski 2022-05-24 02:35:11 UTC
>TLS enabled

TLS support for powerpc darwin was never added.
Comment 2 Sergey Fedorov 2022-05-24 02:39:15 UTC
(In reply to Andrew Pinski from comment #1)
> >TLS enabled
> 
> TLS support for powerpc darwin was never added.

Iain writes that emulated TLS is supported on all Darwin versions starting from 10.5: https://github.com/ruby/ruby/pull/5927?notification_referrer_id=NT_kwDOBXwLlrMzNjYyMzQ0NjYzOjkyMDE1NTEw#issuecomment-1133843490
Comment 3 Andrew Pinski 2022-05-24 02:40:52 UTC
(In reply to Sergey Fedorov from comment #2)
> (In reply to Andrew Pinski from comment #1)
> > >TLS enabled
> > 
> > TLS support for powerpc darwin was never added.
> 
> Iain writes that emulated TLS is supported on all Darwin versions starting
> from 10.5:
> https://github.com/ruby/ruby/pull/
> 5927?notification_referrer_id=NT_kwDOBXwLlrMzNjYyMzQ0NjYzOjkyMDE1NTEw#issueco
> mment-1133843490

That is enabled by default though --enable-tls tries to enable native TLS support.
Comment 4 Sergey Fedorov 2022-05-24 03:24:03 UTC
(In reply to Andrew Pinski from comment #3)
> (In reply to Sergey Fedorov from comment #2)
> > (In reply to Andrew Pinski from comment #1)
> > > >TLS enabled
> > > 
> > > TLS support for powerpc darwin was never added.
> > 
> > Iain writes that emulated TLS is supported on all Darwin versions starting
> > from 10.5:
> > https://github.com/ruby/ruby/pull/
> > 5927?notification_referrer_id=NT_kwDOBXwLlrMzNjYyMzQ0NjYzOjkyMDE1NTEw#issueco
> > mment-1133843490
> 
> That is enabled by default though --enable-tls tries to enable native TLS
> support.

From what I understand, native TLS does not exist with gcc, at least for Darwin.
Comment 5 Iain Sandoe 2022-05-24 06:31:49 UTC
(In reply to Sergey Fedorov from comment #4)
> (In reply to Andrew Pinski from comment #3)
> > (In reply to Sergey Fedorov from comment #2)
> > > (In reply to Andrew Pinski from comment #1)
> > > > >TLS enabled
> > > > 
> > > > TLS support for powerpc darwin was never added.
> > > 
> > > Iain writes that emulated TLS is supported on all Darwin versions starting
> > > from 10.5:
> > > https://github.com/ruby/ruby/pull/
> > > 5927?notification_referrer_id=NT_kwDOBXwLlrMzNjYyMzQ0NjYzOjkyMDE1NTEw#issueco
> > > mment-1133843490
> > 
> > That is enabled by default though --enable-tls tries to enable native TLS
> > support.
> 
> From what I understand, native TLS does not exist with gcc, at least for
> Darwin.

Correct (even if it did exist it would only be for 10.7+) so --enable-tls is a configuration error.

(as I have said several times, the idea of configure is to choose the correct settings for the target _automatically_ - extra config options should only be added if there is a very good reason and you know exactly what they do).
Comment 6 Sergey Fedorov 2022-05-24 07:27:04 UTC
> Correct (even if it did exist it would only be for 10.7+) so --enable-tls is
> a configuration error.
> 
> (as I have said several times, the idea of configure is to choose the
> correct settings for the target _automatically_ - extra config options
> should only be added if there is a very good reason and you know exactly
> what they do).

Got it, thank you!
Comment 7 Eric Gallager 2022-05-24 13:51:12 UTC
(In reply to Sergey Fedorov from comment #4)
> (In reply to Andrew Pinski from comment #3)
> > (In reply to Sergey Fedorov from comment #2)
> > > (In reply to Andrew Pinski from comment #1)
> > > > >TLS enabled
> > > > 
> > > > TLS support for powerpc darwin was never added.
> > > 
> > > Iain writes that emulated TLS is supported on all Darwin versions starting
> > > from 10.5:
> > > https://github.com/ruby/ruby/pull/5927?notification_referrer_id=NT_kwDOBXwLlrMzNjYyMzQ0NjYzOjkyMDE1NTEw#issuecomment-1133843490
> > 
> > That is enabled by default though --enable-tls tries to enable native TLS
> > support.
> 
> From what I understand, native TLS does not exist with gcc, at least for
> Darwin.

That's bug 52268, for reference.

(In reply to Iain Sandoe from comment #5)
> Correct (even if it did exist it would only be for 10.7+) so --enable-tls is
> a configuration error.
> 
> (as I have said several times, the idea of configure is to choose the
> correct settings for the target _automatically_ - extra config options
> should only be added if there is a very good reason and you know exactly
> what they do).

Well we could at least make the error happen earlier rather than letting it turn into an ICE. I think making the configure script smarter about whether TLS works or not could be worthwhile; see bug 53504
Comment 8 Iain Sandoe 2022-05-24 14:01:31 UTC
(In reply to Eric Gallager from comment #7)


> > (as I have said several times, the idea of configure is to choose the
> > correct settings for the target _automatically_ - extra config options
> > should only be added if there is a very good reason and you know exactly
> > what they do).
> 
> Well we could at least make the error happen earlier rather than letting it
> turn into an ICE. I think making the configure script smarter about whether
> TLS works or not could be worthwhile; see bug 53504

If we try to do this for every irrelevant configure option, that's going to
be quite a lot of work.

Really [IMO, at least], configure options are not intended for end-users 
- the goal for end users is that:

 configure --prefix=xxxxxx && make && install

should 'just work' (OK, we don't quite achieve that, but actually we're quite close)

adding out-of-band configure options is for distributions and expert use
(we assume distributions are expert in the options they need to apply to 
customise the install).

However, of course, if you want to write patches to respond to all the options
that Darwin does not need, I'm happy to review :)
Comment 9 Sergey Fedorov 2022-05-24 14:14:57 UTC
(In reply to Iain Sandoe from comment #8)
> If we try to do this for every irrelevant configure option, that's going to
> be quite a lot of work.
> 
> Really [IMO, at least], configure options are not intended for end-users 
> - the goal for end users is that:
> 
>  configure --prefix=xxxxxx && make && install
> 
> should 'just work' (OK, we don't quite achieve that, but actually we're
> quite close)
> 
> adding out-of-band configure options is for distributions and expert use
> (we assume distributions are expert in the options they need to apply to 
> customise the install).
> 
> However, of course, if you want to write patches to respond to all the
> options
> that Darwin does not need, I'm happy to review :)

I agree with Iain here, in fact it is a problem with Macports, since it’s `--disable-tls` option lists a reason totally unrelated to PPC or Darwin version:

># see https://lists.macports.org/pipermail/macports-dev/2017-August/036209.html
># --disable-tls does not limit functionality
># it only determines how std::call_once works
>configure.args-append \
>                    --disable-tls

Then it was me who misunderstood Iain’s reply in my PR to Ruby. I thought that Macports disables TLS for no clear reason, while Ruby wants it provided by the compiler, and tried to build it with `--enable-tls`.
Sorry for a confusion. I just had an impression that all ICEs have to be reported.