Skip to content

coredump: enable cgo warnings#613

Merged
fabled merged 27 commits intoopen-telemetry:mainfrom
grafana:korniltsev/coredump_warnings
Jul 30, 2025
Merged

coredump: enable cgo warnings#613
fabled merged 27 commits intoopen-telemetry:mainfrom
grafana:korniltsev/coredump_warnings

Conversation

@korniltsev
Copy link
Copy Markdown
Contributor

@korniltsev korniltsev commented Jul 16, 2025

@korniltsev korniltsev force-pushed the korniltsev/coredump_warnings branch from a013733 to e88a47c Compare July 17, 2025 07:15
Comment thread tools/coredump/ebpfcode.go Outdated
Comment thread tools/coredump/ebpfcode.go Outdated
Comment thread support/ebpf/bpfdefs.h Outdated
#cgo CFLAGS: -Wno-unused-label
#cgo CFLAGS: -Wno-sign-compare
#cgo CFLAGS: -Wno-unknown-pragmas
#cgo CFLAGS: -Wno-unused-parameter
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately can not enable this one in cgo because of golang/go#71225

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# go.opentelemetry.io/ebpf-profiler/tools/coredump
cgo-generated-wrappers: In function '_cgoexp_b173915d1d03___bpf_log':
cgo-generated-wrappers:91:43: error: unused parameter 'p' [-Werror=unused-parameter]
cgo-generated-wrappers: In function '_cgoexp_b173915d1d03___push_frame':
cgo-generated-wrappers:92:46: error: unused parameter 'p' [-Werror=unused-parameter]
cgo-generated-wrappers: In function '_cgoexp_b173915d1d03_bpf_ktime_get_ns':
cgo-generated-wrappers:93:50: error: unused parameter 'p' [-Werror=unused-parameter]
cgo-generated-wrappers: In function '_cgoexp_b173915d1d03_bpf_get_current_comm':
cgo-generated-wrappers:94:54: error: unused parameter 'p' [-Werror=unused-parameter]
cgo-generated-wrappers: In function '_cgoexp_b173915d1d03___bpf_probe_read_user':
cgo-generated-wrappers:95:55: error: unused parameter 'p' [-Werror=unused-parameter]
cgo-generated-wrappers: In function '_cgoexp_b173915d1d03___bpf_map_lookup_elem':
cgo-generated-wrappers:96:55: error: unused parameter 'p' [-Werror=unused-parameter]
cc1: all warnings being treated as errors

@korniltsev korniltsev marked this pull request as ready for review July 17, 2025 07:25
@korniltsev korniltsev requested review from a team as code owners July 17, 2025 07:25
Comment thread support/ebpf/Makefile
@korniltsev korniltsev force-pushed the korniltsev/coredump_warnings branch from 87e233e to b8e751b Compare July 21, 2025 03:28
Comment thread support/ebpf/dotnet_tracer.ebpf.c Outdated
Comment on lines +109 to +111
#if !defined(TESTING_COREDUMP)
#pragma unroll 256
#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid code repetition by defining a macro (e.g. UNROLL), which is empty for gcc.
Just in case, https://github.com/open-telemetry/opentelemetry-ebpf-profiler/pull/613/files#r2218507693 can't be solved to use the same compiler everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied, please take a look.

@korniltsev korniltsev requested a review from rockdaboot July 21, 2025 14:57
Copy link
Copy Markdown
Contributor

@rockdaboot rockdaboot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, LGTM

Comment thread support/ebpf/tracemgmt.h Outdated
@korniltsev korniltsev force-pushed the korniltsev/coredump_warnings branch from 8ffbb79 to a21ac05 Compare July 28, 2025 02:35
Comment thread support/ebpf/bpfdefs.h Outdated
Comment on lines +186 to +188
#define _PRAGMA_UNROLL(x) _Pragma(_STR(unroll x))
// Macro for loop unrolling. Expands to the appropriate pragma for clang.
#define UNROLL(N) _PRAGMA_UNROLL(N)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we just?

Suggested change
#define _PRAGMA_UNROLL(x) _Pragma(_STR(unroll x))
// Macro for loop unrolling. Expands to the appropriate pragma for clang.
#define UNROLL(N) _PRAGMA_UNROLL(N)
// Macro for loop unrolling. Expands to the appropriate pragma for clang.
#define UNROLL _Pragma(unroll 256)

the number is maximum unrolled loops, and the largest is in dotnet, so we can use 256 unconditionally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could then just write on all instances UNROLL for () (keep UNROLL on same line with for).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily like the idea to write UNROLL for on the same line, but lets try and see how it looks and what others think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format seem to be happy with it

@korniltsev korniltsev force-pushed the korniltsev/coredump_warnings branch from 6f7504a to 1cc7b66 Compare July 29, 2025 03:06
Copy link
Copy Markdown
Contributor

@fabled fabled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fabled fabled merged commit 76c8bd2 into open-telemetry:main Jul 30, 2025
27 checks passed
gnurizen pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Sep 11, 2025
gnurizen pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Sep 11, 2025
gnurizen pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Sep 12, 2025
gnurizen pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants