Rule-based toolchains can use cc_args to express precise link behavior, including -L paths, -l libraries, link-mode selection, and ordered linker state such as --as-needed or --start-group.
For example:
cc_args(
name = "glibc_dynamic_link_args",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = [
"-L{glibc_library_search_path}",
"-Wl,--push-state",
"-Wl,--as-needed",
"-lc",
"-lpthread",
"-ldl",
"-Wl,--pop-state",
],
data = [
"//runtimes/glibc:glibc_library_search_directory",
],
format = {
"glibc_library_search_path": "//runtimes/glibc:glibc_library_search_directory",
},
)
The missing part is runtime handling. Dynamic libraries selected this way can be available to the link action, but they do not become runfiles and do not contribute to runtime_library_search_directories.
cc_toolchain.dynamic_runtime_lib provides runtime handling for toolchain dynamic libraries, but we can't use that when we need to control ordered linker flags for the same runtime libraries.
It would be useful for rule-based toolchain configuration to express toolchain dynamic runtime libraries so binaries and tests get matching runfiles and runtime search paths.
This is the last missing piece for https://github.com/hermeticbuild/hermetic-llvm to be able to provide 100% hermetic runtimes compiled from source both statically and dynamically.
Rule-based toolchains can use
cc_argsto express precise link behavior, including -L paths, -l libraries, link-mode selection, and ordered linker state such as --as-needed or --start-group.For example:
The missing part is runtime handling. Dynamic libraries selected this way can be available to the link action, but they do not become runfiles and do not contribute to runtime_library_search_directories.
cc_toolchain.dynamic_runtime_lib provides runtime handling for toolchain dynamic libraries, but we can't use that when we need to control ordered linker flags for the same runtime libraries.
It would be useful for rule-based toolchain configuration to express toolchain dynamic runtime libraries so binaries and tests get matching runfiles and runtime search paths.
This is the last missing piece for https://github.com/hermeticbuild/hermetic-llvm to be able to provide 100% hermetic runtimes compiled from source both statically and dynamically.