public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104248] New: armel: C11 atomics requires to be linked with libatomic.a explicitly
@ 2022-01-26 16:43 mathieu.malaterre at gmail dot com
2022-01-26 16:48 ` [Bug c/104248] " mathieu.malaterre at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2022-01-26 16:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104248
Bug ID: 104248
Summary: armel: C11 atomics requires to be linked with
libatomic.a explicitly
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mathieu.malaterre at gmail dot com
Target Milestone: ---
Consider the following c11 code (lib + executable):
```
::::::::::::::
foo.c
::::::::::::::
_Atomic(long long) ll;
int foo(void)
{
++ll;
return 42;
}
::::::::::::::
prog.c
::::::::::::::
int foo(void);
int main(int argc, char* argv[])
{
return foo();
}
```
On Debian armel arch, most built system will fail to compile the above. The
error reported is:
```
/usr/bin/ld: libfoo.a(foo.c.o): in function `foo':
foo.c:(.text+0x40): undefined reference to `__atomic_fetch_add_8'
```
One need to carefully pass `atomic` library on the compilation line. So if you
are lucky this is just:
LDFLAGS=-latomic ...
some other time this more complex as in this above case where a static library
is build, thus one needs to:
```
cc -rdynamic prog.o -o prog libfoo.a -Wl,-Bstatic -latomic -Wl,-Bdynamic
```
---
I see that on some other arch (riscv), the spec file for gcc has been updated
to pass automatically (?) the proper flag: `--as-needed -latomic` [1]
Could someone from gcc/arm team please describe what is the reason for not
doing something equivalent for the spec file in armel case ? Thanks for your
time.
[1] https://github.com/riscv-collab/riscv-gcc/issues/12#issuecomment-276587351
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/104248] armel: C11 atomics requires to be linked with libatomic.a explicitly
2022-01-26 16:43 [Bug c/104248] New: armel: C11 atomics requires to be linked with libatomic.a explicitly mathieu.malaterre at gmail dot com
@ 2022-01-26 16:48 ` mathieu.malaterre at gmail dot com
2022-01-26 17:02 ` [Bug driver/104248] " schwab@linux-m68k.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2022-01-26 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104248
--- Comment #1 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
In case that help, cmake instructions for the test case is:
```
project(p C)
set(CMAKE_C_STANDARD 11)
add_library(foo STATIC foo.c)
add_executable(prog prog.c)
target_link_libraries(prog foo)
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug driver/104248] armel: C11 atomics requires to be linked with libatomic.a explicitly
2022-01-26 16:43 [Bug c/104248] New: armel: C11 atomics requires to be linked with libatomic.a explicitly mathieu.malaterre at gmail dot com
2022-01-26 16:48 ` [Bug c/104248] " mathieu.malaterre at gmail dot com
@ 2022-01-26 17:02 ` schwab@linux-m68k.org
2022-01-26 17:21 ` mathieu.malaterre at gmail dot com
2022-01-26 17:28 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: schwab@linux-m68k.org @ 2022-01-26 17:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104248
--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
This is a general problem with architectures not implementing all atomic
operations inline.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug driver/104248] armel: C11 atomics requires to be linked with libatomic.a explicitly
2022-01-26 16:43 [Bug c/104248] New: armel: C11 atomics requires to be linked with libatomic.a explicitly mathieu.malaterre at gmail dot com
2022-01-26 16:48 ` [Bug c/104248] " mathieu.malaterre at gmail dot com
2022-01-26 17:02 ` [Bug driver/104248] " schwab@linux-m68k.org
@ 2022-01-26 17:21 ` mathieu.malaterre at gmail dot com
2022-01-26 17:28 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2022-01-26 17:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104248
--- Comment #3 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
@Andreas the specific issue I am raising is the difference between the approach
of riscv vs armel. The riscv team is taking the responsability for putting the
missing `-latomic`, while armel expect the user to understand how c11 atomics
are implemented on a particular architecture and fix the link line at the build
system level (eg. cmake / meson ...).
In summary: what is the risk (if any) to update the gcc spec file on armel ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug driver/104248] armel: C11 atomics requires to be linked with libatomic.a explicitly
2022-01-26 16:43 [Bug c/104248] New: armel: C11 atomics requires to be linked with libatomic.a explicitly mathieu.malaterre at gmail dot com
` (2 preceding siblings ...)
2022-01-26 17:21 ` mathieu.malaterre at gmail dot com
@ 2022-01-26 17:28 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-26 17:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104248
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 81358.
Note riscv atomics are messed up too(there is a bug report for that).
*** This bug has been marked as a duplicate of bug 81358 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-26 17:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 16:43 [Bug c/104248] New: armel: C11 atomics requires to be linked with libatomic.a explicitly mathieu.malaterre at gmail dot com
2022-01-26 16:48 ` [Bug c/104248] " mathieu.malaterre at gmail dot com
2022-01-26 17:02 ` [Bug driver/104248] " schwab@linux-m68k.org
2022-01-26 17:21 ` mathieu.malaterre at gmail dot com
2022-01-26 17:28 ` 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).