-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build failure with LTO: examples/cpp/pyperf/PyPerfUtil.cc:29:20: error: ‘PYPERF_BPF_PROGRAM’ violates the C++ One Definition Rule [-Werror=odr] #5091
Comments
Had a few spare cycles to look into this since it didn't seem too difficult. The mismatched typedefs are a completely valid C++ complaint and easily fixed:
"extern const" might seem a bit weird at first but works correctly, provided that the symbol is eventually defined once - which is the case here. The last warning turns out to be a problem with cmake generating a likely mismatching
With these changes the PyPerf example builds perfectly fine against an external libbpf using LTO. |
This creates unnecessary header confusion and valid complaints e.g. when building with LTO. One could argue that there could be an explicit version check for whatever libbpf version bcc needs, but silently trying to be helpful by doing something else is pretty much wrong. This is one part of fixing iovisor#5091 Signed-off-by: Holger Hoffstätte <[email protected]>
This is not just good hygiene but also silences valid complaints about mismatched definitions when building with LTO. This is one part of fixing iovisor#5091 Signed-off-by: Holger Hoffstätte <[email protected]>
Gentoo found a problem when building with LTO + -Werror=odr, see here for the bug.
I have reproduced this with 0.31.0 and despite the fact that PyPerf is "only" an example, I am reporting it since it often indicates header confusion/mixups.
The text was updated successfully, but these errors were encountered: