public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Driver] Add support for -fuse-ld=lld
@ 2018-10-20 12:38 Romain Geissler
  2018-10-27 17:52 ` Romain GEISSLER
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Romain Geissler @ 2018-10-20 12:38 UTC (permalink / raw)
  To: gcc-patches; +Cc: Davide Italiano, H.J. Lu

Hi,

I would like to raise again the question of supporting -fuse-ld=ldd. A
patch implementing it was already submitted in
https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
Italiano. This patch still applies correctly to current trunk. I am CC-ing
the original author and re-posting it here unchanged for reference.

I think we can consider this patch as relevant despite the goals and
licence difference of LLVM vs GNU, based on what was written by Mike Stump
in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html

Back then, the technical problem raised by lld was reported as
https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
reported problems have been fixed except the last one. H.J. Lu mentions
this last problem (lld does not produces symbol versions predecessor
relationship while ld.bfd and ld.gold do, which seems to be a decision
taken on purpose and advertised as a harmless change) as being one reason
against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
if yes, why ?

Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?

Cheers,
Romain

From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
From: Davide Italiano <dccitaliano@gmail.com>
Date: Thu, 23 Jun 2016 20:51:53 -0700
Subject: [PATCH] Driver: Add support for -fuse-ld=lld.

* collect2.c  (main): Support -fuse-ld=lld.

* common.opt: Add fuse-ld=lld

* doc/invoke.texi:  Document -fuse-ld=lld

* opts.c: Ignore -fuse-ld=lld
---
 gcc/collect2.c      | 11 ++++++++---
 gcc/common.opt      |  4 ++++
 gcc/doc/invoke.texi |  4 ++++
 gcc/opts.c          |  1 +
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index bffac80..6a8387c 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -831,6 +831,7 @@ main (int argc, char **argv)
       USE_PLUGIN_LD,
       USE_GOLD_LD,
       USE_BFD_LD,
+      USE_LLD_LD,
       USE_LD_MAX
     } selected_linker = USE_DEFAULT_LD;
   static const char *const ld_suffixes[USE_LD_MAX] =
@@ -838,7 +839,8 @@ main (int argc, char **argv)
       "ld",
       PLUGIN_LD_SUFFIX,
       "ld.gold",
-      "ld.bfd"
+      "ld.bfd",
+      "ld.lld"
     };
   static const char *const real_ld_suffix = "real-ld";
   static const char *const collect_ld_suffix = "collect-ld";
@@ -1004,6 +1006,8 @@ main (int argc, char **argv)
 	  selected_linker = USE_BFD_LD;
 	else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
 	  selected_linker = USE_GOLD_LD;
+  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
+    selected_linker = USE_LLD_LD;

 #ifdef COLLECT_EXPORT_LIST
 	/* These flags are position independent, although their order
@@ -1093,7 +1097,8 @@ main (int argc, char **argv)
   /* Maybe we know the right file to use (if not cross).  */
   ld_file_name = 0;
 #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)
     {
       char *linker_name;
 # ifdef HOST_EXECUTABLE_SUFFIX
@@ -1307,7 +1312,7 @@ main (int argc, char **argv)
 	      else if (!use_collect_ld
 		       && strncmp (arg, "-fuse-ld=", 9) == 0)
 		{
-		  /* Do not pass -fuse-ld={bfd|gold} to the linker. */
+		  /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
 		  ld1--;
 		  ld2--;
 		}
diff --git a/gcc/common.opt b/gcc/common.opt
index 5d90385..2a95a1f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2536,6 +2536,10 @@ fuse-ld=gold
 Common Driver Negative(fuse-ld=bfd)
 Use the gold linker instead of the default linker.

+fuse-ld=lld
+Common Driver Negative(fuse-ld=lld)
+Use the lld LLVM linker instead of the default linker.
+
 fuse-linker-plugin
 Common Undocumented Var(flag_use_linker_plugin)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2c87c53..4b8acff 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the default linker.
 @opindex fuse-ld=gold
 Use the @command{gold} linker instead of the default linker.

+@item -fuse-ld=lld
+@opindex fuse-ld=lld
+Use the LLVM @command{lld} linker instead of the default linker.
+
 @cindex Libraries
 @item -l@var{library}
 @itemx -l @var{library}
diff --git a/gcc/opts.c b/gcc/opts.c
index 7406210..f2c86f7 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,

     case OPT_fuse_ld_bfd:
     case OPT_fuse_ld_gold:
+    case OPT_fuse_ld_lld:
     case OPT_fuse_linker_plugin:
       /* No-op. Used by the driver and passed to us because it starts with f.*/
       break;

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2018-10-20 12:38 [Driver] Add support for -fuse-ld=lld Romain Geissler
@ 2018-10-27 17:52 ` Romain GEISSLER
  2018-11-06 16:14   ` Romain GEISSLER
  2018-11-06 16:23 ` H.J. Lu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 27+ messages in thread
From: Romain GEISSLER @ 2018-10-27 17:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Davide Italiano, H.J. Lu

Ping

> Le 20 oct. 2018 à 12:18, Romain Geissler <romain.geissler@amadeus.com> a écrit :
> 
> Hi,
> 
> I would like to raise again the question of supporting -fuse-ld=ldd. A
> patch implementing it was already submitted in
> https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
> Italiano. This patch still applies correctly to current trunk. I am CC-ing
> the original author and re-posting it here unchanged for reference.
> 
> I think we can consider this patch as relevant despite the goals and
> licence difference of LLVM vs GNU, based on what was written by Mike Stump
> in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html
> 
> Back then, the technical problem raised by lld was reported as
> https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
> reported problems have been fixed except the last one. H.J. Lu mentions
> this last problem (lld does not produces symbol versions predecessor
> relationship while ld.bfd and ld.gold do, which seems to be a decision
> taken on purpose and advertised as a harmless change) as being one reason
> against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
> if yes, why ?
> 
> Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?
> 
> Cheers,
> Romain
> 
> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
> From: Davide Italiano <dccitaliano@gmail.com>
> Date: Thu, 23 Jun 2016 20:51:53 -0700
> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
> 
> * collect2.c  (main): Support -fuse-ld=lld.
> 
> * common.opt: Add fuse-ld=lld
> 
> * doc/invoke.texi:  Document -fuse-ld=lld
> 
> * opts.c: Ignore -fuse-ld=lld
> ---
> gcc/collect2.c      | 11 ++++++++---
> gcc/common.opt      |  4 ++++
> gcc/doc/invoke.texi |  4 ++++
> gcc/opts.c          |  1 +
> 4 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/collect2.c b/gcc/collect2.c
> index bffac80..6a8387c 100644
> --- a/gcc/collect2.c
> +++ b/gcc/collect2.c
> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>       USE_PLUGIN_LD,
>       USE_GOLD_LD,
>       USE_BFD_LD,
> +      USE_LLD_LD,
>       USE_LD_MAX
>     } selected_linker = USE_DEFAULT_LD;
>   static const char *const ld_suffixes[USE_LD_MAX] =
> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>       "ld",
>       PLUGIN_LD_SUFFIX,
>       "ld.gold",
> -      "ld.bfd"
> +      "ld.bfd",
> +      "ld.lld"
>     };
>   static const char *const real_ld_suffix = "real-ld";
>   static const char *const collect_ld_suffix = "collect-ld";
> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
> 	  selected_linker = USE_BFD_LD;
> 	else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
> 	  selected_linker = USE_GOLD_LD;
> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
> +    selected_linker = USE_LLD_LD;
> 
> #ifdef COLLECT_EXPORT_LIST
> 	/* These flags are position independent, although their order
> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>   /* Maybe we know the right file to use (if not cross).  */
>   ld_file_name = 0;
> #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)
>     {
>       char *linker_name;
> # ifdef HOST_EXECUTABLE_SUFFIX
> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
> 	      else if (!use_collect_ld
> 		       && strncmp (arg, "-fuse-ld=", 9) == 0)
> 		{
> -		  /* Do not pass -fuse-ld={bfd|gold} to the linker. */
> +		  /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
> 		  ld1--;
> 		  ld2--;
> 		}
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 5d90385..2a95a1f 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -2536,6 +2536,10 @@ fuse-ld=gold
> Common Driver Negative(fuse-ld=bfd)
> Use the gold linker instead of the default linker.
> 
> +fuse-ld=lld
> +Common Driver Negative(fuse-ld=lld)
> +Use the lld LLVM linker instead of the default linker.
> +
> fuse-linker-plugin
> Common Undocumented Var(flag_use_linker_plugin)
> 
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 2c87c53..4b8acff 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the default linker.
> @opindex fuse-ld=gold
> Use the @command{gold} linker instead of the default linker.
> 
> +@item -fuse-ld=lld
> +@opindex fuse-ld=lld
> +Use the LLVM @command{lld} linker instead of the default linker.
> +
> @cindex Libraries
> @item -l@var{library}
> @itemx -l @var{library}
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 7406210..f2c86f7 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
> 
>     case OPT_fuse_ld_bfd:
>     case OPT_fuse_ld_gold:
> +    case OPT_fuse_ld_lld:
>     case OPT_fuse_linker_plugin:
>       /* No-op. Used by the driver and passed to us because it starts with f.*/
>       break;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2018-10-27 17:52 ` Romain GEISSLER
@ 2018-11-06 16:14   ` Romain GEISSLER
  0 siblings, 0 replies; 27+ messages in thread
From: Romain GEISSLER @ 2018-11-06 16:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: Davide Italiano, H.J. Lu

Ping^2

> Le 27 oct. 2018 à 11:33, Romain GEISSLER <romain.geissler@amadeus.com> a écrit :
> 
> Ping
> 
>> Le 20 oct. 2018 à 12:18, Romain Geissler <romain.geissler@amadeus.com> a écrit :
>> 
>> Hi,
>> 
>> I would like to raise again the question of supporting -fuse-ld=ldd. A
>> patch implementing it was already submitted in
>> https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
>> Italiano. This patch still applies correctly to current trunk. I am CC-ing
>> the original author and re-posting it here unchanged for reference.
>> 
>> I think we can consider this patch as relevant despite the goals and
>> licence difference of LLVM vs GNU, based on what was written by Mike Stump
>> in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html
>> 
>> Back then, the technical problem raised by lld was reported as
>> https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
>> reported problems have been fixed except the last one. H.J. Lu mentions
>> this last problem (lld does not produces symbol versions predecessor
>> relationship while ld.bfd and ld.gold do, which seems to be a decision
>> taken on purpose and advertised as a harmless change) as being one reason
>> against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
>> if yes, why ?
>> 
>> Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?
>> 
>> Cheers,
>> Romain
>> 
>> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
>> From: Davide Italiano <dccitaliano@gmail.com>
>> Date: Thu, 23 Jun 2016 20:51:53 -0700
>> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>> 
>> * collect2.c  (main): Support -fuse-ld=lld.
>> 
>> * common.opt: Add fuse-ld=lld
>> 
>> * doc/invoke.texi:  Document -fuse-ld=lld
>> 
>> * opts.c: Ignore -fuse-ld=lld
>> ---
>> gcc/collect2.c      | 11 ++++++++---
>> gcc/common.opt      |  4 ++++
>> gcc/doc/invoke.texi |  4 ++++
>> gcc/opts.c          |  1 +
>> 4 files changed, 17 insertions(+), 3 deletions(-)
>> 
>> diff --git a/gcc/collect2.c b/gcc/collect2.c
>> index bffac80..6a8387c 100644
>> --- a/gcc/collect2.c
>> +++ b/gcc/collect2.c
>> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>>      USE_PLUGIN_LD,
>>      USE_GOLD_LD,
>>      USE_BFD_LD,
>> +      USE_LLD_LD,
>>      USE_LD_MAX
>>    } selected_linker = USE_DEFAULT_LD;
>>  static const char *const ld_suffixes[USE_LD_MAX] =
>> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>>      "ld",
>>      PLUGIN_LD_SUFFIX,
>>      "ld.gold",
>> -      "ld.bfd"
>> +      "ld.bfd",
>> +      "ld.lld"
>>    };
>>  static const char *const real_ld_suffix = "real-ld";
>>  static const char *const collect_ld_suffix = "collect-ld";
>> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>> 	  selected_linker = USE_BFD_LD;
>> 	else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>> 	  selected_linker = USE_GOLD_LD;
>> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
>> +    selected_linker = USE_LLD_LD;
>> 
>> #ifdef COLLECT_EXPORT_LIST
>> 	/* These flags are position independent, although their order
>> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>>  /* Maybe we know the right file to use (if not cross).  */
>>  ld_file_name = 0;
>> #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)
>>    {
>>      char *linker_name;
>> # ifdef HOST_EXECUTABLE_SUFFIX
>> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>> 	      else if (!use_collect_ld
>> 		       && strncmp (arg, "-fuse-ld=", 9) == 0)
>> 		{
>> -		  /* Do not pass -fuse-ld={bfd|gold} to the linker. */
>> +		  /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>> 		  ld1--;
>> 		  ld2--;
>> 		}
>> diff --git a/gcc/common.opt b/gcc/common.opt
>> index 5d90385..2a95a1f 100644
>> --- a/gcc/common.opt
>> +++ b/gcc/common.opt
>> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>> Common Driver Negative(fuse-ld=bfd)
>> Use the gold linker instead of the default linker.
>> 
>> +fuse-ld=lld
>> +Common Driver Negative(fuse-ld=lld)
>> +Use the lld LLVM linker instead of the default linker.
>> +
>> fuse-linker-plugin
>> Common Undocumented Var(flag_use_linker_plugin)
>> 
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index 2c87c53..4b8acff 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the default linker.
>> @opindex fuse-ld=gold
>> Use the @command{gold} linker instead of the default linker.
>> 
>> +@item -fuse-ld=lld
>> +@opindex fuse-ld=lld
>> +Use the LLVM @command{lld} linker instead of the default linker.
>> +
>> @cindex Libraries
>> @item -l@var{library}
>> @itemx -l @var{library}
>> diff --git a/gcc/opts.c b/gcc/opts.c
>> index 7406210..f2c86f7 100644
>> --- a/gcc/opts.c
>> +++ b/gcc/opts.c
>> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>> 
>>    case OPT_fuse_ld_bfd:
>>    case OPT_fuse_ld_gold:
>> +    case OPT_fuse_ld_lld:
>>    case OPT_fuse_linker_plugin:
>>      /* No-op. Used by the driver and passed to us because it starts with f.*/
>>      break;
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2018-10-20 12:38 [Driver] Add support for -fuse-ld=lld Romain Geissler
  2018-10-27 17:52 ` Romain GEISSLER
@ 2018-11-06 16:23 ` H.J. Lu
  2018-11-08 11:00   ` [EXT] " Romain Geissler
  2018-11-08 22:04 ` Jeff Law
  2019-01-25 15:06 ` Jonathan Wakely
  3 siblings, 1 reply; 27+ messages in thread
From: H.J. Lu @ 2018-11-06 16:23 UTC (permalink / raw)
  To: Romain Geissler; +Cc: GCC Patches, Davide Italiano

On Sat, Oct 20, 2018 at 3:19 AM Romain Geissler
<romain.geissler@amadeus.com> wrote:
>
> Hi,
>
> I would like to raise again the question of supporting -fuse-ld=ldd. A
> patch implementing it was already submitted in
> https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
> Italiano. This patch still applies correctly to current trunk. I am CC-ing
> the original author and re-posting it here unchanged for reference.
>
> I think we can consider this patch as relevant despite the goals and
> licence difference of LLVM vs GNU, based on what was written by Mike Stump
> in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html
>
> Back then, the technical problem raised by lld was reported as
> https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
> reported problems have been fixed except the last one. H.J. Lu mentions
> this last problem (lld does not produces symbol versions predecessor
> relationship while ld.bfd and ld.gold do, which seems to be a decision
> taken on purpose and advertised as a harmless change) as being one reason
> against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
> if yes, why ?
>
> Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?
>
> Cheers,
> Romain
>
> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
> From: Davide Italiano <dccitaliano@gmail.com>
> Date: Thu, 23 Jun 2016 20:51:53 -0700
> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>
> * collect2.c  (main): Support -fuse-ld=lld.
>
> * common.opt: Add fuse-ld=lld
>
> * doc/invoke.texi:  Document -fuse-ld=lld
>
> * opts.c: Ignore -fuse-ld=lld
> ---
>  gcc/collect2.c      | 11 ++++++++---
>  gcc/common.opt      |  4 ++++
>  gcc/doc/invoke.texi |  4 ++++
>  gcc/opts.c          |  1 +
>  4 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/collect2.c b/gcc/collect2.c
> index bffac80..6a8387c 100644
> --- a/gcc/collect2.c
> +++ b/gcc/collect2.c
> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>        USE_PLUGIN_LD,
>        USE_GOLD_LD,
>        USE_BFD_LD,
> +      USE_LLD_LD,
>        USE_LD_MAX
>      } selected_linker = USE_DEFAULT_LD;
>    static const char *const ld_suffixes[USE_LD_MAX] =
> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>        "ld",
>        PLUGIN_LD_SUFFIX,
>        "ld.gold",
> -      "ld.bfd"
> +      "ld.bfd",
> +      "ld.lld"
>      };
>    static const char *const real_ld_suffix = "real-ld";
>    static const char *const collect_ld_suffix = "collect-ld";
> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>           selected_linker = USE_BFD_LD;
>         else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>           selected_linker = USE_GOLD_LD;
> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
> +    selected_linker = USE_LLD_LD;
>
>  #ifdef COLLECT_EXPORT_LIST
>         /* These flags are position independent, although their order
> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>    /* Maybe we know the right file to use (if not cross).  */
>    ld_file_name = 0;
>  #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)
>      {
>        char *linker_name;
>  # ifdef HOST_EXECUTABLE_SUFFIX
> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>               else if (!use_collect_ld
>                        && strncmp (arg, "-fuse-ld=", 9) == 0)
>                 {
> -                 /* Do not pass -fuse-ld={bfd|gold} to the linker. */
> +                 /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>                   ld1--;
>                   ld2--;
>                 }
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 5d90385..2a95a1f 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>  Common Driver Negative(fuse-ld=bfd)
>  Use the gold linker instead of the default linker.
>
> +fuse-ld=lld
> +Common Driver Negative(fuse-ld=lld)
> +Use the lld LLVM linker instead of the default linker.
> +
>  fuse-linker-plugin
>  Common Undocumented Var(flag_use_linker_plugin)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 2c87c53..4b8acff 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the default linker.
>  @opindex fuse-ld=gold
>  Use the @command{gold} linker instead of the default linker.
>
> +@item -fuse-ld=lld
> +@opindex fuse-ld=lld
> +Use the LLVM @command{lld} linker instead of the default linker.
> +
>  @cindex Libraries
>  @item -l@var{library}
>  @itemx -l @var{library}
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 7406210..f2c86f7 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>
>      case OPT_fuse_ld_bfd:
>      case OPT_fuse_ld_gold:
> +    case OPT_fuse_ld_lld:
>      case OPT_fuse_linker_plugin:
>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>        break;

LGTM.  But I can't approve it.

-- 
H.J.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2018-11-06 16:23 ` H.J. Lu
@ 2018-11-08 11:00   ` Romain Geissler
  2018-11-08 11:51     ` Richard Biener
  0 siblings, 1 reply; 27+ messages in thread
From: Romain Geissler @ 2018-11-08 11:00 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Romain Geissler, GCC Patches, Davide Italiano

On Tue, 6 Nov 2018, H.J. Lu wrote:

> On Sat, Oct 20, 2018 at 3:19 AM Romain Geissler
> <romain.geissler@amadeus.com> wrote:
> >
> > I would like to raise again the question of supporting -fuse-ld=lld.
> >
>
> LGTM.  But I can't approve it.
>
> --
> H.J.

Hi,

Is there any gcc reviewer that could comment whether or not this small
feature is welcome in gcc ?

Cheers,
Romain

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2018-11-08 11:00   ` [EXT] " Romain Geissler
@ 2018-11-08 11:51     ` Richard Biener
  2018-11-08 21:46       ` Romain Geissler
  0 siblings, 1 reply; 27+ messages in thread
From: Richard Biener @ 2018-11-08 11:51 UTC (permalink / raw)
  To: romain.geissler; +Cc: H. J. Lu, GCC Patches, dccitaliano

On Thu, Nov 8, 2018 at 12:00 PM Romain Geissler
<romain.geissler@amadeus.com> wrote:
>
> On Tue, 6 Nov 2018, H.J. Lu wrote:
>
> > On Sat, Oct 20, 2018 at 3:19 AM Romain Geissler
> > <romain.geissler@amadeus.com> wrote:
> > >
> > > I would like to raise again the question of supporting -fuse-ld=lld.
> > >
> >
> > LGTM.  But I can't approve it.
> >
> > --
> > H.J.
>
> Hi,
>
> Is there any gcc reviewer that could comment whether or not this small
> feature is welcome in gcc ?

The patch is OK.

Thanks,
Richard.

> Cheers,
> Romain

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2018-11-08 11:51     ` Richard Biener
@ 2018-11-08 21:46       ` Romain Geissler
  0 siblings, 0 replies; 27+ messages in thread
From: Romain Geissler @ 2018-11-08 21:46 UTC (permalink / raw)
  To: Richard Biener; +Cc: romain.geissler, H. J. Lu, GCC Patches, dccitaliano

On Thu, 8 Nov 2018, Richard Biener wrote:

>
> The patch is OK.
>
> Thanks,
> Richard.
>

Thanks. Can you please apply it as I don't have any commit rights ?
The patch can be found in
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01240.html

Here is a valid gcc/ChangeLog correctly formated where I am referrencing
the original author of the patch (not me).

Cheers,
Romain

2018-11-08  Davide Italiano  <dccitaliano@gmail.com>

 	* collect2.c (main): Support -fuse-ld=lld.
 	* common.opt: Add fuse-ld=lld
 	* doc/invoke.texi:  Document -fuse-ld=lld
 	* opts.c: Ignore -fuse-ld=lld

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2018-10-20 12:38 [Driver] Add support for -fuse-ld=lld Romain Geissler
  2018-10-27 17:52 ` Romain GEISSLER
  2018-11-06 16:23 ` H.J. Lu
@ 2018-11-08 22:04 ` Jeff Law
  2019-01-25 15:06 ` Jonathan Wakely
  3 siblings, 0 replies; 27+ messages in thread
From: Jeff Law @ 2018-11-08 22:04 UTC (permalink / raw)
  To: Romain Geissler, gcc-patches; +Cc: Davide Italiano, H.J. Lu

On 10/20/18 4:18 AM, Romain Geissler wrote:
> Hi,
> 
> I would like to raise again the question of supporting -fuse-ld=ldd. A
> patch implementing it was already submitted in
> https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
> Italiano. This patch still applies correctly to current trunk. I am CC-ing
> the original author and re-posting it here unchanged for reference.
> 
> I think we can consider this patch as relevant despite the goals and
> licence difference of LLVM vs GNU, based on what was written by Mike Stump
> in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html
> 
> Back then, the technical problem raised by lld was reported as
> https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
> reported problems have been fixed except the last one. H.J. Lu mentions
> this last problem (lld does not produces symbol versions predecessor
> relationship while ld.bfd and ld.gold do, which seems to be a decision
> taken on purpose and advertised as a harmless change) as being one reason
> against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
> if yes, why ?
> 
> Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?
> 
> Cheers,
> Romain
> 
> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
> From: Davide Italiano <dccitaliano@gmail.com>
> Date: Thu, 23 Jun 2016 20:51:53 -0700
> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
> 
> * collect2.c  (main): Support -fuse-ld=lld.
> 
> * common.opt: Add fuse-ld=lld
> 
> * doc/invoke.texi:  Document -fuse-ld=lld
> 
> * opts.c: Ignore -fuse-ld=lld
THanks.  Installed.

JEff

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2018-10-20 12:38 [Driver] Add support for -fuse-ld=lld Romain Geissler
                   ` (2 preceding siblings ...)
  2018-11-08 22:04 ` Jeff Law
@ 2019-01-25 15:06 ` Jonathan Wakely
  2019-01-29 19:07   ` Marek Polacek
  2019-02-04 12:08   ` Romain Geissler
  3 siblings, 2 replies; 27+ messages in thread
From: Jonathan Wakely @ 2019-01-25 15:06 UTC (permalink / raw)
  To: Romain Geissler; +Cc: gcc-patches, Davide Italiano, H.J. Lu, Jeff Law

On 20/10/18 12:18 +0200, Romain Geissler wrote:
>Hi,
>
>I would like to raise again the question of supporting -fuse-ld=ldd. A
>patch implementing it was already submitted in
>https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
>Italiano. This patch still applies correctly to current trunk. I am CC-ing
>the original author and re-posting it here unchanged for reference.
>
>I think we can consider this patch as relevant despite the goals and
>licence difference of LLVM vs GNU, based on what was written by Mike Stump
>in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html
>
>Back then, the technical problem raised by lld was reported as
>https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
>reported problems have been fixed except the last one. H.J. Lu mentions
>this last problem (lld does not produces symbol versions predecessor
>relationship while ld.bfd and ld.gold do, which seems to be a decision
>taken on purpose and advertised as a harmless change) as being one reason
>against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
>if yes, why ?
>
>Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?

This patch was committed to trunk (r265940), but HJ's review comments
were never addressed (and look correct to me):
https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00146.html

The multi-line condition should be split before the || operator not
after it, and the negation of -fuse-ld=lld is not -fuse-ld-lld.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2019-01-25 15:06 ` Jonathan Wakely
@ 2019-01-29 19:07   ` Marek Polacek
  2019-01-29 19:12     ` [EXT] " Romain GEISSLER
  2019-02-04 12:08   ` Romain Geissler
  1 sibling, 1 reply; 27+ messages in thread
From: Marek Polacek @ 2019-01-29 19:07 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Romain Geissler, gcc-patches, Davide Italiano, H.J. Lu, Jeff Law

On Fri, Jan 25, 2019 at 03:06:41PM +0000, Jonathan Wakely wrote:
> On 20/10/18 12:18 +0200, Romain Geissler wrote:
> > Hi,
> > 
> > I would like to raise again the question of supporting -fuse-ld=ldd. A
> > patch implementing it was already submitted in
> > https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01722.html by Davide
> > Italiano. This patch still applies correctly to current trunk. I am CC-ing
> > the original author and re-posting it here unchanged for reference.
> > 
> > I think we can consider this patch as relevant despite the goals and
> > licence difference of LLVM vs GNU, based on what was written by Mike Stump
> > in https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00157.html
> > 
> > Back then, the technical problem raised by lld was reported as
> > https://bugs.llvm.org/show_bug.cgi?id=28414 now closed. In this bug, every
> > reported problems have been fixed except the last one. H.J. Lu mentions
> > this last problem (lld does not produces symbol versions predecessor
> > relationship while ld.bfd and ld.gold do, which seems to be a decision
> > taken on purpose and advertised as a harmless change) as being one reason
> > against supporting in -fuse-ld=ldd in gcc. Is it still the case today, and
> > if yes, why ?
> > 
> > Is there any other reason why -fuse-ld=ldd shall not be supported by gcc ?
> 
> This patch was committed to trunk (r265940), but HJ's review comments
> were never addressed (and look correct to me):
> https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00146.html
> 
> The multi-line condition should be split before the || operator not
> after it, and the negation of -fuse-ld=lld is not -fuse-ld-lld.

Indeed.  Romain, are you going to submit a followup patch to address this?

Marek

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2019-01-29 19:07   ` Marek Polacek
@ 2019-01-29 19:12     ` Romain GEISSLER
  2019-01-29 19:18       ` Marek Polacek
  0 siblings, 1 reply; 27+ messages in thread
From: Romain GEISSLER @ 2019-01-29 19:12 UTC (permalink / raw)
  To: Marek Polacek
  Cc: Jonathan Wakely, gcc-patches, Davide Italiano, H.J. Lu, Jeff Law

> Le 29 janv. 2019 à 20:03, Marek Polacek <polacek@redhat.com> a écrit :
> 
> On Fri, Jan 25, 2019 at 03:06:41PM +0000, Jonathan Wakely wrote:
> 
> Indeed.  Romain, are you going to submit a followup patch to address this?
> 
> Marek

Hi,

I submitted the original patch because it was not written by me but by Davide, and I thought that modifying myself would require me to sign a FSF copyright assignment (which is Ok for me, but my employer needs to sign too and right now it is not done).

So if the followup patch can be committed without assignment, I can do it right now. If not, I will need to get my company legal team to figure out the assignment and it can take weeks. Do you think it would be obvious enough not to require an assignment ?

Cheers,
Romain

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2019-01-29 19:12     ` [EXT] " Romain GEISSLER
@ 2019-01-29 19:18       ` Marek Polacek
  2019-01-29 20:20         ` Jonathan Wakely
  0 siblings, 1 reply; 27+ messages in thread
From: Marek Polacek @ 2019-01-29 19:18 UTC (permalink / raw)
  To: Romain GEISSLER
  Cc: Jonathan Wakely, gcc-patches, Davide Italiano, H.J. Lu, Jeff Law

On Tue, Jan 29, 2019 at 07:07:31PM +0000, Romain GEISSLER wrote:
> > Le 29 janv. 2019 à 20:03, Marek Polacek <polacek@redhat.com> a écrit :
> > 
> > On Fri, Jan 25, 2019 at 03:06:41PM +0000, Jonathan Wakely wrote:
> > 
> > Indeed.  Romain, are you going to submit a followup patch to address this?
> > 
> > Marek
> 
> Hi,
> 
> I submitted the original patch because it was not written by me but by Davide, and I thought that modifying myself would require me to sign a FSF copyright assignment (which is Ok for me, but my employer needs to sign too and right now it is not done).
> 
> So if the followup patch can be committed without assignment, I can do it right now. If not, I will need to get my company legal team to figure out the assignment and it can take weeks. Do you think it would be obvious enough not to require an assignment ?

Thanks for the quick response.

I believe a formatting fix and a trivial 1- or 2-line change can be
committed without that assignment.

Marek

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2019-01-29 19:18       ` Marek Polacek
@ 2019-01-29 20:20         ` Jonathan Wakely
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Wakely @ 2019-01-29 20:20 UTC (permalink / raw)
  To: Marek Polacek
  Cc: Romain GEISSLER, gcc-patches, Davide Italiano, H.J. Lu, Jeff Law

On 29/01/19 14:12 -0500, Marek Polacek wrote:
>On Tue, Jan 29, 2019 at 07:07:31PM +0000, Romain GEISSLER wrote:
>> > Le 29 janv. 2019 à 20:03, Marek Polacek <polacek@redhat.com> a écrit :
>> >
>> > On Fri, Jan 25, 2019 at 03:06:41PM +0000, Jonathan Wakely wrote:
>> >
>> > Indeed.  Romain, are you going to submit a followup patch to address this?
>> >
>> > Marek
>>
>> Hi,
>>
>> I submitted the original patch because it was not written by me but by Davide, and I thought that modifying myself would require me to sign a FSF copyright assignment (which is Ok for me, but my employer needs to sign too and right now it is not done).
>>
>> So if the followup patch can be committed without assignment, I can do it right now. If not, I will need to get my company legal team to figure out the assignment and it can take weeks. Do you think it would be obvious enough not to require an assignment ?
>
>Thanks for the quick response.
>
>I believe a formatting fix and a trivial 1- or 2-line change can be
>committed without that assignment.

Agreed.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [EXT] Re: [Driver] Add support for -fuse-ld=lld
  2019-01-25 15:06 ` Jonathan Wakely
  2019-01-29 19:07   ` Marek Polacek
@ 2019-02-04 12:08   ` Romain Geissler
  1 sibling, 0 replies; 27+ messages in thread
From: Romain Geissler @ 2019-02-04 12:08 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Romain Geissler, gcc-patches, Davide Italiano, H.J. Lu, Jeff Law

On Fri, 25 Jan 2019, Jonathan Wakely wrote:

> This patch was committed to trunk (r265940), but HJ's review comments
> were never addressed (and look correct to me):
> https://clicktime.symantec.com/3QJw9yc7Scra74WXzR3yBDR6H2?u=https%3A%2F%2Fgcc.gnu.org%2Fml%2Fgcc-patches%2F2016-07%2Fmsg00146.html
>
> The multi-line condition should be split before the || operator not
> after it, and the negation of -fuse-ld=lld is not -fuse-ld-lld.

Hi,

This small cosmetic patch should address it. I don't know how much spaces
should be used to indent the second and third lines in the if condition,
this of course can be changed if it doesn't follow the gcc guidelines.

Cheers,
Romain

2019-02-04  Romain Geissler  <romain.geissler@amadeus.com>

	* collect2.c (main): Use one condition per line when checking for
	selected_linker.
	* common.opt (-fuse-ld=gold, -fuse-ld=lld): Adjust negative driver option.


From ff9489bad0eda7b1a551ba454300022def0c8c77 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@amadeus.com>
Date: Mon, 4 Feb 2019 11:49:41 +0000
Subject: [PATCH] Cosmetic changes for -fuse-ld=lld patch.

---
 gcc/collect2.c | 5 +++--
 gcc/common.opt | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index da956bfd984..96e449962e9 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -1127,8 +1127,9 @@ main (int argc, char **argv)
   /* Maybe we know the right file to use (if not cross).  */
   ld_file_name = 0;
 #ifdef DEFAULT_LINKER
-  if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD ||
-      selected_linker == USE_LLD_LD)
+  if (selected_linker == USE_BFD_LD
+      || selected_linker == USE_GOLD_LD
+      || selected_linker == USE_LLD_LD)
     {
       char *linker_name;
 # ifdef HOST_EXECUTABLE_SUFFIX
diff --git a/gcc/common.opt b/gcc/common.opt
index 295cb1f55e1..03d8bc36260 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2792,11 +2792,11 @@ Common Driver Negative(fuse-ld=gold)
 Use the bfd linker instead of the default linker.

 fuse-ld=gold
-Common Driver Negative(fuse-ld=bfd)
+Common Driver Negative(fuse-ld=lld)
 Use the gold linker instead of the default linker.

 fuse-ld=lld
-Common Driver Negative(fuse-ld=lld)
+Common Driver Negative(fuse-ld=bfd)
 Use the lld LLVM linker instead of the default linker.

 fuse-linker-plugin
-- 
2.17.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2019-01-26 22:37 ` Segher Boessenkool
@ 2019-01-29  1:49   ` Alan Modra
  0 siblings, 0 replies; 27+ messages in thread
From: Alan Modra @ 2019-01-29  1:49 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Davide Italiano, gcc-patches

On Sat, Jan 26, 2019 at 04:34:59PM -0600, Segher Boessenkool wrote:
> On Thu, Jun 23, 2016 at 09:01:30PM -0700, Davide Italiano wrote:
> > LLVM currently ships with a new ELF linker http://lld.llvm.org/.
> > I experiment a lot with gcc and lld so it would be nice if
> > -fuse-ld=lld is supported (considering the linker is now mature enough
> > to link large C/C++ applications).
> > 
> > Also, IMHO, -fuse-ld should be a generic facility which accept other
> > linkers (as long as they follow the convention ld.<arg>), and should
> > also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
> > Probably outside of the scope of this patch, but I thought worth
> > mentioning.
> 
> This can never work correctly.
> 
> The many HAVE_LD_* flags are set for the linker you are configured
> against.  Now normally GNU ld and Gold will be built from the same tree,
> so they will be at least mostly compatible.  But for some other linker
> that cannot ever work.  If you can choose a random linker at runtime then
> the linker features the compiler is built for will almost certainly not
> match those that linker has.
> 
> You can built with --with-ld=/some/path/to/your/lld, and *that* should
> work fine.  But -fuse-ld=/smth/random will result in randomness.

Yes, and please do note (distros!!) that --with-ld will result in -B
also not being able to specify a linker.  That's a pain if you want to
run the binutils ld testsuite.  You'll get something like:

ERROR: ************************************************************************
ERROR: Your compiler driver ignores -B when choosing ld.
ERROR: You will not be testing the new ld in many of the following tests.
ERROR: It seems you will be testing /usr/bin/x86_64-w64-mingw32-ld instead.
ERROR: ************************************************************************

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-06-24  4:11 Davide Italiano
  2016-06-24  6:53 ` Davide Italiano
  2016-07-04 17:14 ` H.J. Lu
@ 2019-01-26 22:37 ` Segher Boessenkool
  2019-01-29  1:49   ` Alan Modra
  2 siblings, 1 reply; 27+ messages in thread
From: Segher Boessenkool @ 2019-01-26 22:37 UTC (permalink / raw)
  To: Davide Italiano; +Cc: gcc-patches

On Thu, Jun 23, 2016 at 09:01:30PM -0700, Davide Italiano wrote:
> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
> I experiment a lot with gcc and lld so it would be nice if
> -fuse-ld=lld is supported (considering the linker is now mature enough
> to link large C/C++ applications).
> 
> Also, IMHO, -fuse-ld should be a generic facility which accept other
> linkers (as long as they follow the convention ld.<arg>), and should
> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
> Probably outside of the scope of this patch, but I thought worth
> mentioning.

This can never work correctly.

The many HAVE_LD_* flags are set for the linker you are configured
against.  Now normally GNU ld and Gold will be built from the same tree,
so they will be at least mostly compatible.  But for some other linker
that cannot ever work.  If you can choose a random linker at runtime then
the linker features the compiler is built for will almost certainly not
match those that linker has.

You can built with --with-ld=/some/path/to/your/lld, and *that* should
work fine.  But -fuse-ld=/smth/random will result in randomness.


Segher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04 19:37       ` Markus Trippelsdorf
  2016-07-04 19:44         ` Davide Italiano
  2016-07-04 19:58         ` Mike Stump
@ 2016-07-07  0:52         ` Trevor Saunders
  2 siblings, 0 replies; 27+ messages in thread
From: Trevor Saunders @ 2016-07-07  0:52 UTC (permalink / raw)
  To: Markus Trippelsdorf; +Cc: H.J. Lu, Davide Italiano, GCC Patches

On Mon, Jul 04, 2016 at 09:36:52PM +0200, Markus Trippelsdorf wrote:
> On 2016.07.04 at 10:08 -0700, H.J. Lu wrote:
> > On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> > > On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> > >> + HJ who wrote the code for the option originally.
> > >>
> > >> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> > >>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
> > >>> I experiment a lot with gcc and lld so it would be nice if
> > >>> -fuse-ld=lld is supported (considering the linker is now mature enough
> > >>> to link large C/C++ applications).
> > >>>
> > >>> Also, IMHO, -fuse-ld should be a generic facility which accept other
> > >>> linkers (as long as they follow the convention ld.<arg>), and should
> > >>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
> > >>> Probably outside of the scope of this patch, but I thought worth
> > >>> mentioning.
> > >
> > > Hi, can anybody take a look?
> > 
> > lld isn't compatible with GCC:
> > 
> > https://llvm.org/bugs/show_bug.cgi?id=28414
> 
> Besides the technical issues, this also raises the question if it is
> right to support lld at all. Because this project was obviously started
> to replace the GNU linkers (ld.bfd and gold) in the long run.

Technically it seems like it would be useful to support
-fuse-ld=<something that can be execed> so you can say easily test gcc
with a ld.bfd you just built.

> So I see no reason why it should be supported in GCC.
> 
> (And who needs a buggy new ELF linker anyway?)

I'm not particularly thrilled by a new linker, but presumably the bugs
will get fixed, and it does link libxul.so and presumably other things
but I don't have data, and that is certainly useful.

Trev

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04 16:12     ` H.J. Lu
@ 2016-07-04 19:58       ` Davide Italiano
  0 siblings, 0 replies; 27+ messages in thread
From: Davide Italiano @ 2016-07-04 19:58 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GCC Patches

On Mon, Jul 4, 2016 at 9:12 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>> + HJ who wrote the code for the option originally.
>>>
>>> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
>>>> I experiment a lot with gcc and lld so it would be nice if
>>>> -fuse-ld=lld is supported (considering the linker is now mature enough
>>>> to link large C/C++ applications).
>>>>
>>>> Also, IMHO, -fuse-ld should be a generic facility which accept other
>>>> linkers (as long as they follow the convention ld.<arg>), and should
>>>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
>>>> Probably outside of the scope of this patch, but I thought worth
>>>> mentioning.
>>>>
>>>> Thanks,
>>>>
>>
>> Hi, can anybody take a look?
>>
>> Thanks,
>
> lld won't build on Fedora 24/x86-64 with GCC 6:
>
> [ 39%] Building CXX object
> tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o
> /export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp: In
> member function ‘void
> lld::elf::GnuHashTableSection<ELFT>::addSymbols(std::vector<std::pair<lld::elf::SymbolBody*,
> long unsigned int> >&)’:
> /export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp:585:8:
> error: inconsistent deduction for ‘auto’: ‘auto’ and then
> ‘__gnu_cxx::__normal_iterator<std::pair<lld::elf::SymbolBody*, long
> unsigned int>*, std::vector<std::pair<lld::elf::SymbolBody*, long
> unsigned int> > >’
> tools/lld/ELF/CMakeFiles/lldELF.dir/build.make:302: recipe for target
> 'tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o' failed
> gmake[4]: *** [tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o] Error 1
>
> Can you fix it?



>> --
>> Davide
>>
>>>> --
>>>> Davide
>>>>
>>>> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
>>>> From: Davide Italiano <dccitaliano@gmail.com>
>>>> Date: Thu, 23 Jun 2016 20:51:53 -0700
>>>> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>>>>
>>>> * collect2.c  (main): Support -fuse-ld=lld.
>>>>
>>>> * common.opt: Add fuse-ld=lld
>>>>
>>>> * doc/invoke.texi:  Document -fuse-ld=lld
>>>>
>>>> * opts.c: Ignore -fuse-ld=lld
>>>> ---
>>>>  gcc/collect2.c      | 11 ++++++++---
>>>>  gcc/common.opt      |  4 ++++
>>>>  gcc/doc/invoke.texi |  4 ++++
>>>>  gcc/opts.c          |  1 +
>>>>  4 files changed, 17 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/gcc/collect2.c b/gcc/collect2.c
>>>> index bffac80..6a8387c 100644
>>>> --- a/gcc/collect2.c
>>>> +++ b/gcc/collect2.c
>>>> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>>>>        USE_PLUGIN_LD,
>>>>        USE_GOLD_LD,
>>>>        USE_BFD_LD,
>>>> +      USE_LLD_LD,
>>>>        USE_LD_MAX
>>>>      } selected_linker = USE_DEFAULT_LD;
>>>>    static const char *const ld_suffixes[USE_LD_MAX] =
>>>> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>>>>        "ld",
>>>>        PLUGIN_LD_SUFFIX,
>>>>        "ld.gold",
>>>> -      "ld.bfd"
>>>> +      "ld.bfd",
>>>> +      "ld.lld"
>>>>      };
>>>>    static const char *const real_ld_suffix = "real-ld";
>>>>    static const char *const collect_ld_suffix = "collect-ld";
>>>> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>>>>        selected_linker = USE_BFD_LD;
>>>>      else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>>>>        selected_linker = USE_GOLD_LD;
>>>> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
>>>> +    selected_linker = USE_LLD_LD;
>>>>
>>>>  #ifdef COLLECT_EXPORT_LIST
>>>>      /* These flags are position independent, although their order
>>>> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>>>>    /* Maybe we know the right file to use (if not cross).  */
>>>>    ld_file_name = 0;
>>>>  #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)
>>>>      {
>>>>        char *linker_name;
>>>>  # ifdef HOST_EXECUTABLE_SUFFIX
>>>> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>>>>            else if (!use_collect_ld
>>>>                 && strncmp (arg, "-fuse-ld=", 9) == 0)
>>>>          {
>>>> -          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
>>>> +          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>>>>            ld1--;
>>>>            ld2--;
>>>>          }
>>>> diff --git a/gcc/common.opt b/gcc/common.opt
>>>> index 5d90385..2a95a1f 100644
>>>> --- a/gcc/common.opt
>>>> +++ b/gcc/common.opt
>>>> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>>>>  Common Driver Negative(fuse-ld=bfd)
>>>>  Use the gold linker instead of the default linker.
>>>>
>>>> +fuse-ld=lld
>>>> +Common Driver Negative(fuse-ld=lld)
>>>> +Use the lld LLVM linker instead of the default linker.
>>>> +
>>>>  fuse-linker-plugin
>>>>  Common Undocumented Var(flag_use_linker_plugin)
>>>>
>>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>>> index 2c87c53..4b8acff 100644
>>>> --- a/gcc/doc/invoke.texi
>>>> +++ b/gcc/doc/invoke.texi
>>>> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
>>>> default linker.
>>>>  @opindex fuse-ld=gold
>>>>  Use the @command{gold} linker instead of the default linker.
>>>>
>>>> +@item -fuse-ld=lld
>>>> +@opindex fuse-ld=lld
>>>> +Use the LLVM @command{lld} linker instead of the default linker.
>>>> +
>>>>  @cindex Libraries
>>>>  @item -l@var{library}
>>>>  @itemx -l @var{library}
>>>> diff --git a/gcc/opts.c b/gcc/opts.c
>>>> index 7406210..f2c86f7 100644
>>>> --- a/gcc/opts.c
>>>> +++ b/gcc/opts.c
>>>> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>>>>
>>>>      case OPT_fuse_ld_bfd:
>>>>      case OPT_fuse_ld_gold:
>>>> +    case OPT_fuse_ld_lld:
>>>>      case OPT_fuse_linker_plugin:
>>>>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>>>>        break;
>>>> --
>>>> 2.5.5
>
>
>
> --
> H.J.


FWIW, this should be fixed upstream.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04 19:37       ` Markus Trippelsdorf
  2016-07-04 19:44         ` Davide Italiano
@ 2016-07-04 19:58         ` Mike Stump
  2016-07-07  0:52         ` Trevor Saunders
  2 siblings, 0 replies; 27+ messages in thread
From: Mike Stump @ 2016-07-04 19:58 UTC (permalink / raw)
  To: Markus Trippelsdorf; +Cc: H.J. Lu, Davide Italiano, GCC Patches

On Jul 4, 2016, at 12:36 PM, Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
> 
> On 2016.07.04 at 10:08 -0700, H.J. Lu wrote:
>> On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>> On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>>> + HJ who wrote the code for the option originally.
>>>> 
>>>> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>>>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
>>>>> I experiment a lot with gcc and lld so it would be nice if
>>>>> -fuse-ld=lld is supported (considering the linker is now mature enough
>>>>> to link large C/C++ applications).
>>>>> 
>>>>> Also, IMHO, -fuse-ld should be a generic facility which accept other
>>>>> linkers (as long as they follow the convention ld.<arg>), and should
>>>>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
>>>>> Probably outside of the scope of this patch, but I thought worth
>>>>> mentioning.
>>> 
>>> Hi, can anybody take a look?
>> 
>> lld isn't compatible with GCC:
>> 
>> https://llvm.org/bugs/show_bug.cgi?id=28414
> 
> Besides the technical issues, this also raises the question if it is
> right to support lld at all. Because this project was obviously started
> to replace the GNU linkers (ld.bfd and gold) in the long run.
> So I see no reason why it should be supported in GCC.
> 
> (And who needs a buggy new ELF linker anyway?)

So, this is off-topic for the list, gnu.misc.discuss is a better forum for such things, if you want.  The GNU tools have no prohibition with working with system libraries that are non-free, nor non-free tools, such as ar, nm, ld and as or even simulators.  Contributions for interoperability with other tools will be considered.  gcc has always been widely compatible and interoperable with more than just Linux systems.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04 19:37       ` Markus Trippelsdorf
@ 2016-07-04 19:44         ` Davide Italiano
  2016-07-04 19:58         ` Mike Stump
  2016-07-07  0:52         ` Trevor Saunders
  2 siblings, 0 replies; 27+ messages in thread
From: Davide Italiano @ 2016-07-04 19:44 UTC (permalink / raw)
  To: Markus Trippelsdorf; +Cc: H.J. Lu, GCC Patches

On Mon, Jul 4, 2016 at 12:36 PM, Markus Trippelsdorf
<markus@trippelsdorf.de> wrote:
> On 2016.07.04 at 10:08 -0700, H.J. Lu wrote:
>> On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> > On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> >> + HJ who wrote the code for the option originally.
>> >>
>> >> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> >>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
>> >>> I experiment a lot with gcc and lld so it would be nice if
>> >>> -fuse-ld=lld is supported (considering the linker is now mature enough
>> >>> to link large C/C++ applications).
>> >>>
>> >>> Also, IMHO, -fuse-ld should be a generic facility which accept other
>> >>> linkers (as long as they follow the convention ld.<arg>), and should
>> >>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
>> >>> Probably outside of the scope of this patch, but I thought worth
>> >>> mentioning.
>> >
>> > Hi, can anybody take a look?
>>
>> lld isn't compatible with GCC:
>>
>> https://llvm.org/bugs/show_bug.cgi?id=28414
>
> Besides the technical issues, this also raises the question if it is
> right to support lld at all. Because this project was obviously started
> to replace the GNU linkers (ld.bfd and gold) in the long run.
> So I see no reason why it should be supported in GCC.
>
> (And who needs a buggy new ELF linker anyway?)


Fair enough. Consider this patch withdrawn, sorry for the noise.

--
Davide

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04 17:08     ` H.J. Lu
@ 2016-07-04 19:37       ` Markus Trippelsdorf
  2016-07-04 19:44         ` Davide Italiano
                           ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Markus Trippelsdorf @ 2016-07-04 19:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Davide Italiano, GCC Patches

On 2016.07.04 at 10:08 -0700, H.J. Lu wrote:
> On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> > On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> >> + HJ who wrote the code for the option originally.
> >>
> >> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> >>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
> >>> I experiment a lot with gcc and lld so it would be nice if
> >>> -fuse-ld=lld is supported (considering the linker is now mature enough
> >>> to link large C/C++ applications).
> >>>
> >>> Also, IMHO, -fuse-ld should be a generic facility which accept other
> >>> linkers (as long as they follow the convention ld.<arg>), and should
> >>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
> >>> Probably outside of the scope of this patch, but I thought worth
> >>> mentioning.
> >
> > Hi, can anybody take a look?
> 
> lld isn't compatible with GCC:
> 
> https://llvm.org/bugs/show_bug.cgi?id=28414

Besides the technical issues, this also raises the question if it is
right to support lld at all. Because this project was obviously started
to replace the GNU linkers (ld.bfd and gold) in the long run.
So I see no reason why it should be supported in GCC.

(And who needs a buggy new ELF linker anyway?)

-- 
Markus

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-06-24  4:11 Davide Italiano
  2016-06-24  6:53 ` Davide Italiano
@ 2016-07-04 17:14 ` H.J. Lu
  2019-01-26 22:37 ` Segher Boessenkool
  2 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2016-07-04 17:14 UTC (permalink / raw)
  To: Davide Italiano; +Cc: GCC Patches

On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
> I experiment a lot with gcc and lld so it would be nice if
> -fuse-ld=lld is supported (considering the linker is now mature enough
> to link large C/C++ applications).
>
> Also, IMHO, -fuse-ld should be a generic facility which accept other
> linkers (as long as they follow the convention ld.<arg>), and should
> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
> Probably outside of the scope of this patch, but I thought worth
> mentioning.
>
> Thanks,
>
> --
> Davide
>
> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
> From: Davide Italiano <dccitaliano@gmail.com>
> Date: Thu, 23 Jun 2016 20:51:53 -0700
> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>
> * collect2.c  (main): Support -fuse-ld=lld.
>
> * common.opt: Add fuse-ld=lld
>
> * doc/invoke.texi:  Document -fuse-ld=lld
>
> * opts.c: Ignore -fuse-ld=lld

Remove blank line between them.

> ---
>  gcc/collect2.c      | 11 ++++++++---
>  gcc/common.opt      |  4 ++++
>  gcc/doc/invoke.texi |  4 ++++
>  gcc/opts.c          |  1 +
>  4 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/collect2.c b/gcc/collect2.c
> index bffac80..6a8387c 100644
> --- a/gcc/collect2.c
> +++ b/gcc/collect2.c
> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>        USE_PLUGIN_LD,
>        USE_GOLD_LD,
>        USE_BFD_LD,
> +      USE_LLD_LD,
>        USE_LD_MAX
>      } selected_linker = USE_DEFAULT_LD;
>    static const char *const ld_suffixes[USE_LD_MAX] =
> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>        "ld",
>        PLUGIN_LD_SUFFIX,
>        "ld.gold",
> -      "ld.bfd"
> +      "ld.bfd",
> +      "ld.lld"
>      };
>    static const char *const real_ld_suffix = "real-ld";
>    static const char *const collect_ld_suffix = "collect-ld";
> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>        selected_linker = USE_BFD_LD;
>      else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>        selected_linker = USE_GOLD_LD;
> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
> +    selected_linker = USE_LLD_LD;
>
>  #ifdef COLLECT_EXPORT_LIST
>      /* These flags are position independent, although their order
> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>    /* Maybe we know the right file to use (if not cross).  */
>    ld_file_name = 0;
>  #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)

Please make each condition on a separate line starting with ||.

>      {
>        char *linker_name;
>  # ifdef HOST_EXECUTABLE_SUFFIX
> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>            else if (!use_collect_ld
>                 && strncmp (arg, "-fuse-ld=", 9) == 0)
>          {
> -          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
> +          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>            ld1--;
>            ld2--;
>          }
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 5d90385..2a95a1f 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>  Common Driver Negative(fuse-ld=bfd)
>  Use the gold linker instead of the default linker.
>
> +fuse-ld=lld
> +Common Driver Negative(fuse-ld=lld)
> +Use the lld LLVM linker instead of the default linker.
> +

This is wrong.  It should be

fuse-ld=bfd
Common Driver Negative(fuse-ld=gold)
Use the bfd linker instead of the default linker.

fuse-ld=gold
Common Driver Negative(fuse-ld=lld)
Use the gold linker instead of the default linker.

fuse-ld=lld
Common Driver Negative(fuse-ld=bfd)
Use the lld LLVM linker instead of the default linker.


>  fuse-linker-plugin
>  Common Undocumented Var(flag_use_linker_plugin)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 2c87c53..4b8acff 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
> default linker.
>  @opindex fuse-ld=gold
>  Use the @command{gold} linker instead of the default linker.
>
> +@item -fuse-ld=lld
> +@opindex fuse-ld=lld
> +Use the LLVM @command{lld} linker instead of the default linker.
> +
>  @cindex Libraries
>  @item -l@var{library}
>  @itemx -l @var{library}
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 7406210..f2c86f7 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>
>      case OPT_fuse_ld_bfd:
>      case OPT_fuse_ld_gold:
> +    case OPT_fuse_ld_lld:
>      case OPT_fuse_linker_plugin:
>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>        break;
> --
> 2.5.5



-- 
H.J.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04  4:39   ` Davide Italiano
  2016-07-04 16:12     ` H.J. Lu
@ 2016-07-04 17:08     ` H.J. Lu
  2016-07-04 19:37       ` Markus Trippelsdorf
  1 sibling, 1 reply; 27+ messages in thread
From: H.J. Lu @ 2016-07-04 17:08 UTC (permalink / raw)
  To: Davide Italiano; +Cc: GCC Patches

On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> + HJ who wrote the code for the option originally.
>>
>> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
>>> I experiment a lot with gcc and lld so it would be nice if
>>> -fuse-ld=lld is supported (considering the linker is now mature enough
>>> to link large C/C++ applications).
>>>
>>> Also, IMHO, -fuse-ld should be a generic facility which accept other
>>> linkers (as long as they follow the convention ld.<arg>), and should
>>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
>>> Probably outside of the scope of this patch, but I thought worth
>>> mentioning.
>>>
>>> Thanks,
>>>
>
> Hi, can anybody take a look?

lld isn't compatible with GCC:

https://llvm.org/bugs/show_bug.cgi?id=28414


> Thanks,
>
> --
> Davide
>
>>> --
>>> Davide
>>>
>>> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
>>> From: Davide Italiano <dccitaliano@gmail.com>
>>> Date: Thu, 23 Jun 2016 20:51:53 -0700
>>> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>>>
>>> * collect2.c  (main): Support -fuse-ld=lld.
>>>
>>> * common.opt: Add fuse-ld=lld
>>>
>>> * doc/invoke.texi:  Document -fuse-ld=lld
>>>
>>> * opts.c: Ignore -fuse-ld=lld
>>> ---
>>>  gcc/collect2.c      | 11 ++++++++---
>>>  gcc/common.opt      |  4 ++++
>>>  gcc/doc/invoke.texi |  4 ++++
>>>  gcc/opts.c          |  1 +
>>>  4 files changed, 17 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/gcc/collect2.c b/gcc/collect2.c
>>> index bffac80..6a8387c 100644
>>> --- a/gcc/collect2.c
>>> +++ b/gcc/collect2.c
>>> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>>>        USE_PLUGIN_LD,
>>>        USE_GOLD_LD,
>>>        USE_BFD_LD,
>>> +      USE_LLD_LD,
>>>        USE_LD_MAX
>>>      } selected_linker = USE_DEFAULT_LD;
>>>    static const char *const ld_suffixes[USE_LD_MAX] =
>>> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>>>        "ld",
>>>        PLUGIN_LD_SUFFIX,
>>>        "ld.gold",
>>> -      "ld.bfd"
>>> +      "ld.bfd",
>>> +      "ld.lld"
>>>      };
>>>    static const char *const real_ld_suffix = "real-ld";
>>>    static const char *const collect_ld_suffix = "collect-ld";
>>> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>>>        selected_linker = USE_BFD_LD;
>>>      else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>>>        selected_linker = USE_GOLD_LD;
>>> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
>>> +    selected_linker = USE_LLD_LD;
>>>
>>>  #ifdef COLLECT_EXPORT_LIST
>>>      /* These flags are position independent, although their order
>>> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>>>    /* Maybe we know the right file to use (if not cross).  */
>>>    ld_file_name = 0;
>>>  #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)
>>>      {
>>>        char *linker_name;
>>>  # ifdef HOST_EXECUTABLE_SUFFIX
>>> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>>>            else if (!use_collect_ld
>>>                 && strncmp (arg, "-fuse-ld=", 9) == 0)
>>>          {
>>> -          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
>>> +          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>>>            ld1--;
>>>            ld2--;
>>>          }
>>> diff --git a/gcc/common.opt b/gcc/common.opt
>>> index 5d90385..2a95a1f 100644
>>> --- a/gcc/common.opt
>>> +++ b/gcc/common.opt
>>> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>>>  Common Driver Negative(fuse-ld=bfd)
>>>  Use the gold linker instead of the default linker.
>>>
>>> +fuse-ld=lld
>>> +Common Driver Negative(fuse-ld=lld)
>>> +Use the lld LLVM linker instead of the default linker.
>>> +
>>>  fuse-linker-plugin
>>>  Common Undocumented Var(flag_use_linker_plugin)
>>>
>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>> index 2c87c53..4b8acff 100644
>>> --- a/gcc/doc/invoke.texi
>>> +++ b/gcc/doc/invoke.texi
>>> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
>>> default linker.
>>>  @opindex fuse-ld=gold
>>>  Use the @command{gold} linker instead of the default linker.
>>>
>>> +@item -fuse-ld=lld
>>> +@opindex fuse-ld=lld
>>> +Use the LLVM @command{lld} linker instead of the default linker.
>>> +
>>>  @cindex Libraries
>>>  @item -l@var{library}
>>>  @itemx -l @var{library}
>>> diff --git a/gcc/opts.c b/gcc/opts.c
>>> index 7406210..f2c86f7 100644
>>> --- a/gcc/opts.c
>>> +++ b/gcc/opts.c
>>> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>>>
>>>      case OPT_fuse_ld_bfd:
>>>      case OPT_fuse_ld_gold:
>>> +    case OPT_fuse_ld_lld:
>>>      case OPT_fuse_linker_plugin:
>>>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>>>        break;
>>> --
>>> 2.5.5



-- 
H.J.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-07-04  4:39   ` Davide Italiano
@ 2016-07-04 16:12     ` H.J. Lu
  2016-07-04 19:58       ` Davide Italiano
  2016-07-04 17:08     ` H.J. Lu
  1 sibling, 1 reply; 27+ messages in thread
From: H.J. Lu @ 2016-07-04 16:12 UTC (permalink / raw)
  To: Davide Italiano; +Cc: GCC Patches

On Sun, Jul 3, 2016 at 9:38 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> + HJ who wrote the code for the option originally.
>>
>> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
>>> I experiment a lot with gcc and lld so it would be nice if
>>> -fuse-ld=lld is supported (considering the linker is now mature enough
>>> to link large C/C++ applications).
>>>
>>> Also, IMHO, -fuse-ld should be a generic facility which accept other
>>> linkers (as long as they follow the convention ld.<arg>), and should
>>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
>>> Probably outside of the scope of this patch, but I thought worth
>>> mentioning.
>>>
>>> Thanks,
>>>
>
> Hi, can anybody take a look?
>
> Thanks,

lld won't build on Fedora 24/x86-64 with GCC 6:

[ 39%] Building CXX object
tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp: In
member function ‘void
lld::elf::GnuHashTableSection<ELFT>::addSymbols(std::vector<std::pair<lld::elf::SymbolBody*,
long unsigned int> >&)’:
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp:585:8:
error: inconsistent deduction for ‘auto’: ‘auto’ and then
‘__gnu_cxx::__normal_iterator<std::pair<lld::elf::SymbolBody*, long
unsigned int>*, std::vector<std::pair<lld::elf::SymbolBody*, long
unsigned int> > >’
tools/lld/ELF/CMakeFiles/lldELF.dir/build.make:302: recipe for target
'tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o' failed
gmake[4]: *** [tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o] Error 1

Can you fix it?

H.J.
> --
> Davide
>
>>> --
>>> Davide
>>>
>>> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
>>> From: Davide Italiano <dccitaliano@gmail.com>
>>> Date: Thu, 23 Jun 2016 20:51:53 -0700
>>> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>>>
>>> * collect2.c  (main): Support -fuse-ld=lld.
>>>
>>> * common.opt: Add fuse-ld=lld
>>>
>>> * doc/invoke.texi:  Document -fuse-ld=lld
>>>
>>> * opts.c: Ignore -fuse-ld=lld
>>> ---
>>>  gcc/collect2.c      | 11 ++++++++---
>>>  gcc/common.opt      |  4 ++++
>>>  gcc/doc/invoke.texi |  4 ++++
>>>  gcc/opts.c          |  1 +
>>>  4 files changed, 17 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/gcc/collect2.c b/gcc/collect2.c
>>> index bffac80..6a8387c 100644
>>> --- a/gcc/collect2.c
>>> +++ b/gcc/collect2.c
>>> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>>>        USE_PLUGIN_LD,
>>>        USE_GOLD_LD,
>>>        USE_BFD_LD,
>>> +      USE_LLD_LD,
>>>        USE_LD_MAX
>>>      } selected_linker = USE_DEFAULT_LD;
>>>    static const char *const ld_suffixes[USE_LD_MAX] =
>>> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>>>        "ld",
>>>        PLUGIN_LD_SUFFIX,
>>>        "ld.gold",
>>> -      "ld.bfd"
>>> +      "ld.bfd",
>>> +      "ld.lld"
>>>      };
>>>    static const char *const real_ld_suffix = "real-ld";
>>>    static const char *const collect_ld_suffix = "collect-ld";
>>> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>>>        selected_linker = USE_BFD_LD;
>>>      else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>>>        selected_linker = USE_GOLD_LD;
>>> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
>>> +    selected_linker = USE_LLD_LD;
>>>
>>>  #ifdef COLLECT_EXPORT_LIST
>>>      /* These flags are position independent, although their order
>>> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>>>    /* Maybe we know the right file to use (if not cross).  */
>>>    ld_file_name = 0;
>>>  #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)
>>>      {
>>>        char *linker_name;
>>>  # ifdef HOST_EXECUTABLE_SUFFIX
>>> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>>>            else if (!use_collect_ld
>>>                 && strncmp (arg, "-fuse-ld=", 9) == 0)
>>>          {
>>> -          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
>>> +          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>>>            ld1--;
>>>            ld2--;
>>>          }
>>> diff --git a/gcc/common.opt b/gcc/common.opt
>>> index 5d90385..2a95a1f 100644
>>> --- a/gcc/common.opt
>>> +++ b/gcc/common.opt
>>> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>>>  Common Driver Negative(fuse-ld=bfd)
>>>  Use the gold linker instead of the default linker.
>>>
>>> +fuse-ld=lld
>>> +Common Driver Negative(fuse-ld=lld)
>>> +Use the lld LLVM linker instead of the default linker.
>>> +
>>>  fuse-linker-plugin
>>>  Common Undocumented Var(flag_use_linker_plugin)
>>>
>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>> index 2c87c53..4b8acff 100644
>>> --- a/gcc/doc/invoke.texi
>>> +++ b/gcc/doc/invoke.texi
>>> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
>>> default linker.
>>>  @opindex fuse-ld=gold
>>>  Use the @command{gold} linker instead of the default linker.
>>>
>>> +@item -fuse-ld=lld
>>> +@opindex fuse-ld=lld
>>> +Use the LLVM @command{lld} linker instead of the default linker.
>>> +
>>>  @cindex Libraries
>>>  @item -l@var{library}
>>>  @itemx -l @var{library}
>>> diff --git a/gcc/opts.c b/gcc/opts.c
>>> index 7406210..f2c86f7 100644
>>> --- a/gcc/opts.c
>>> +++ b/gcc/opts.c
>>> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>>>
>>>      case OPT_fuse_ld_bfd:
>>>      case OPT_fuse_ld_gold:
>>> +    case OPT_fuse_ld_lld:
>>>      case OPT_fuse_linker_plugin:
>>>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>>>        break;
>>> --
>>> 2.5.5



-- 
H.J.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-06-24  6:53 ` Davide Italiano
@ 2016-07-04  4:39   ` Davide Italiano
  2016-07-04 16:12     ` H.J. Lu
  2016-07-04 17:08     ` H.J. Lu
  0 siblings, 2 replies; 27+ messages in thread
From: Davide Italiano @ 2016-07-04  4:39 UTC (permalink / raw)
  To: gcc-patches, hjl.tools

On Thu, Jun 23, 2016 at 9:11 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> + HJ who wrote the code for the option originally.
>
> On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
>> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
>> I experiment a lot with gcc and lld so it would be nice if
>> -fuse-ld=lld is supported (considering the linker is now mature enough
>> to link large C/C++ applications).
>>
>> Also, IMHO, -fuse-ld should be a generic facility which accept other
>> linkers (as long as they follow the convention ld.<arg>), and should
>> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
>> Probably outside of the scope of this patch, but I thought worth
>> mentioning.
>>
>> Thanks,
>>

Hi, can anybody take a look?

Thanks,

--
Davide

>> --
>> Davide
>>
>> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
>> From: Davide Italiano <dccitaliano@gmail.com>
>> Date: Thu, 23 Jun 2016 20:51:53 -0700
>> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>>
>> * collect2.c  (main): Support -fuse-ld=lld.
>>
>> * common.opt: Add fuse-ld=lld
>>
>> * doc/invoke.texi:  Document -fuse-ld=lld
>>
>> * opts.c: Ignore -fuse-ld=lld
>> ---
>>  gcc/collect2.c      | 11 ++++++++---
>>  gcc/common.opt      |  4 ++++
>>  gcc/doc/invoke.texi |  4 ++++
>>  gcc/opts.c          |  1 +
>>  4 files changed, 17 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/collect2.c b/gcc/collect2.c
>> index bffac80..6a8387c 100644
>> --- a/gcc/collect2.c
>> +++ b/gcc/collect2.c
>> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>>        USE_PLUGIN_LD,
>>        USE_GOLD_LD,
>>        USE_BFD_LD,
>> +      USE_LLD_LD,
>>        USE_LD_MAX
>>      } selected_linker = USE_DEFAULT_LD;
>>    static const char *const ld_suffixes[USE_LD_MAX] =
>> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>>        "ld",
>>        PLUGIN_LD_SUFFIX,
>>        "ld.gold",
>> -      "ld.bfd"
>> +      "ld.bfd",
>> +      "ld.lld"
>>      };
>>    static const char *const real_ld_suffix = "real-ld";
>>    static const char *const collect_ld_suffix = "collect-ld";
>> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>>        selected_linker = USE_BFD_LD;
>>      else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>>        selected_linker = USE_GOLD_LD;
>> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
>> +    selected_linker = USE_LLD_LD;
>>
>>  #ifdef COLLECT_EXPORT_LIST
>>      /* These flags are position independent, although their order
>> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>>    /* Maybe we know the right file to use (if not cross).  */
>>    ld_file_name = 0;
>>  #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)
>>      {
>>        char *linker_name;
>>  # ifdef HOST_EXECUTABLE_SUFFIX
>> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>>            else if (!use_collect_ld
>>                 && strncmp (arg, "-fuse-ld=", 9) == 0)
>>          {
>> -          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
>> +          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>>            ld1--;
>>            ld2--;
>>          }
>> diff --git a/gcc/common.opt b/gcc/common.opt
>> index 5d90385..2a95a1f 100644
>> --- a/gcc/common.opt
>> +++ b/gcc/common.opt
>> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>>  Common Driver Negative(fuse-ld=bfd)
>>  Use the gold linker instead of the default linker.
>>
>> +fuse-ld=lld
>> +Common Driver Negative(fuse-ld=lld)
>> +Use the lld LLVM linker instead of the default linker.
>> +
>>  fuse-linker-plugin
>>  Common Undocumented Var(flag_use_linker_plugin)
>>
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index 2c87c53..4b8acff 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
>> default linker.
>>  @opindex fuse-ld=gold
>>  Use the @command{gold} linker instead of the default linker.
>>
>> +@item -fuse-ld=lld
>> +@opindex fuse-ld=lld
>> +Use the LLVM @command{lld} linker instead of the default linker.
>> +
>>  @cindex Libraries
>>  @item -l@var{library}
>>  @itemx -l @var{library}
>> diff --git a/gcc/opts.c b/gcc/opts.c
>> index 7406210..f2c86f7 100644
>> --- a/gcc/opts.c
>> +++ b/gcc/opts.c
>> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>>
>>      case OPT_fuse_ld_bfd:
>>      case OPT_fuse_ld_gold:
>> +    case OPT_fuse_ld_lld:
>>      case OPT_fuse_linker_plugin:
>>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>>        break;
>> --
>> 2.5.5

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [Driver] Add support for -fuse-ld=lld
  2016-06-24  4:11 Davide Italiano
@ 2016-06-24  6:53 ` Davide Italiano
  2016-07-04  4:39   ` Davide Italiano
  2016-07-04 17:14 ` H.J. Lu
  2019-01-26 22:37 ` Segher Boessenkool
  2 siblings, 1 reply; 27+ messages in thread
From: Davide Italiano @ 2016-06-24  6:53 UTC (permalink / raw)
  To: gcc-patches, hjl.tools

+ HJ who wrote the code for the option originally.

On Thu, Jun 23, 2016 at 9:01 PM, Davide Italiano <dccitaliano@gmail.com> wrote:
> LLVM currently ships with a new ELF linker http://lld.llvm.org/.
> I experiment a lot with gcc and lld so it would be nice if
> -fuse-ld=lld is supported (considering the linker is now mature enough
> to link large C/C++ applications).
>
> Also, IMHO, -fuse-ld should be a generic facility which accept other
> linkers (as long as they follow the convention ld.<arg>), and should
> also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
> Probably outside of the scope of this patch, but I thought worth
> mentioning.
>
> Thanks,
>
> --
> Davide
>
> From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
> From: Davide Italiano <dccitaliano@gmail.com>
> Date: Thu, 23 Jun 2016 20:51:53 -0700
> Subject: [PATCH] Driver: Add support for -fuse-ld=lld.
>
> * collect2.c  (main): Support -fuse-ld=lld.
>
> * common.opt: Add fuse-ld=lld
>
> * doc/invoke.texi:  Document -fuse-ld=lld
>
> * opts.c: Ignore -fuse-ld=lld
> ---
>  gcc/collect2.c      | 11 ++++++++---
>  gcc/common.opt      |  4 ++++
>  gcc/doc/invoke.texi |  4 ++++
>  gcc/opts.c          |  1 +
>  4 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/collect2.c b/gcc/collect2.c
> index bffac80..6a8387c 100644
> --- a/gcc/collect2.c
> +++ b/gcc/collect2.c
> @@ -831,6 +831,7 @@ main (int argc, char **argv)
>        USE_PLUGIN_LD,
>        USE_GOLD_LD,
>        USE_BFD_LD,
> +      USE_LLD_LD,
>        USE_LD_MAX
>      } selected_linker = USE_DEFAULT_LD;
>    static const char *const ld_suffixes[USE_LD_MAX] =
> @@ -838,7 +839,8 @@ main (int argc, char **argv)
>        "ld",
>        PLUGIN_LD_SUFFIX,
>        "ld.gold",
> -      "ld.bfd"
> +      "ld.bfd",
> +      "ld.lld"
>      };
>    static const char *const real_ld_suffix = "real-ld";
>    static const char *const collect_ld_suffix = "collect-ld";
> @@ -1004,6 +1006,8 @@ main (int argc, char **argv)
>        selected_linker = USE_BFD_LD;
>      else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
>        selected_linker = USE_GOLD_LD;
> +  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
> +    selected_linker = USE_LLD_LD;
>
>  #ifdef COLLECT_EXPORT_LIST
>      /* These flags are position independent, although their order
> @@ -1093,7 +1097,8 @@ main (int argc, char **argv)
>    /* Maybe we know the right file to use (if not cross).  */
>    ld_file_name = 0;
>  #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)
>      {
>        char *linker_name;
>  # ifdef HOST_EXECUTABLE_SUFFIX
> @@ -1307,7 +1312,7 @@ main (int argc, char **argv)
>            else if (!use_collect_ld
>                 && strncmp (arg, "-fuse-ld=", 9) == 0)
>          {
> -          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
> +          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
>            ld1--;
>            ld2--;
>          }
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 5d90385..2a95a1f 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -2536,6 +2536,10 @@ fuse-ld=gold
>  Common Driver Negative(fuse-ld=bfd)
>  Use the gold linker instead of the default linker.
>
> +fuse-ld=lld
> +Common Driver Negative(fuse-ld=lld)
> +Use the lld LLVM linker instead of the default linker.
> +
>  fuse-linker-plugin
>  Common Undocumented Var(flag_use_linker_plugin)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 2c87c53..4b8acff 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
> default linker.
>  @opindex fuse-ld=gold
>  Use the @command{gold} linker instead of the default linker.
>
> +@item -fuse-ld=lld
> +@opindex fuse-ld=lld
> +Use the LLVM @command{lld} linker instead of the default linker.
> +
>  @cindex Libraries
>  @item -l@var{library}
>  @itemx -l @var{library}
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 7406210..f2c86f7 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
>
>      case OPT_fuse_ld_bfd:
>      case OPT_fuse_ld_gold:
> +    case OPT_fuse_ld_lld:
>      case OPT_fuse_linker_plugin:
>        /* No-op. Used by the driver and passed to us because it starts with f.*/
>        break;
> --
> 2.5.5

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Driver] Add support for -fuse-ld=lld
@ 2016-06-24  4:11 Davide Italiano
  2016-06-24  6:53 ` Davide Italiano
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Davide Italiano @ 2016-06-24  4:11 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 4119 bytes --]

