Support ld.mold linker.

gcc/ChangeLog:

	* collect2.c (main): Add ld.mold.
	* common.opt: Add -fuse-ld=mold.
	* doc/invoke.texi: Document it.
	* gcc.c (driver_handle_option): Handle -fuse-ld=mold.
	* opts.c (common_handle_option): Likewise.
This commit is contained in:
Martin Liska 2021-12-21 17:43:55 +01:00
parent 52a6b06c26
commit ad964f7eae
5 changed files with 20 additions and 3 deletions

View File

@ -776,6 +776,7 @@ main (int argc, char **argv)
USE_GOLD_LD, USE_GOLD_LD,
USE_BFD_LD, USE_BFD_LD,
USE_LLD_LD, USE_LLD_LD,
USE_MOLD_LD,
USE_LD_MAX USE_LD_MAX
} selected_linker = USE_DEFAULT_LD; } selected_linker = USE_DEFAULT_LD;
static const char *const ld_suffixes[USE_LD_MAX] = static const char *const ld_suffixes[USE_LD_MAX] =
@ -784,7 +785,8 @@ main (int argc, char **argv)
PLUGIN_LD_SUFFIX, PLUGIN_LD_SUFFIX,
"ld.gold", "ld.gold",
"ld.bfd", "ld.bfd",
"ld.lld" "ld.lld",
"ld.mold"
}; };
static const char *const real_ld_suffix = "real-ld"; static const char *const real_ld_suffix = "real-ld";
static const char *const collect_ld_suffix = "collect-ld"; static const char *const collect_ld_suffix = "collect-ld";
@ -957,6 +959,8 @@ main (int argc, char **argv)
selected_linker = USE_GOLD_LD; selected_linker = USE_GOLD_LD;
else if (strcmp (argv[i], "-fuse-ld=lld") == 0) else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
selected_linker = USE_LLD_LD; selected_linker = USE_LLD_LD;
else if (strcmp (argv[i], "-fuse-ld=mold") == 0)
selected_linker = USE_MOLD_LD;
else if (startswith (argv[i], "-o")) else if (startswith (argv[i], "-o"))
{ {
/* Parse the output filename if it's given so that we can make /* Parse the output filename if it's given so that we can make
@ -1048,7 +1052,7 @@ main (int argc, char **argv)
ld_file_name = 0; ld_file_name = 0;
#ifdef DEFAULT_LINKER #ifdef DEFAULT_LINKER
if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD || if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD ||
selected_linker == USE_LLD_LD) selected_linker == USE_LLD_LD || selected_linker == USE_MOLD_LD)
{ {
char *linker_name; char *linker_name;
# ifdef HOST_EXECUTABLE_SUFFIX # ifdef HOST_EXECUTABLE_SUFFIX
@ -1283,7 +1287,7 @@ main (int argc, char **argv)
else if (!use_collect_ld else if (!use_collect_ld
&& startswith (arg, "-fuse-ld=")) && startswith (arg, "-fuse-ld="))
{ {
/* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */ /* Do not pass -fuse-ld={bfd|gold|lld|mold} to the linker. */
ld1--; ld1--;
ld2--; ld2--;
} }

View File

@ -3046,6 +3046,10 @@ fuse-ld=lld
Common Driver Negative(fuse-ld=lld) Common Driver Negative(fuse-ld=lld)
Use the lld LLVM linker instead of the default linker. Use the lld LLVM linker instead of the default linker.
fuse-ld=mold
Common Driver Negative(fuse-ld=mold)
Use the Modern linker (MOLD) linker instead of the default linker.
fuse-linker-plugin fuse-linker-plugin
Common Undocumented Var(flag_use_linker_plugin) Common Undocumented Var(flag_use_linker_plugin)

View File

@ -16266,6 +16266,10 @@ Use the @command{gold} linker instead of the default linker.
@opindex fuse-ld=lld @opindex fuse-ld=lld
Use the LLVM @command{lld} linker instead of the default linker. Use the LLVM @command{lld} linker instead of the default linker.
@item -fuse-ld=mold
@opindex fuse-ld=mold
Use the Modern Linker (@command{mold}) instead of the default linker.
@cindex Libraries @cindex Libraries
@item -l@var{library} @item -l@var{library}
@itemx -l @var{library} @itemx -l @var{library}

View File

@ -4282,6 +4282,10 @@ driver_handle_option (struct gcc_options *opts,
use_ld = ".gold"; use_ld = ".gold";
break; break;
case OPT_fuse_ld_mold:
use_ld = ".mold";
break;
case OPT_fcompare_debug_second: case OPT_fcompare_debug_second:
compare_debug_second = 1; compare_debug_second = 1;
break; break;

View File

@ -3105,6 +3105,7 @@ common_handle_option (struct gcc_options *opts,
case OPT_fuse_ld_bfd: case OPT_fuse_ld_bfd:
case OPT_fuse_ld_gold: case OPT_fuse_ld_gold:
case OPT_fuse_ld_lld: case OPT_fuse_ld_lld:
case OPT_fuse_ld_mold:
case OPT_fuse_linker_plugin: case OPT_fuse_linker_plugin:
/* No-op. Used by the driver and passed to us because it starts with f.*/ /* No-op. Used by the driver and passed to us because it starts with f.*/
break; break;