Skip to content
Draft
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
26 changes: 25 additions & 1 deletion misc/bazel/rust.bzl
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@semmle_code//buildutils-internal:glibc_symbols_check.bzl", "glibc_symbols_check")
load("@semmle_code//buildutils-internal:lipo.bzl", "universal_binary")
load("@semmle_code//buildutils-internal:transitions.bzl", "forward_binary_from_transition", "get_transition_attrs")

def _full_lto_transition_impl(_settings, _attr):
return {"@rules_rust//rust/settings:lto": "fat"}

_full_lto_transition = transition(
implementation = _full_lto_transition_impl,
inputs = [],
outputs = ["@rules_rust//rust/settings:lto"],
)

_full_lto_binary = rule(
implementation = forward_binary_from_transition,
attrs = get_transition_attrs(_full_lto_transition),
)

def codeql_rust_binary(
name,
full_lto = False,
target_compatible_with = None,
visibility = None,
symbols_test = True,
**kwargs):
rust_label_name = "single_arch/" + name
binary_dep = ":" + rust_label_name
if full_lto:
lto_label_name = "full_lto/" + name
_full_lto_binary(
name = lto_label_name,
dep = binary_dep,
)
binary_dep = ":" + lto_label_name
universal_binary(
name = name,
dep = ":" + rust_label_name,
dep = binary_dep,
target_compatible_with = target_compatible_with,
visibility = visibility,
)
Expand Down
1 change: 1 addition & 0 deletions rust/extractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ codeql_rust_binary(
"src/qltest_cargo.mustache",
"src/nightly-toolchain/rust-toolchain.toml",
],
full_lto = True,
proc_macro_deps = all_crate_deps(
proc_macro = True,
) + [
Expand Down
Loading