Skip to content

Bazel dwp action configuration does not pass environment variables, so we cannot use them in this script/tool (related to fission feature) #25336

@trzeciak

Description

@trzeciak

Description of the feature request:

As the title says, the action to combine dwo files into dwp files is not configured to provide environment variables, take a look at the latest source code, the action named CcGenerateDwp is declared here LINK:

    ctx.actions.run(
        mnemonic = "CcGenerateDwp",
        tools = packager["tools"],
        executable = packager["executable"],
        toolchain = cc_helper.CPP_TOOLCHAIN_TYPE,
        arguments = [packager["arguments"]],
        inputs = packager["inputs"],
        outputs = packager["outputs"],
    )

As you can see, the env variable is not declared for this action.
The same applies to CcGenerateIntermediateDwp action.

For comparison, I found the CppArchive action where the env variable is set LINK:

    env = cc_common.get_environment_variables(
        feature_configuration = feature_configuration,
        action_name = CPP_LINK_STATIC_LIBRARY_ACTION_NAME,
        variables = archiver_variables,
    )
    …
    ctx.actions.run(
        executable = archiver_path,
        toolchain = cc_helper.CPP_TOOLCHAIN_TYPE,
        arguments = [args],
        env = env,
        inputs = depset(
            direct = object_files,
            transitive = [
                cc_toolchain.all_files,
            ],
        ),
        use_default_shell_env = True,
        outputs = [output_file],
        mnemonic = "CppArchive",
    )

I would expect there should be an option to set env's variables for the dwp tool as well.

Which category does this issue belong to?

C++ Rules

What underlying problem are you trying to solve with this feature?

I ran into this when trying to implement debug fission functionality in the emsdk-bazel-toolchain. Here's a link to the PR discussion thread: emscripten-core/emsdk#1531 (comment)

Which operating system are you running Bazel on?

macOS, linux and windows

What is the output of bazel info release?

release 7.5.0, release 5.4.0, release 6.4.0, release 8.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?


Have you found anything relevant by searching the web?

I initially asked on bazel-slack, but no response: https://bazelbuild.slack.com/archives/CGA9QFQ8H/p1739488236571719,
Then I started analyzing it in PR to emsdk: emscripten-core/emsdk#1531 (comment)

Any other information, logs, or outputs that you want to share?

I'm submitting this as a feature request, even though it looks a bit like a bug/oversight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-CPPIssues for C++ rulestype: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions