diff --git a/include/eld/Driver/GnuLinkerOptions.td b/include/eld/Driver/GnuLinkerOptions.td index 637c181c5..13ae53fdf 100644 --- a/include/eld/Driver/GnuLinkerOptions.td +++ b/include/eld/Driver/GnuLinkerOptions.td @@ -6,6 +6,20 @@ include "llvm/Option/OptParser.td" +// The definitions below are copied from lld. + +// For options whose names are multiple letters, either one dash or +// two can precede the option name except those that start with 'o'. +class F : Flag<["--", "-"], name>; +class J : Joined<["--", "-"], name>; + +// Convenience classes for long options which only accept two dashes. For lld +// specific or newer long options, we prefer two dashes to avoid collision with +// short options. For many others, we have to accept both forms to be compatible +// with GNU ld. +class FF : Flag<["--"], name>; +class JJ : Joined<["--"], name>; + //===----------------------------------------------------------------------===// /// Utility Functions //===----------------------------------------------------------------------===// @@ -16,7 +30,183 @@ multiclass smDash { def opt1_eq : Joined<["-"], opt1 #"=">, Alias(opt1)>; // Compatibility aliases def opt2_dashdash : Separate<["--"], opt2>, Alias(opt1)>; - def opt2_dashdash_eq : Joined<["--"], opt2 #"=">, Alias(opt1)>; + def opt2_dashdash_eq : JJ, HelpText; + def opt_eq : Joined<["-"], opt #"=">, Alias(opt)>; + + // Deprecated aliases + def opt_dashdash : Separate<["--"], opt>, Alias(opt)>, + HelpText<"Deprecated alias for -" # opt>; + def opt_dashdash_eq : JJ, HelpText; + + // Deprecated aliases + def opt_dash : Flag<["-"], opt>, Alias(opt)>, + HelpText<"Deprecated alias for --" # opt>; +} + +// Multiple dash option combined with deprecated single dash option. +multiclass mDashDeprWithOpt { + // Option + def "" : FF, HelpText; + + // Deprecated aliases + def opt_dash : Flag<["-"], opt>, Alias(realopt)>, + HelpText<"Deprecated alias for --" # opt>; +} + +// Multiple dash option combined with deprecated single dash option with equals. +multiclass mDashDeprEq { + // Option + def "" : Separate<["--"], opt>, HelpText; + def opt_eq : JJ, Alias(opt)>, + HelpText<"Deprecated alias for --" # opt>; + def opt_dash_eq : Joined<["-"], opt #"=">, Alias(opt)>, + HelpText<"Deprecated alias for --" # opt # "=">; +} + +// Multiple dash option combined with deprecated single dash option with equals. +multiclass mDashDeprEqWithOpt { + // Option + def "" : Separate<["--"], opt>, HelpText; + def opt_eq : JJ, Alias(realopt)>, + HelpText<"Deprecated alias for --" # opt>; + def opt_dash_eq : Joined<["-"], opt #"=">, Alias(realopt)>, + HelpText<"Deprecated alias for --" # opt # "=">; +} + +// Multiple dash option combined with deprecated single dash option with equals +// only. +multiclass mDashDeprEqOnlyWithOpt { + // Option + def "" : JJ, Alias(realopt)>, HelpText; + + // Deprecated aliases + def opt_dash_eq : Flag<["-"], opt>, Alias(realopt)>, + HelpText<"Deprecated alias for --" # opt>; +} + +multiclass + mDashDeprTwoWithOpt { + // Option + def "" : Separate<["-"], opt1>, HelpText; + def opt1_eq : Joined<["-"], opt1 #"=">, Alias(realopt)>; + def opt1_joined : Joined<["-"], opt1>, Alias(realopt)>; + def opt2_dashdash : Separate<["--"], opt2>, Alias(realopt)>; + def opt2_dashdash_eq : JJ, Alias(realopt)>; + + + // Deprecated aliases + def opt1_dashdash : Separate<["--"], opt1>, Alias(realopt)>, + HelpText<"Deprecated alias for -" # opt1>; + def opt1_dashdash_eq : JJ, Alias(realopt)>, + HelpText<"Deprecated alias for -" # opt2>; + def opt2_dash_eq : Joined<["-"], opt2 #"=">, Alias(realopt)>, + HelpText<"Deprecated alias for -" # opt2 # "=">; +} + +//===----------------------------------------------------------------------===// +/// Compatibility aliases +//===----------------------------------------------------------------------===// + +// Multiple dash option combined with compatible single dash option. +multiclass mDashComp { + // Option + def "" : FF, HelpText; + + // Compatibility aliases + def opt_dash : Flag<["-"], opt>, Alias(opt)>, + HelpText<"Compatibility alias for --" # opt>; +} + +// Multiple dash option combined with compatible single dash option. +multiclass mDashCompWithOpt { + // Option + def "" : FF, HelpText; + + // Compatibility aliases + def opt_dash : Flag<["-"], opt>, Alias(realopt)>, + HelpText<"Compatibility alias for --" # opt>; +} + +// Multiple dash option combined with compatible single dash option with equals. +multiclass mDashCompEq { + // Option + def "" : Separate<["--"], opt>, HelpText; + def opt_eq : JJ, Alias(opt)>, + HelpText<"Compatibility alias for --" # opt>; + def opt_dash_eq : Joined<["-"], opt #"=">, Alias(opt)>, + HelpText<"Compatibility alias for --" # opt # "=">; +} + +// Multiple dash option combined with compatible single dash option with equals. +multiclass mDashCompEqWithOpt { + // Option + def "" : Separate<["--"], opt>, HelpText; + def opt_eq : JJ, Alias(realopt)>, + HelpText<"Compatibility alias for --" # opt>; + def opt_dash_eq : Joined<["-"], opt #"=">, Alias(realopt)>, + HelpText<"Compatibility alias for --" # opt # "=">; +} + +// Multiple dash option combined with deprecated single dash option aliases. +multiclass mDashCompAlias { + // Option + def "" : FF, Alias(realopt)>, HelpText; + + // Compatibility aliases + def opt_dash : Flag<["-"], opt>, Alias(realopt)>, + HelpText<"Compatibility alias for --" # opt>; } // Single and multiple dash options combined @@ -26,8 +216,7 @@ multiclass smDashWithOpt { def opt1_eq : Joined<["-"], opt1 #"=">, Alias(realopt)>; // Compatibility aliases def opt1_dashdash : Separate<["--"], opt1>, Alias(realopt)>; - def opt1_dashdash_eq : Joined<["--"], opt1 #"=">, - Alias(realopt)>; + def opt1_dashdash_eq : JJ, HelpText, Alias(realopt)>; - def opt2_dashdash_eq : Joined<["--"], opt2 #"=">, + def opt2_dashdash_eq : JJ, HelpText; // Compatibility aliases - def opt2_eq : Joined<["--"], opt1 #"=">, Alias(realopt)>; + def opt2_eq : JJ; - def NAME # _eq: Joined<["--"], name # "=">, Alias(NAME)>, + def NAME # _eq: JJ, Alias(realopt)>; } // Support -