LLVM currently ships with a new ELF linker http://lld.llvm.org/.
I experiment a lot with gcc and lld so it would be nice if
-fuse-ld=lld is supported (considering the linker is now mature enough
to link large C/C++ applications).

Also, IMHO, -fuse-ld should be a generic facility which accept other
linkers (as long as they follow the convention ld.<arg>), and should
also support absolute path, e.g. -fuse-ld=/usr/local/bin/ld.mylinker.
Probably outside of the scope of this patch, but I thought worth
mentioning.

Thanks,

--
Davide

From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
From: Davide Italiano <dccitaliano@gmail.com>
Date: Thu, 23 Jun 2016 20:51:53 -0700
Subject: [PATCH] Driver: Add support for -fuse-ld=lld.

* collect2.c  (main): Support -fuse-ld=lld.

* common.opt: Add fuse-ld=lld

* doc/invoke.texi:  Document -fuse-ld=lld

* opts.c: Ignore -fuse-ld=lld
---
 gcc/collect2.c      | 11 ++++++++---
 gcc/common.opt      |  4 ++++
 gcc/doc/invoke.texi |  4 ++++
 gcc/opts.c          |  1 +
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index bffac80..6a8387c 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -831,6 +831,7 @@ main (int argc, char **argv)
       USE_PLUGIN_LD,
       USE_GOLD_LD,
       USE_BFD_LD,
