* Re: Using __sync_* builtins within libgcc code
@ 2008-06-10 11:45 Uros Bizjak
0 siblings, 0 replies; 11+ messages in thread
From: Uros Bizjak @ 2008-06-10 11:45 UTC (permalink / raw)
To: Luke Dalessandro; +Cc: GCC
Hello!
> I'm making some modifications to exception handling inside of unwind-dw2-fde.c that I'd like to use __sync_bool_compare_and_swap for, unfortunately I can't seem to figure out how to
> correctly use builtins in the context of libgcc.
> I've tried a bunch of different things, but I consistently get the error
> bin/../lib/gcc/i686-pc-linux-gnu/4.3.1/../../../libgcc_s.so: undefined reference to `__sync_bool_compare_and_swap_4'
> so clearly I'm not getting this symbol included correctly when I build. Any advice would be appreciated.
You have to compile library with -march=i486 to activate these
instructions. Alternatively, you can use
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1, 2, 4, 8, 16} to fall back to
generic implementation.
Uros.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 6:40 ` Paolo Carlini
2008-06-10 12:01 ` Joseph S. Myers
@ 2008-06-11 12:35 ` Luke Dalessandro
1 sibling, 0 replies; 11+ messages in thread
From: Luke Dalessandro @ 2008-06-11 12:35 UTC (permalink / raw)
To: Paolo Carlini; +Cc: gcc
Paolo Carlini wrote:
> Luke Dalessandro wrote:
>> I'm making some modifications to exception handling inside of
>> unwind-dw2-fde.c that I'd like to use __sync_bool_compare_and_swap
>> for, unfortunately I can't seem to figure out how to correctly use
>> builtins in the context of libgcc.
>>
>> I've tried a bunch of different things, but I consistently get the error
>>
>> bin/../lib/gcc/i686-pc-linux-gnu/4.3.1/../../../libgcc_s.so:
>> undefined reference to `__sync_bool_compare_and_swap_4'
>>
> Maybe you can usefully exploit the recently added
> __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* macros or add a few more along the
> same way...
Thank you Paolo, this allows me to wrap cas in a function that falls back to a
mutex for targets that don't support builtins.
I was aware of the i386 restriction, but didn't realize that i686-* platforms
still defaulted to i386.
Thanks for everyone's help.
Luke
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 14:22 ` Paolo Carlini
2008-06-10 14:39 ` H.J. Lu
@ 2008-06-10 16:34 ` Ross Smith
1 sibling, 0 replies; 11+ messages in thread
From: Ross Smith @ 2008-06-10 16:34 UTC (permalink / raw)
To: gcc
Paolo Carlini wrote:
> Joseph S. Myers wrote:
>> I hold that it is a bug that i686-* tools default to -march=i386
>> instead of -march=i686 (whereas e.g. sparcv9-* tools default to
>> -mcpu=sparcv9, and -mcpu means -march for SPARC).
>
> Seconded.
I've long been of the opinion that -march=native should be the default.
-- Ross Smith
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 14:43 ` Joseph S. Myers
@ 2008-06-10 15:37 ` H.J. Lu
0 siblings, 0 replies; 11+ messages in thread
From: H.J. Lu @ 2008-06-10 15:37 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: Paolo Carlini, Luke Dalessandro, gcc
On Tue, Jun 10, 2008 at 7:42 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Tue, 10 Jun 2008, H.J. Lu wrote:
>
>> On Tue, Jun 10, 2008 at 02:27:17PM +0200, Paolo Carlini wrote:
>> > Joseph S. Myers wrote:
>> >> I hold that it is a bug that i686-* tools default to -march=i386 instead
>> >> of -march=i686 (whereas e.g. sparcv9-* tools default to -mcpu=sparcv9, and
>> >> -mcpu means -march for SPARC).
>> > Seconded.
>> >
>>
>> What arch should be used for -m32 on x86-64? Personally, I think
>> it should be at least i686, if not SSE2.
>
> -march=x86-64, I'd say, if you're configuring as x86_64-* (so assuming
> those 32-bit features present on all 64-bit processors). Obviously,
> subject to override from --with-arch-32 or --with-arch.
>
Works for me.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 14:39 ` H.J. Lu
2008-06-10 14:43 ` Joseph S. Myers
@ 2008-06-10 15:36 ` Andrew Haley
1 sibling, 0 replies; 11+ messages in thread
From: Andrew Haley @ 2008-06-10 15:36 UTC (permalink / raw)
To: H.J. Lu; +Cc: Paolo Carlini, Joseph S. Myers, Luke Dalessandro, gcc
H.J. Lu wrote:
> On Tue, Jun 10, 2008 at 02:27:17PM +0200, Paolo Carlini wrote:
>> Joseph S. Myers wrote:
>>> I hold that it is a bug that i686-* tools default to -march=i386 instead
>>> of -march=i686 (whereas e.g. sparcv9-* tools default to -mcpu=sparcv9, and
>>> -mcpu means -march for SPARC).
>> Seconded.
>>
>
> What arch should be used for -m32 on x86-64? Personally, I think
> it should be at least i686, if not SSE2.
I suppose that depends on your opinion as to why people use -32 on x86_64.
If it's just to make programs smaller, then i686 makes sense, but if it's
to make programs that will run on another, smaller (older?) box it doesn't.
I think we should be conservative, and assume little.
Andrew.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 14:39 ` H.J. Lu
@ 2008-06-10 14:43 ` Joseph S. Myers
2008-06-10 15:37 ` H.J. Lu
2008-06-10 15:36 ` Andrew Haley
1 sibling, 1 reply; 11+ messages in thread
From: Joseph S. Myers @ 2008-06-10 14:43 UTC (permalink / raw)
To: H.J. Lu; +Cc: Paolo Carlini, Luke Dalessandro, gcc
On Tue, 10 Jun 2008, H.J. Lu wrote:
> On Tue, Jun 10, 2008 at 02:27:17PM +0200, Paolo Carlini wrote:
> > Joseph S. Myers wrote:
> >> I hold that it is a bug that i686-* tools default to -march=i386 instead
> >> of -march=i686 (whereas e.g. sparcv9-* tools default to -mcpu=sparcv9, and
> >> -mcpu means -march for SPARC).
> > Seconded.
> >
>
> What arch should be used for -m32 on x86-64? Personally, I think
> it should be at least i686, if not SSE2.
-march=x86-64, I'd say, if you're configuring as x86_64-* (so assuming
those 32-bit features present on all 64-bit processors). Obviously,
subject to override from --with-arch-32 or --with-arch.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 14:22 ` Paolo Carlini
@ 2008-06-10 14:39 ` H.J. Lu
2008-06-10 14:43 ` Joseph S. Myers
2008-06-10 15:36 ` Andrew Haley
2008-06-10 16:34 ` Ross Smith
1 sibling, 2 replies; 11+ messages in thread
From: H.J. Lu @ 2008-06-10 14:39 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Joseph S. Myers, Luke Dalessandro, gcc
On Tue, Jun 10, 2008 at 02:27:17PM +0200, Paolo Carlini wrote:
> Joseph S. Myers wrote:
>> I hold that it is a bug that i686-* tools default to -march=i386 instead
>> of -march=i686 (whereas e.g. sparcv9-* tools default to -mcpu=sparcv9, and
>> -mcpu means -march for SPARC).
> Seconded.
>
What arch should be used for -m32 on x86-64? Personally, I think
it should be at least i686, if not SSE2.
H.J.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 12:01 ` Joseph S. Myers
@ 2008-06-10 14:22 ` Paolo Carlini
2008-06-10 14:39 ` H.J. Lu
2008-06-10 16:34 ` Ross Smith
0 siblings, 2 replies; 11+ messages in thread
From: Paolo Carlini @ 2008-06-10 14:22 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: Luke Dalessandro, gcc
Joseph S. Myers wrote:
> I hold that it is a bug that i686-* tools default to -march=i386 instead
> of -march=i686 (whereas e.g. sparcv9-* tools default to -mcpu=sparcv9, and
> -mcpu means -march for SPARC).
Seconded.
Paolo.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 6:40 ` Paolo Carlini
@ 2008-06-10 12:01 ` Joseph S. Myers
2008-06-10 14:22 ` Paolo Carlini
2008-06-11 12:35 ` Luke Dalessandro
1 sibling, 1 reply; 11+ messages in thread
From: Joseph S. Myers @ 2008-06-10 12:01 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Luke Dalessandro, gcc
On Tue, 10 Jun 2008, Paolo Carlini wrote:
> Luke Dalessandro wrote:
> > I'm making some modifications to exception handling inside of
> > unwind-dw2-fde.c that I'd like to use __sync_bool_compare_and_swap for,
> > unfortunately I can't seem to figure out how to correctly use builtins in
> > the context of libgcc.
> >
> > I've tried a bunch of different things, but I consistently get the error
> >
> > bin/../lib/gcc/i686-pc-linux-gnu/4.3.1/../../../libgcc_s.so: undefined
> > reference to `__sync_bool_compare_and_swap_4'
> >
> > so clearly I'm not getting this symbol included correctly when I build. Any
> > advice would be appreciated.
> Isn't this the well know, annoying, issue that the default sub-architecture is
> i386 and the builtins are only available on i486 and later?
I hold that it is a bug that i686-* tools default to -march=i386 instead
of -march=i686 (whereas e.g. sparcv9-* tools default to -mcpu=sparcv9, and
-mcpu means -march for SPARC). My --with-arch-32 etc. patch
<http://gcc.gnu.org/ml/gcc-patches/2008-06/msg00124.html> (config/i386
part pending review) would facilitate fixing this bug by making i686-*
imply --with-arch-32=i686 instead of --with-cpu-32=i686, while leaving the
64-bit defaults (for which mode -march=i686 is invalid) unaffected.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Using __sync_* builtins within libgcc code
2008-06-10 3:22 Luke Dalessandro
@ 2008-06-10 6:40 ` Paolo Carlini
2008-06-10 12:01 ` Joseph S. Myers
2008-06-11 12:35 ` Luke Dalessandro
0 siblings, 2 replies; 11+ messages in thread
From: Paolo Carlini @ 2008-06-10 6:40 UTC (permalink / raw)
To: Luke Dalessandro; +Cc: gcc
Luke Dalessandro wrote:
> I'm making some modifications to exception handling inside of
> unwind-dw2-fde.c that I'd like to use __sync_bool_compare_and_swap
> for, unfortunately I can't seem to figure out how to correctly use
> builtins in the context of libgcc.
>
> I've tried a bunch of different things, but I consistently get the error
>
> bin/../lib/gcc/i686-pc-linux-gnu/4.3.1/../../../libgcc_s.so:
> undefined reference to `__sync_bool_compare_and_swap_4'
>
> so clearly I'm not getting this symbol included correctly when I
> build. Any advice would be appreciated.
Isn't this the well know, annoying, issue that the default
sub-architecture is i386 and the builtins are only available on i486 and
later?
Maybe you can usefully exploit the recently added
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_* macros or add a few more along the
same way...
Paolo.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Using __sync_* builtins within libgcc code
@ 2008-06-10 3:22 Luke Dalessandro
2008-06-10 6:40 ` Paolo Carlini
0 siblings, 1 reply; 11+ messages in thread
From: Luke Dalessandro @ 2008-06-10 3:22 UTC (permalink / raw)
To: gcc
I'm making some modifications to exception handling inside of unwind-dw2-fde.c
that I'd like to use __sync_bool_compare_and_swap for, unfortunately I can't
seem to figure out how to correctly use builtins in the context of libgcc.
I've tried a bunch of different things, but I consistently get the error
bin/../lib/gcc/i686-pc-linux-gnu/4.3.1/../../../libgcc_s.so: undefined
reference to `__sync_bool_compare_and_swap_4'
so clearly I'm not getting this symbol included correctly when I build. Any
advice would be appreciated.
Luke
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-06-11 12:35 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-10 11:45 Using __sync_* builtins within libgcc code Uros Bizjak
-- strict thread matches above, loose matches on Subject: below --
2008-06-10 3:22 Luke Dalessandro
2008-06-10 6:40 ` Paolo Carlini
2008-06-10 12:01 ` Joseph S. Myers
2008-06-10 14:22 ` Paolo Carlini
2008-06-10 14:39 ` H.J. Lu
2008-06-10 14:43 ` Joseph S. Myers
2008-06-10 15:37 ` H.J. Lu
2008-06-10 15:36 ` Andrew Haley
2008-06-10 16:34 ` Ross Smith
2008-06-11 12:35 ` Luke Dalessandro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).