Skip to content

CodeSamples: Make non-default combinations of cc and -O levels happy

Akira Yokosawa perfbook 1 version Applied

Status from this message: Queued and pushed, thank you very much! And happy perfect-square

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/6CodeSamples: Put $(GCC_ARGS) in cc argument listCodeSamples/intro/Makefile CodeSamples/locking/Makefile+9 -90 replies
2/6CodeSamples/datastruct: Move struct declaration from .c to .hCodeSamples/datastruct/Issaquah/existence.c CodeSamples/datastruct/Issaquah/existence.h+6 -70 replies
3/6CodeSamples/advsync: Add explicit type cast in xchg()CodeSamples/advsync/q.c CodeSamples/advsync/wfenqueue.c+2 -20 replies
4/6CodeSamples/count: Add static to __inline__ function declarationsCodeSamples/count/count_end.c CodeSamples/count/count_end_rcu.c CodeSamples/count/count_stack.c +1 more+10 -100 replies
5/6CodeSamples: Add #ifndef SUBOBJ to api-pthreads.hCodeSamples/api-pthreads/api-pthreads.h CodeSamples/datastruct/Issaquah/Makefile CodeSamples/datastruct/hash/Makefile +2 more+39 -90 replies
6/6CodeSamples/datastruct/Issaquah: Remove unused variablesCodeSamples/datastruct/Issaquah/existence_test.c CodeSamples/datastruct/Issaquah/tree.c+0 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH -perfbook 0/6] CodeSamples: Make non-default combinations of cc and -O levels happy

While testing commit f2596972845b ("CodeSamples: Fix liburcu-signal support deprecation"), I observed build errors under Ubuntu 22.04.

Which prompted me to test various combinations of cc and optimization levels in building under CodeSamples/.

This patch set is a collection of fixes/adjustments to make such various choices happy.

Patch 1/6 is a preliminary change for ease of experimenting alternative GCC_ARGS such as "-g -Wall -O0", "-g -Wall -O1", and so on, under CodeSamples/.

Patch 2/6 fixes an issue around forward declaration of struct in .h file failing to satisfy compiler's assumption of accessing them from inline functions. Looks like this matters with some of gcc versions in low level optimization, but gcc of Ubuntu 22.04 hits this even at -O3. Actual declaration of a struct seems to be needed in front of inline functions who access such a struct.

Patch 3/6 adjusts indirection level of pointer arguments in xchg().

Patch 4/6 adds "static" to __inline__ functions.

Patch 5/6 fixes errors of duplicate symbols due to api.h being included in multiple .c files linked together. As a workaround, "#ifndef SUBOBJ" is added in api-pthreads.h and a flag of -DSUBOBJ is added in Makefiles to recipes of .c --> _sub.o.

Patch 6/6 removes variables whose final values are never used. Recent clang is pretty strict on set-but-unused variables.

To test against clang, you need to redirect cc --> clang by, for example, symlinking $HOME/bin/cc --> /usr/bin/clang or similar.

Thanks, Akira
--
Akira Yokosawa (6):
CodeSamples: Put $(GCC_ARGS) in cc argument list CodeSamples/datastruct: Move struct declaration from .c to .h CodeSamples/advsync: Add explicit type cast in xchg() CodeSamples/count: Add static to __inline__ function declarations
CodeSamples: Add #ifndef SUBOBJ to api-pthreads.h CodeSamples/datastruct/Issaquah: Remove unused variables

 CodeSamples/advsync/q.c                          |  2 +-
 CodeSamples/advsync/wfenqueue.c                  |  2 +-
 CodeSamples/api-pthreads/api-pthreads.h          | 14 ++++++++++++++
 CodeSamples/count/count_end.c                    |  4 ++--
 CodeSamples/count/count_end_rcu.c                |  4 ++--
 CodeSamples/count/count_stack.c                  |  6 +++---
 CodeSamples/count/count_stat_atomic.c            |  6 +++---
 CodeSamples/datastruct/Issaquah/Makefile         | 14 ++++++++++----
 CodeSamples/datastruct/Issaquah/existence.c      |  6 ------
 CodeSamples/datastruct/Issaquah/existence.h      |  7 ++++++-
 CodeSamples/datastruct/Issaquah/existence_test.c |  3 ---
 CodeSamples/datastruct/Issaquah/tree.c           |  6 ------
 CodeSamples/datastruct/hash/Makefile             |  7 +++++--
 CodeSamples/defer/Makefile                       |  7 +++++--
 CodeSamples/defer/hazptr.h                       |  6 +++++-
 CodeSamples/intro/Makefile                       | 12 ++++++------
 CodeSamples/locking/Makefile                     |  6 +++---
 17 files changed, 66 insertions(+), 46 deletions(-)

base-commit: 41e6a800d630336b1d8e614b3d11281e42e880c7

Signature · 1 line
2.34.1