Skip to content
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

Use LLVM_VERSION_MAJOR from llvm-config.h instead of inferred LLVM_MAJOR_VERSION #4737

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

chantra
Copy link
Contributor

@chantra chantra commented Sep 13, 2023

Instead of inferring this from within the CMakeList.txt file, we can pull it directly from llvm-config.h.

…JOR_VERSION

Instead of inferring this from within the CMakeList.txt file, we can pull it
directly from llvm-config.h.
@chantra
Copy link
Contributor Author

chantra commented Sep 13, 2023

hum... I am not sure those errors are related. Forcing an update to re-trigger build.

@chantra
Copy link
Contributor Author

chantra commented Sep 14, 2023

ok, tests that previously failed, now succeed. Tests that previously succeeded, now fail.

@@ -19,7 +19,7 @@
#include <tuple>
#include <vector>

#if LLVM_MAJOR_VERSION >= 15
Copy link
Collaborator

Choose a reason for hiding this comment

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

Too much code churn, could we avoid this change here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chenhengqi what do you mean by too much code churn?

This is essentially a sed s/LLVM_MAJOR_VERSION/LLVM_VERSION_MAJOR/ on the files, e.g from internally defined to the one provided by llvm itself.

The main reason for doing this is that when using alternate build systems such as buck, bazel... the LLVM version get automatically discovered at build time without needing some special handling by the build system.
Given that this is readily available, we can use it directly instead of re-inventing the wheel.

Copy link
Collaborator

Choose a reason for hiding this comment

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

without needing some special handling by the build system

But we still rely on cmake to find the LLVM libraries, no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a build agnostic system, the build system will find the llvm libraries (cmake, make, bazel, buck....), yes.
LLVM library itself (via llvm-config.h https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/include/llvm/Config/llvm-config.h.cmake#L69 ) exposes the major version (and more).

Currently, this is inferred from

string(REGEX MATCH "^([0-9]+).*" _ ${LLVM_PACKAGE_VERSION})

I am replacing this by llvm native defines.

@davemarchevsky davemarchevsky merged commit 7d1ece0 into iovisor:master Oct 16, 2023
11 checks passed
chantra added a commit to chantra/bcc that referenced this pull request Oct 20, 2023
In iovisor#4737 I added support for using LLVM_VERSION_MAJOR from llvm-config.h instead
of inferred LLVM_MAJOR_VERSION.
This went through CI just fine because CI uses LLVM 14 as the latest LLVM
version (through the fedora 36 build).

`bcc_debug.cc` was using LLVM_VERSION_MAJOR before any include that would
actually define it, causing LLVM_VERSION_MAJOR to default to 0.
This was fine for builds using LLVM < 15, but does not work for LLVM >= 15.

On Ubuntu 23.04, using
```
-- Found LLVM: /usr/lib/llvm-15/include 15.0.7 (Use LLVM_ROOT envronment variable for another version of LLVM)
```

compilation of bcc_debug.cc would fail with:
https://gist.github.com/chantra/d2277d500d150ec2cc863dd412bd3264

This change moves the include of `bpf_module.h` up the file to make sure
LLVM_VERSION_MAJOR is defined.

After this change, compilation goes through just fine.

Signed-off-by: Manu Bretelle <chantr4@gmail.com>
chantra added a commit to chantra/bcc that referenced this pull request May 29, 2024
In iovisor#4737 I added depedency on llvm-config.h in order to discover what LLVM version
is being used. This was only meant to be used at build time.
By adding llvm-config.h in bpf_module.h, a public header of libbcc, I introduced
a dependency on llvm-dev to libbcc which is unnecessary.

This change removes the include from `bpf_module.h`, which should be enough.

It does not seem I need to add the include in any other files.

Fixes iovisor#4997

Signed-off-by: Manu Bretelle <chantr4@gmail.com>
chantra added a commit to chantra/bcc that referenced this pull request May 29, 2024
In iovisor#4737 I added depedency on llvm-config.h in order to discover what LLVM version
is being used. This was only meant to be used at build time.
By adding llvm-config.h in bpf_module.h, a public header of libbcc, I introduced
a dependency on llvm-dev to libbcc which is unnecessary.

This change removes the include from `bpf_module.h`, which should be enough.

It does not seem I need to add the include in any other files.

Fixes iovisor#4997

Signed-off-by: Manu Bretelle <chantr4@gmail.com>
chantra added a commit to chantra/bcc that referenced this pull request May 29, 2024
In iovisor#4737 I added depedency on llvm-config.h in order to discover what LLVM version
is being used. This was only meant to be used at build time.
By adding llvm-config.h in bpf_module.h, a public header of libbcc, I introduced
a dependency on llvm-dev to libbcc which is unnecessary.

This change removes the include from `bpf_module.h`, which should be enough, and
add it to `bpf_module.cc` instead.

Fixes iovisor#4997

Signed-off-by: Manu Bretelle <chantr4@gmail.com>
yonghong-song pushed a commit that referenced this pull request May 30, 2024
In #4737 I added depedency on llvm-config.h in order to discover what LLVM version
is being used. This was only meant to be used at build time.
By adding llvm-config.h in bpf_module.h, a public header of libbcc, I introduced
a dependency on llvm-dev to libbcc which is unnecessary.

This change removes the include from `bpf_module.h`, which should be enough, and
add it to `bpf_module.cc` instead.

Fixes #4997

Signed-off-by: Manu Bretelle <chantr4@gmail.com>
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.

3 participants