+      USE_LLD_LD,
       USE_LD_MAX
     } selected_linker = USE_DEFAULT_LD;
   static const char *const ld_suffixes[USE_LD_MAX] =
@@ -838,7 +839,8 @@ main (int argc, char **argv)
       "ld",
       PLUGIN_LD_SUFFIX,
       "ld.gold",
-      "ld.bfd"
+      "ld.bfd",
+      "ld.lld"
     };
   static const char *const real_ld_suffix = "real-ld";
   static const char *const collect_ld_suffix = "collect-ld";
@@ -1004,6 +1006,8 @@ main (int argc, char **argv)
       selected_linker = USE_BFD_LD;
     else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
       selected_linker = USE_GOLD_LD;
+  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
+    selected_linker = USE_LLD_LD;

 #ifdef COLLECT_EXPORT_LIST
     /* These flags are position independent, although their order
@@ -1093,7 +1097,8 @@ main (int argc, char **argv)
   /* Maybe we know the right file to use (if not cross).  */
   ld_file_name = 0;
 #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)
     {
       char *linker_name;
 # ifdef HOST_EXECUTABLE_SUFFIX
@@ -1307,7 +1312,7 @@ main (int argc, char **argv)
           else if (!use_collect_ld
                && strncmp (arg, "-fuse-ld=", 9) == 0)
         {
-          /* Do not pass -fuse-ld={bfd|gold} to the linker. */
+          /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
           ld1--;
           ld2--;
         }
diff --git a/gcc/common.opt b/gcc/common.opt
index 5d90385..2a95a1f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2536,6 +2536,10 @@ fuse-ld=gold
 Common Driver Negative(fuse-ld=bfd)
 Use the gold linker instead of the default linker.

+fuse-ld=lld
+Common Driver Negative(fuse-ld=lld)
+Use the lld LLVM linker instead of the default linker.
+
 fuse-linker-plugin
 Common Undocumented Var(flag_use_linker_plugin)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2c87c53..4b8acff 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the
default linker.
 @opindex fuse-ld=gold
 Use the @command{gold} linker instead of the default linker.

+@item -fuse-ld=lld
+@opindex fuse-ld=lld
+Use the LLVM @command{lld} linker instead of the default linker.
+
 @cindex Libraries
 @item -l@var{library}
 @itemx -l @var{library}
diff --git a/gcc/opts.c b/gcc/opts.c
index 7406210..f2c86f7 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,

     case OPT_fuse_ld_bfd:
     case OPT_fuse_ld_gold:
+    case OPT_fuse_ld_lld:
     case OPT_fuse_linker_plugin:
       /* No-op. Used by the driver and passed to us because it starts with f.*/
       break;
-- 
2.5.5

[-- Attachment #2: 0001-Driver-Add-support-for-fuse-ld-lld.patch --]
[-- Type: text/x-patch, Size: 3531 bytes --]

From 323c23d79c91d7dcee2f29b9ced8c1c00703d346 Mon Sep 17 00:00:00 2001
From: Davide Italiano <dccitaliano@gmail.com>
Date: Thu, 23 Jun 2016 20:51:53 -0700
Subject: [PATCH] Driver: Add support for -fuse-ld=lld.

* collect2.c  (main): Support -fuse-ld=lld.

* common.opt: Add fuse-ld=lld

* doc/invoke.texi:  Document -fuse-ld=lld

* opts.c: Ignore -fuse-ld=lld
---
 gcc/collect2.c      | 11 ++++++++---
 gcc/common.opt      |  4 ++++
 gcc/doc/invoke.texi |  4 ++++
 gcc/opts.c          |  1 +
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index bffac80..6a8387c 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -831,6 +831,7 @@ main (int argc, char **argv)
       USE_PLUGIN_LD,
       USE_GOLD_LD,
       USE_BFD_LD,
+      USE_LLD_LD,
       USE_LD_MAX
     } selected_linker = USE_DEFAULT_LD;
   static const char *const ld_suffixes[USE_LD_MAX] =
@@ -838,7 +839,8 @@ main (int argc, char **argv)
       "ld",
       PLUGIN_LD_SUFFIX,
       "ld.gold",
-      "ld.bfd"
+      "ld.bfd",
+      "ld.lld"
     };
   static const char *const real_ld_suffix = "real-ld";
   static const char *const collect_ld_suffix = "collect-ld";
