public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/34115] New: atomic builtins not supported on i686?
@ 2007-11-15 22:15 scovich at gmail dot com
2007-11-15 22:19 ` [Bug target/34115] " pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: scovich at gmail dot com @ 2007-11-15 22:15 UTC (permalink / raw)
To: gcc-bugs
Linking fails for the program below, with the error:
undefined reference to `___sync_val_compare_and_swap_4'
// gcc -Wall atomic.c
int main() {
int *a, b, c;
return __sync_val_compare_and_swap(a, b, c);
}
According to the atomic builtins docs (), "Not all operations are supported by
all target processors. If a particular operation cannot be implemented on the
target processor, a warning will be generated and a call an external function
will be generated. The external function will carry the same name as the
builtin, with an additional suffix `_n' where n is the size of the data type."
If CAS is not supported, how come I don't get a warning? Why would i686 *not*
support compare and swap? The cmpxchg instruction has been around since 80486,
according to the intel IA-32 processor manual.
Also, does an unsupported builtin mean the user is responsible to write that
function, or simply that the compiler must make a function call to synthesize
its behavior?
FWIW, my x86_64 cross-compile gcc 4.2.0 handles it fine, emitting a
"lock"+"cmpxchg" pair.
--
Summary: atomic builtins not supported on i686?
Product: gcc
Version: 4.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: scovich at gmail dot com
GCC host triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
@ 2007-11-15 22:19 ` pinskia at gcc dot gnu dot org
2007-11-15 22:30 ` pcarlini at suse dot de
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-15 22:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-11-15 22:19 -------
Because the default arch for i686-linux-gnu is i386.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
2007-11-15 22:19 ` [Bug target/34115] " pinskia at gcc dot gnu dot org
@ 2007-11-15 22:30 ` pcarlini at suse dot de
2007-11-15 23:53 ` joseph at codesourcery dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2007-11-15 22:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pcarlini at suse dot de 2007-11-15 22:30 -------
I think this is essentially invalid. Note that now we also have the various
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_* macros:
http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
2007-11-15 22:19 ` [Bug target/34115] " pinskia at gcc dot gnu dot org
2007-11-15 22:30 ` pcarlini at suse dot de
@ 2007-11-15 23:53 ` joseph at codesourcery dot com
2007-11-16 0:07 ` pcarlini at suse dot de
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: joseph at codesourcery dot com @ 2007-11-15 23:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from joseph at codesourcery dot com 2007-11-15 23:53 -------
Subject: Re: atomic builtins not supported on i686?
On Thu, 15 Nov 2007, pinskia at gcc dot gnu dot org wrote:
> Because the default arch for i686-linux-gnu is i386.
Which is a stupid inconsistency and arguably a bug. sparcv9-linux-gnu
defaults to -mcpu=v9 (where -mcpu means -march for SPARC), likewise
various other architectures; i686-linux-gnu should be consistent with
those other targets and default to -march=i686. libstdc++ will use
i486-specific code if you configure GCC for i[456]86, even when GCC itself
restricts itself to i386 code, making this default to i386 even less
useful; likewise glibc will use i486/i586/i686 code when configured for
those processors (and no longer supports i386).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (2 preceding siblings ...)
2007-11-15 23:53 ` joseph at codesourcery dot com
@ 2007-11-16 0:07 ` pcarlini at suse dot de
2007-11-16 1:00 ` scovich at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2007-11-16 0:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pcarlini at suse dot de 2007-11-16 00:07 -------
Yeah, the wind is changing!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (3 preceding siblings ...)
2007-11-16 0:07 ` pcarlini at suse dot de
@ 2007-11-16 1:00 ` scovich at gmail dot com
2007-11-16 1:04 ` scovich at gmail dot com
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: scovich at gmail dot com @ 2007-11-16 1:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from scovich at gmail dot com 2007-11-16 01:00 -------
Subject: Re: atomic builtins not supported on i686?
On 15 Nov 2007 23:53:06 -0000, joseph at codesourcery dot com
<gcc-bugzilla@gcc.gnu.org> wrote:
> > Because the default arch for i686-linux-gnu is i386.
> Which is a stupid inconsistency and arguably a bug.
++
BTW, -march=i686 works beautifully. Close the bug? or rename it as a
RFE to have i686-* default to -march=i686?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (4 preceding siblings ...)
2007-11-16 1:00 ` scovich at gmail dot com
@ 2007-11-16 1:04 ` scovich at gmail dot com
2007-11-28 1:56 ` scovich at gmail dot com
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: scovich at gmail dot com @ 2007-11-16 1:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from scovich at gmail dot com 2007-11-16 01:04 -------
(In reply to comment #5)
> Subject: Re: atomic builtins not supported on i686?
>
> On 15 Nov 2007 23:53:06 -0000, joseph at codesourcery dot com
> <gcc-bugzilla@gcc.gnu.org> wrote:
> > > Because the default arch for i686-linux-gnu is i386.
> > Which is a stupid inconsistency and arguably a bug.
>
> ++
>
> BTW, -march=i686 works beautifully. Close the bug? or rename it as a
> RFE to have i686-* default to -march=i686?
>
Oh, and is there supposed to be a warning about unsupported atomic ops or not?
If not the docs should say to expect a linker error instead (and also
mention/link those macros Paolo pointed out).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (5 preceding siblings ...)
2007-11-16 1:04 ` scovich at gmail dot com
@ 2007-11-28 1:56 ` scovich at gmail dot com
2007-11-28 2:05 ` pcarlini at suse dot de
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: scovich at gmail dot com @ 2007-11-28 1:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from scovich at gmail dot com 2007-11-28 01:56 -------
(In reply to comment #2)
> I think this is essentially invalid. Note that now we also have the various
> __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* macros:
>
> http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
>
Too bad they aren't defined for any machine I've tried so far...
ia64-linux-gnu (4.1.2 Debian)
x86_64-unknown-linux-gnu (4.2.0)
sparc-sun-solaris2.10 (4.1.1)
powerpc64-unknown-linux-gnu (4.1.2 Gentoo)
i686-pc-cygwin (4.2.2)
All these actually *do* support CAS, and emit perfectly respectable .asm... as
long as you don't wrap them in any #ifdef's.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (6 preceding siblings ...)
2007-11-28 1:56 ` scovich at gmail dot com
@ 2007-11-28 2:05 ` pcarlini at suse dot de
2007-11-28 14:20 ` scovich at gmail dot com
2009-06-08 21:18 ` joseph dot h dot garvin at gmail dot com
9 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2007-11-28 2:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pcarlini at suse dot de 2007-11-28 02:05 -------
(In reply to comment #7)
> Too bad they aren't defined for any machine I've tried so far...
The explanation is very simple: the new macros are implemented only in mainline
(would be 4.3.0).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (7 preceding siblings ...)
2007-11-28 2:05 ` pcarlini at suse dot de
@ 2007-11-28 14:20 ` scovich at gmail dot com
2009-06-08 21:18 ` joseph dot h dot garvin at gmail dot com
9 siblings, 0 replies; 13+ messages in thread
From: scovich at gmail dot com @ 2007-11-28 14:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from scovich at gmail dot com 2007-11-28 14:20 -------
(In reply to comment #8)
> (In reply to comment #7)
> > Too bad they aren't defined for any machine I've tried so far...
>
> The explanation is very simple: the new macros are implemented only in mainline
> (would be 4.3.0).
>
Any chance of backporting? (I know, probably not)
The only question left is whether the compiler is supposed to emit a warning
when it doesn't support the intrinsics (like the docs say) or whether the user
should just be ready for linker errors.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
` (8 preceding siblings ...)
2007-11-28 14:20 ` scovich at gmail dot com
@ 2009-06-08 21:18 ` joseph dot h dot garvin at gmail dot com
9 siblings, 0 replies; 13+ messages in thread
From: joseph dot h dot garvin at gmail dot com @ 2009-06-08 21:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from joseph dot h dot garvin at gmail dot com 2009-06-08 21:18 -------
After encountering this issue and some testing, I think this is definitely a
bug. The problem ONLY occurs when directly returning a call to an atomic
builtin! Assuming no march flags:
Links:
int main()
{
unsigned long test;
return __sync_add_and_fetch(&test, 1);
return (int)test;
}
Does not link:
int main()
{
unsigned long test;
return __sync_add_and_fetch(&test, 1);
}
If you do specify -march=i686, then they both link! If this somehow isn't a
bug, the design is poor, because it's very hard to debug behavior.
$ gcc -v
Reading specs from
/opt/app/g++lib6/gcc-4.2/lib/gcc/i386-pc-solaris2.10/4.2.2/specs
Target: i386-pc-solaris2.10
Configured with: ../configure --prefix=/opt/app/g++lib6/gcc-4.2
--enable-languages=c,c++,fortran,objc --disable-nls --with-included-gettext
--with-gnu-as --with-as=/usr/sfw/bin/gas --with-target-tools=/usr/sfw/bin/
--with-gmp=/opt/app/nonc++/gmp-4.2 --with-mpfr=/opt/app/nonc++/mpfr-2.3
Thread model: posix
gcc version 4.2.2
--
joseph dot h dot garvin at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |joseph dot h dot garvin at
| |gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
[not found] <bug-34115-4@http.gcc.gnu.org/bugzilla/>
2010-10-15 20:48 ` redi at gcc dot gnu.org
@ 2021-09-12 8:16 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-12 8:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |4.5.0
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The defualt arch changed with r0-98640 such that i686 defaults to i686 which
fixes this issue all together.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/34115] atomic builtins not supported on i686?
[not found] <bug-34115-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-15 20:48 ` redi at gcc dot gnu.org
2021-09-12 8:16 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2010-10-15 20:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-15 20:48:37 UTC ---
is this still a problem now that GCC defaults to setting the default march
based on the configure target?
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-09-12 8:16 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-15 22:15 [Bug c/34115] New: atomic builtins not supported on i686? scovich at gmail dot com
2007-11-15 22:19 ` [Bug target/34115] " pinskia at gcc dot gnu dot org
2007-11-15 22:30 ` pcarlini at suse dot de
2007-11-15 23:53 ` joseph at codesourcery dot com
2007-11-16 0:07 ` pcarlini at suse dot de
2007-11-16 1:00 ` scovich at gmail dot com
2007-11-16 1:04 ` scovich at gmail dot com
2007-11-28 1:56 ` scovich at gmail dot com
2007-11-28 2:05 ` pcarlini at suse dot de
2007-11-28 14:20 ` scovich at gmail dot com
2009-06-08 21:18 ` joseph dot h dot garvin at gmail dot com
[not found] <bug-34115-4@http.gcc.gnu.org/bugzilla/>
2010-10-15 20:48 ` redi at gcc dot gnu.org
2021-09-12 8:16 ` pinskia at gcc dot gnu.org
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).