-
Notifications
You must be signed in to change notification settings - Fork 604
numactl: Allow the build of shared lirary #6644
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
base: main
Are you sure you want to change the base?
Conversation
|
Hello @UebelAndre, modules you maintain (numactl) have been updated in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a new BCR version for numactl to enable building a shared library. The changes look mostly good, with a new overlay for Bazel build files and a test module. I have two main points of feedback on the BUILD.bazel overlay file, both of which are based on the BCR style guide and best practices for creating reusable modules.
- The
:utillibrary is defined withlinkstatic = Trueandalwayslink = True, which is overly restrictive for a public library. I've suggested removing these. - The BCR style guide suggests having a library target named after the module. I've recommended adding an alias
numactlfor the main:numalibrary.
Addressing these points will improve the usability of the module for downstream consumers. Also, there's a small typo in the PR title ('lirary' instead of 'library').
| cc_library( | ||
| name = "util", | ||
| srcs = [ | ||
| "util.c", | ||
| ":gen_config_h", | ||
| ], | ||
| hdrs = ["util.h"], | ||
| copts = COMMON_COPTS, | ||
| includes = ["."], | ||
| linkstatic = True, | ||
| target_compatible_with = LINUX_ONLY, | ||
| visibility = ["//visibility:public"], | ||
| deps = [":numa"], | ||
| alwayslink = True, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The util library is defined with linkstatic = True and alwayslink = True. These attributes are quite restrictive for consumers of this library. linkstatic = True forces static linking on all dependents, and alwayslink = True forces the library to be linked even if no symbols are used from it. Since this library has public visibility, these settings can be problematic for downstream users. It's better to let consumers decide how to link. The binaries within this module already request static linking via their own linkstatic attribute, so these attributes on the library are not necessary for them.
To provide more flexibility, I suggest removing linkstatic = True and alwayslink = True.
cc_library(
name = "util",
srcs = [
"util.c",
":gen_config_h",
],
hdrs = ["util.h"],
copts = COMMON_COPTS,
includes = ["."],
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [":numa"],
)
| alias( | ||
| name = "libnuma", | ||
| actual = ":numa", | ||
| visibility = ["//visibility:public"], | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the BCR style guide, for C++ overlays, there should be a public target named after the module.1 The module name is numactl, but there is no library target with this name. Please add an alias from numactl to the main library target :numa for better usability and to conform to the style guide.
alias(
name = "libnuma",
actual = ":numa",
visibility = ["//visibility:public"],
)
alias(
name = "numactl",
actual = ":numa",
visibility = ["//visibility:public"],
)
Style Guide References
Footnotes
-
For C++ overlays: ensure a public target named after the module (or alias
libfoo->foo); visibility is minimal but includes//visibility:publicfor intended APIs. ↩
Currently it only creates a static library. Signed-off-by: Jonh Wendell <[email protected]>
fe454cb to
af38c06
Compare
|
The fact that we have to copy the whole directory to make a patch version makes review harder I think. Here's the actual difference between current state and my changes: --- 2.0.19/overlay/BUILD.bazel 2025-11-25 21:26:37.804820241 -0500
+++ 2.0.19.bcr.1/overlay/BUILD.bazel 2025-11-25 21:41:49.036779752 -0500
@@ -78,9 +78,14 @@
"numacompat1.h",
"numaif.h",
],
+ additional_linker_inputs = ["versions.ldscript"],
copts = COMMON_COPTS,
includes = ["."],
- linkstatic = True,
+ linkopts = [
+ "-Wl,--version-script=$(location versions.ldscript)",
+ "-Wl,-init,numa_init",
+ "-Wl,-fini,numa_fini",
+ ],
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
alwayslink = True, |
|
@jwendell there is a job that conveniently shows a diff |
|
@meteorcloudy this issue seems unrelated to the PR I'm wondering if it'd be better to remove |
|
It's up to the module maintainer to decide, I'm fine with removing rolling in the test matrix. And indeed, this particular failure is more like an issue of the rolling release. |
|
@jwendell if you wanna remove it that's fine with me |
|
/hold |
Currently it only creates a static library.