@@ -1004,6 +1006,8 @@ main (int argc, char **argv)
 	  selected_linker = USE_BFD_LD;
 	else if (strcmp (argv[i], "-fuse-ld=gold") == 0)
 	  selected_linker = USE_GOLD_LD;
+  else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
+    selected_linker = USE_LLD_LD;
 
 #ifdef COLLECT_EXPORT_LIST
 	/* These flags are position independent, although their order
@@ -1093,7 +1097,8 @@ main (int argc, char **argv)
   /* Maybe we know the right file to use (if not cross).  */
   ld_file_name = 0;
 #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)
     {
       char *linker_name;
 # ifdef HOST_EXECUTABLE_SUFFIX
@@ -1307,7 +1312,7 @@ main (int argc, char **argv)
 	      else if (!use_collect_ld
 		       && strncmp (arg, "-fuse-ld=", 9) == 0)
 		{
-		  /* Do not pass -fuse-ld={bfd|gold} to the linker. */
+		  /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
 		  ld1--;
 		  ld2--;
 		}
diff --git a/gcc/common.opt b/gcc/common.opt
index 5d90385..2a95a1f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2536,6 +2536,10 @@ fuse-ld=gold
 Common Driver Negative(fuse-ld=bfd)
 Use the gold linker instead of the default linker.
 
+fuse-ld=lld
+Common Driver Negative(fuse-ld=lld)
+Use the lld LLVM linker instead of the default linker.
+
 fuse-linker-plugin
 Common Undocumented Var(flag_use_linker_plugin)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2c87c53..4b8acff 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10651,6 +10651,10 @@ Use the @command{bfd} linker instead of the default linker.
 @opindex fuse-ld=gold
 Use the @command{gold} linker instead of the default linker.
 
+@item -fuse-ld=lld
+@opindex fuse-ld=lld
+Use the LLVM @command{lld} linker instead of the default linker.
+
 @cindex Libraries
 @item -l@var{library}
 @itemx -l @var{library}
diff --git a/gcc/opts.c b/gcc/opts.c
index 7406210..f2c86f7 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2178,6 +2178,7 @@ common_handle_option (struct gcc_options *opts,
 
     case OPT_fuse_ld_bfd:
     case OPT_fuse_ld_gold:
+    case OPT_fuse_ld_lld:
     case OPT_fuse_linker_plugin:
       /* No-op. Used by the driver and passed to us because it starts with f.*/
       break;
-- 
2.5.5


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-02-04 12:08 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20 12:38 [Driver] Add support for -fuse-ld=lld Romain Geissler
2018-10-27 17:52 ` Romain GEISSLER
2018-11-06 16:14   ` Romain GEISSLER
2018-11-06 16:23 ` H.J. Lu
2018-11-08 11:00   ` [EXT] " Romain Geissler
2018-11-08 11:51     ` Richard Biener
2018-11-08 21:46       ` Romain Geissler
2018-11-08 22:04 ` Jeff Law
2019-01-25 15:06 ` Jonathan Wakely
2019-01-29 19:07   ` Marek Polacek
2019-01-29 19:12     ` [EXT] " Romain GEISSLER
2019-01-29 19:18       ` Marek Polacek
2019-01-29 20:20         ` Jonathan Wakely
2019-02-04 12:08   ` Romain Geissler
  -- strict thread matches above, loose matches on Subject: below --
2016-06-24  4:11 Davide Italiano
2016-06-24  6:53 ` Davide Italiano
2016-07-04  4:39   ` Davide Italiano
2016-07-04 16:12     ` H.J. Lu
2016-07-04 19:58       ` Davide Italiano
2016-07-04 17:08     ` H.J. Lu
2016-07-04 19:37       ` Markus Trippelsdorf
2016-07-04 19:44         ` Davide Italiano
2016-07-04 19:58         ` Mike Stump
2016-07-07  0:52         ` Trevor Saunders
2016-07-04 17:14 ` H.J. Lu
2019-01-26 22:37 ` Segher Boessenkool
2019-01-29  1:49   ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).