CodeSamples: Add -fcommon to GCC_ARGS
PATCH 1/1 CodeSamples: Add -fcommon to GCC_ARGS
An item on GCC 10 changes [1] reads:
- GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.
This change affects builds under CodeSamples/ as reported by Elad [2].
As a band-aide fix, add -fcommon to GCC_ARGS where necessary.
---
Hi,
Under Ubuntu 22.04, there is another issue with distro package of liburcu-dev (0.13.1).
"make" under CodeSamples/datastuct/Issaquah/ result in error:
cc -g -O3 -Wall -fcommon -o existence_test existence.c existence_test.c -lpthread -lurcu -lurcu-signal In file included from /usr/include/x86_64-linux-gnu/urcu/pointer.h:39,
from /usr/include/x86_64-linux-gnu/urcu-pointer.h:1,
from /usr/include/x86_64-linux-gnu/urcu/rculist.h:30,
from ../../api.h:847,
from existence.c:30:
existence.h: In function ‘existence_exists_relaxed’:
existence.h:54:32: error: invalid use of undefined type ‘struct existence’
54 | struct existence *ep = rcu_dereference(*epp);
| ^~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/urcu/pointer.h:39,
from /usr/include/x86_64-linux-gnu/urcu-pointer.h:1,
from /usr/include/x86_64-linux-gnu/urcu/rculist.h:30,
from ../../api.h:847,
from existence_test.c:26:
existence.h: In function ‘existence_exists_relaxed’:
existence.h:54:32: error: invalid use of undefined type ‘struct existence’
54 | struct existence *ep = rcu_dereference(*epp);
| ^~~~~~~~~~~~~~~make: *** [Makefile:48: existence_test] Error 1
This can be fixed by installing 0.13.2 (from https://liburcu.org/).
However, you will still see warning messages like:
cc -g -O3 -Wall -fcommon -o treetorture tree.c existence.c spinlockmult.c ../../lib/random.c -lpthread -lurcu -lurcu-signal In function 'free_treenode_cache',
inlined from 'tree_remove_all' at tree.c:102:2,
inlined from 'tree_free' at tree.c:128:2:
tree.c:251:9: warning: 'free' called on pointer 'trp' with nonzero offset 96 [-Wfree-nonheap-object]
251 | free(tnp);
| ^~~~~~~~~
In function 'free_treenode_cache',
inlined from 'tree_remove_all' at tree.c:102:2,
inlined from 'tree_free' at tree.c:128:2,
inlined from 'manual_smoke' at treetorture.h:481:2:
tree.c:251:9: warning: 'free' called on pointer 'trp0' with nonzero offset 96 [-Wfree-nonheap-object]
251 | free(tnp);
| ^~~~~~~~~
In file included from tree.c:928:
treetorture.h: In function 'manual_smoke':
treetorture.h:424:16: note: returned from 'tree_alloc'
424 | trp0 = tree_alloc();
| ^~~~~~~~~~~~
In function 'free_treenode_cache',
inlined from 'tree_remove_all' at tree.c:102:2,
inlined from 'tree_free' at tree.c:128:2,
inlined from 'manual_smoke' at treetorture.h:482:2:
tree.c:251:9: warning: 'free' called on pointer 'trp1' with nonzero offset 96 [-Wfree-nonheap-object]
251 | free(tnp);
| ^~~~~~~~~[snip]
I have not yet looked into these warnings.
Thanks, Akira
--
CodeSamples/datastruct/Issaquah/Makefile | 2 ++ CodeSamples/datastruct/hash/Makefile | 2 ++ CodeSamples/defer/Makefile | 2 ++ 3 files changed, 6 insertions(+)
CodeSamples/datastruct/Issaquah/Makefile +2 -0
@@ -32,6 +32,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + # NOTE: For decent scalability on update-side tests as of early 2015, # use something like jemalloc() instead of glibc malloc(). # If you install jemalloc at /home/paulmck/jemalloc, you will
CodeSamples/datastruct/hash/Makefile +2 -0
@@ -32,6 +32,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + hash_bkt: hash_bkt.c ../../api.h hashtorture.h cc $(GCC_ARGS) -DTEST_HASH -o hash_bkt hash_bkt.c $(LIB)/random.c -lpthread
CodeSamples/defer/Makefile +2 -0
@@ -61,6 +61,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + # Note that bug_srcu_a is disabled until completed. bug_srcu_a: bug_srcu_a.c srcu.c ../api.h cc $(GCC_ARGS) -o bug_srcu_a -DTEST bug_srcu_a.c -lurcu -lpthread
base-commit: 7f7a2c25e3d2e87412d10bdb355b369eca524b1a
Signature · 1 line
2.25.1
PATCH v2 1/1 CodeSamples: Add -fcommon to GCC_ARGS
An item on GCC 10 changes [1] reads:
- GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.
This change affects builds under CodeSamples/ as reported by Elad [2].
As a band-aide fix, add -fcommon to GCC_ARGS where necessary.
---
v2:
- Fix mismatch of From: and S-o-b.
Thanks, Akira
--
CodeSamples/datastruct/Issaquah/Makefile | 2 ++ CodeSamples/datastruct/hash/Makefile | 2 ++ CodeSamples/defer/Makefile | 2 ++ 3 files changed, 6 insertions(+)
CodeSamples/datastruct/Issaquah/Makefile +2 -0
@@ -32,6 +32,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + # NOTE: For decent scalability on update-side tests as of early 2015, # use something like jemalloc() instead of glibc malloc(). # If you install jemalloc at /home/paulmck/jemalloc, you will
CodeSamples/datastruct/hash/Makefile +2 -0
@@ -32,6 +32,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + hash_bkt: hash_bkt.c ../../api.h hashtorture.h cc $(GCC_ARGS) -DTEST_HASH -o hash_bkt hash_bkt.c $(LIB)/random.c -lpthread
CodeSamples/defer/Makefile +2 -0
@@ -61,6 +61,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + # Note that bug_srcu_a is disabled until completed. bug_srcu_a: bug_srcu_a.c srcu.c ../api.h cc $(GCC_ARGS) -o bug_srcu_a -DTEST bug_srcu_a.c -lurcu -lpthread
base-commit: 7f7a2c25e3d2e87412d10bdb355b369eca524b1a
Signature · 1 line
2.25.1
Paul E. McKenney
AppliedQuoted 8 lines · Akira Yokosawa
An item on GCC 10 changes [1] reads:
- GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.
Quoted 8 lines
This change affects builds under CodeSamples/ as reported by Elad [2].
As a band-aide fix, add -fcommon to
GCC_ARGSwhere necessary.Reported-by Elad Lahav <[email protected]>Signed-off-by Akira Yokosawa <[email protected]>
Queued, thank you both!
Thanx, Paul
Quoted 57 lines
---
v2:
- Fix mismatch of From: and S-o-b.Thanks, Akira
--
CodeSamples/datastruct/Issaquah/Makefile | 2 ++ CodeSamples/datastruct/hash/Makefile | 2 ++ CodeSamples/defer/Makefile | 2 ++ 3 files changed, 6 insertions(+)CodeSamples/datastruct/Issaquah/Makefile +2
-0@@ -32,6 +32,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + # NOTE: For decent scalability on update-side tests as of early 2015, # use something like jemalloc() instead of glibc malloc(). # If you install jemalloc at /home/paulmck/jemalloc, you willCodeSamples/datastruct/hash/Makefile +2
-0@@ -32,6 +32,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + hash_bkt: hash_bkt.c ../../api.h hashtorture.h cc $(GCC_ARGS) -DTEST_HASH -o hash_bkt hash_bkt.c $(LIB)/random.c -lpthreadCodeSamples/defer/Makefile +2
-0@@ -61,6 +61,8 @@ endif include $(top)/recipes.mk +GCC_ARGS += -fcommon + # Note that bug_srcu_a is disabled until completed. bug_srcu_a: bug_srcu_a.c srcu.c ../api.h cc $(GCC_ARGS) -o bug_srcu_a -DTEST bug_srcu_a.c -lurcu -lpthreadbase-commit:
7f7a2c25e3d2e87412d10bdb355b369eca524b1aSignature · 1 line
2.25.1