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

[7.1.0] Cherry-pick: linker_param_file only added to command line if it starts with "@" #21235

Merged

Commits on Feb 7, 2024

  1. Merge extractArgumentsForStaticLinkParamFile and extractArgumentsForD…

    …ynamicLinkParamFile
    
    The implementation was exactly the same. (Probably historically that wasn't the case).
    
    PiperOrigin-RevId: 595674237
    Change-Id: I608b6d5f06db0d81a8abf631505e2552ce45a7b3
    comius committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    d24eb8a View commit details
    Browse the repository at this point in the history
  2. Replace calls to getRawLinkArgv with calls to arguments

    The implementation of both methods is the same. Because the second one is already public, this reduces the number of public methods of LinkCommandLine.
    
    The change is a no-op.
    
    PiperOrigin-RevId: 595771439
    Change-Id: Ia5a494746c1f15be7a16149ee28ae349c57c955d
    comius committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    7f62f0e View commit details
    Browse the repository at this point in the history
  3. Refactor splitting of LinkerCommandLine

    Before `getRawLinkArgv` generated a joint/mixed command line, which was composed of 'linker executable' (first argument) and regular arguments. Reference to 'param file' was mixed into the regular arguments.
    
    Linker command line is long, too long. To fix this, most of linkers are called like `linker @param.file`. The long list of arguments is hidden in `param.file`.
    
    `splitCommandline` used `isLikelyParamFile` to filter out what that `param file` reference was. The result were 2 command lines. First one with 'linker executable' and reference to 'param file' and second command line contained regular arguments, that are written to param file.
    
    Generate those 2 command lines directly. First one is returned by `getCommandLine` and second one (the regular arguments) by `getParamCommandLine`
    
    Param file reference is formatted using `linker_param_file` feature, using `%{linker_param_file}` substitution. In most cases this is just `@%{linker_param_file}`, but there are some linkers that need different formatting.
    
    This change is also needed for Starlarkification of CppLinkAction, because the Starlark interface requires to set how param file is formatted, directly. See https://bazel.build/rules/lib/builtins/Args#use_param_file
    
    Fixes: bazelbuild#18074
    PiperOrigin-RevId: 595912823
    Change-Id: I54b36113d87f975af63341b2dec17b2f861c0ffa
    comius committed Feb 7, 2024
    Configuration menu
    Copy the full SHA
    ebf5a8f View commit details
    Browse the repository at this point in the history