Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cc/config/aarch64_ubuntu18_gcc8.4/sysroot.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,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",
)

Copy link
Copy Markdown
Collaborator

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:

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",
        "usr/lib/aarch64-linux-gnu/libutil.so",
        "usr/lib/aarch64-linux-gnu/libutil.a",
    ],
)

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.

# 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(
Expand All @@ -189,6 +200,7 @@ cc_toolchain_import(
":dynamic_linker",
":libc",
":pthread",
":util",
],
)

Expand Down
12 changes: 12 additions & 0 deletions cc/config/aarch64_ubuntu20_gcc10/sysroot.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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(
Expand All @@ -180,6 +191,7 @@ cc_toolchain_import(
":dynamic_linker",
":libc",
":pthread",
":util",
],
)

Expand Down
12 changes: 12 additions & 0 deletions cc/config/x86_64_ubuntu18_gcc8.4/sysroot.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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(
Expand All @@ -205,6 +216,7 @@ cc_toolchain_import(
":dynamic_linker",
":libc",
":pthread",
":util",
":asan",
],
visibility = ["//visibility:public"],
Expand Down
12 changes: 12 additions & 0 deletions cc/config/x86_64_ubuntu20_gcc10/sysroot.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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(
Expand All @@ -185,6 +196,7 @@ cc_toolchain_import(
":dynamic_linker",
":libc",
":pthread",
":util",
],
)

Expand Down