-
Notifications
You must be signed in to change notification settings - Fork 33
Add libutil to sysroot configs for Rust toolchain compatibility #222
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鈥檒l 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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,17 @@ cc_toolchain_import( | |
| ], | ||
| ) | ||
|
|
||
| # libutil is required by Rust's std library for linking (glibc < 2.34). | ||
| cc_toolchain_import( | ||
| name = "util", | ||
| additional_libs = [ | ||
| "lib/aarch64-linux-gnu/libutil-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), | ||
| "lib/aarch64-linux-gnu/libutil.so.1", | ||
| ], | ||
| shared_library = "usr/lib/aarch64-linux-gnu/libutil.so", | ||
| static_library = "usr/lib/aarch64-linux-gnu/libutil.a", | ||
| ) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| # This is a group of essential system libraries. The actual glibc library is split | ||
| # out to fix link ordering problems that cause false undefined symbol positives. | ||
| cc_toolchain_import( | ||
|
|
@@ -180,6 +191,7 @@ cc_toolchain_import( | |
| ":dynamic_linker", | ||
| ":libc", | ||
| ":pthread", | ||
| ":util", | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,17 @@ cc_toolchain_import( | |
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| # libutil is required by Rust's std library for linking (glibc < 2.34). | ||
| cc_toolchain_import( | ||
| name = "util", | ||
| additional_libs = [ | ||
| "lib/x86_64-linux-gnu/libutil-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), | ||
| "lib/x86_64-linux-gnu/libutil.so.1", | ||
| ], | ||
| shared_library = "usr/lib/x86_64-linux-gnu/libutil.so", | ||
| static_library = "usr/lib/x86_64-linux-gnu/libutil.a", | ||
| ) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
|
|
||
| # This is a group of essential system libraries. The actual glibc library is split | ||
| # out to fix link ordering problems that cause false undefined symbol positives. | ||
| cc_toolchain_import( | ||
|
|
@@ -205,6 +216,7 @@ cc_toolchain_import( | |
| ":dynamic_linker", | ||
| ":libc", | ||
| ":pthread", | ||
| ":util", | ||
| ":asan", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,6 +176,17 @@ cc_toolchain_import( | |
| ], | ||
| ) | ||
|
|
||
| # libutil is required by Rust's std library for linking (glibc < 2.34). | ||
| cc_toolchain_import( | ||
| name = "util", | ||
| additional_libs = [ | ||
| "lib/x86_64-linux-gnu/libutil-{glibc_version}.so".format(glibc_version = GLIBC_VERSION), | ||
| "lib/x86_64-linux-gnu/libutil.so.1", | ||
| ], | ||
| shared_library = "usr/lib/x86_64-linux-gnu/libutil.so", | ||
| static_library = "usr/lib/x86_64-linux-gnu/libutil.a", | ||
| ) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| # This is a group of essential system libraries. The actual glibc library is split | ||
| # out to fix link ordering problems that cause false undefined symbol positives. | ||
| cc_toolchain_import( | ||
|
|
@@ -185,6 +196,7 @@ cc_toolchain_import( | |
| ":dynamic_linker", | ||
| ":libc", | ||
| ":pthread", | ||
| ":util", | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
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.
Refactor the cc_toolchain_import invocation as follows:
Why?
Defining these as shared_library or static_library forces the toolchain to link them into every binary. Instead, we should only provide the library paths via the -L flag and populate the Bazel cache. This ensures that when -lutil is invoked, the linker can resolve the dependency without error.