[all-commits] [llvm/llvm-project] 22a01b: [LinkerWrapper] Forward `-mllvm` options to the li...

Joseph Huber via All-commits all-commits at lists.llvm.org
Sat Jul 9 18:18:34 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 22a01b860b909d7836658e0c58e484950766239b
      https://github.com/llvm/llvm-project/commit/22a01b860b909d7836658e0c58e484950766239b
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-09 (Sat, 09 Jul 2022)

  Changed paths:
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/Driver/linker-wrapper.c
    M clang/test/Driver/openmp-offload.c
    M clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

  Log Message:
  -----------
  [LinkerWrapper] Forward `-mllvm` options to the linker wrapper

This patch adds the ability to use `-mllvm` options in the linker
wrapper when performing bitcode linking or the module compilation.
This is done by passing in the LLVM argument to the clang-linker-wrapper
tool. Inside the linker-wrapper tool we invoke the `CommandLine` parser
solely for forwarding command line options to the `clang-linker-wrapper`
to the LLVM tools that also use the `CommandLine` parser. The actual
arguments to the linker wrapper are parsed using the `Opt` library
instead.

For example, in the following command the `CommandLine` parser will attempt to
parse `abc`, while the `opt` parser takes `-mllvm <arg>` and ignores it so it is
not passed to the linker arguments.
```
clang-linker-wrapper -mllvm -abc -- <linker-args>
```

As far as I can tell this is the easiest way to forward arguments to
LLVM tool invocations. If there is a better way to pass these arguments
(such as through the LTO config) let me know.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D129424




More information about the All-commits mailing list