[cfe-dev] Understanding Options.td

David Greene via cfe-dev cfe-dev at lists.llvm.org
Tue Mar 5 07:29:17 PST 2019


I am looking at adding an option that should only be passed by the user
at link time.  The option affects how clang behaves and does not get
passed to the linker itself.  Clang should warn if the option is given
in a non-linking context.

Looking at Driver/Options.td, I see a couple of definitions that might
be relevant:

// LinkerInput - The option is a linker input.
def LinkerInput : OptionFlag;

def Link_Group : OptionGroup<"<T/e/s/t/u group>">, DocName<"Linker flags">,
                 DocBrief<[{Flags that are passed on to the linker}]>;

I also see some uses of these:

def hip_device_lib_path_EQ : Joined<["--"], "hip-device-lib-path=">, Group<Link_Group>,
  HelpText<"HIP device library path">;
def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group<Link_Group>,
  HelpText<"HIP device library">;

def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;

I am not sure how to interpret this.  On the one hand, I imagine the HIP
options are options that affect how clang behaves but do not get passed
to the linker, so Link_Group seems like the right things to use.  On the
other hand, I don't think linkers support a -framework option so maybe
LinkerInput is what I should use.  I don't know what "linker input"
means, nor what "passed on to the linker" means given what I am seeing
in Options.td.

Is there some guidance on the use of Flags and Group for options?  What
is the right incantation for my needs?

Thanks!

                            -David



More information about the cfe-dev mailing list