Skip to content

Rule based toolchains should expand args with data #364

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

Open
keith opened this issue Feb 25, 2025 · 2 comments
Open

Rule based toolchains should expand args with data #364

keith opened this issue Feb 25, 2025 · 2 comments

Comments

@keith
Copy link
Member

keith commented Feb 25, 2025

I wrote a args rule like this:

cc_args(
    name = "asan_compile_args",
    actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
    args = [
        "-fno-sanitize-recover=all",
        "-fsanitize=address",
        "-fsanitize-ignorelist=$(location //bazel/internal:asan-suppressions.txt)",
    ],
    data = [
        "//bazel/internal:asan-suppressions.txt",
    ],
)

Which I think we should be able to support

@armandomontanez
Copy link
Collaborator

The cc_args.format attribute can do this today, and can handle expansion of directory rules from bazel_skylib as well as files and cc_variables. I don't think there's a significant reason to not support this though.

@jscissr
Copy link

jscissr commented May 6, 2025

Putting a file in cc_args.format doesn't work because the format argument is missing allow_files = True. As a workaround, the file can be wrapped in a filegroup:

filegroup(
    name = "example",
    srcs = ["example.txt"],
)

cc_args(
    name = "default_flags",
    actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
    args = [
        "--example={example}",
    ],
    format = {"example": ":example"},
    data = [":example"],
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants