Skip to content
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

ninja tool can call subst incorrectly #4580

Open
mwichmann opened this issue Jul 29, 2024 · 0 comments
Open

ninja tool can call subst incorrectly #4580

mwichmann opened this issue Jul 29, 2024 · 0 comments
Labels

Comments

@mwichmann
Copy link
Collaborator

This information is collected from the discord thread at
https://discord.com/channels/571796279483564041/1262451038435414027
Filing this to make sure it's captured, I did not discover it.

In the ninja tool, in the file SCons/Tool/ninja/Utils.py, we can see the following code snippet in the generate_command function:

        genstring = action.genstring(targets, sources, env)
        if executor is not None:
            cmd = env.subst(genstring, executor=executor)
        else:
            cmd = env.subst(genstring, targets, sources)

When env.subst is called with positional arguments only, they are interpreted in order as string, raw, target, source, conv, executor. Thus, the targets value will be interpreted by subst as being raw, and the sources value will be target. Issuing those as keyword arguments fixes the problem:

            cmd = env.subst(genstring, targets=targets, sources=sources)

This must not be exercised by a test, since we're not seeing a problem - contribution of a small test case that shows breakage would help move a change along.

Code link for this:

cmd = env.subst(genstring, targets, sources)

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

No branches or pull requests

1 participant