Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mold wiki: patching gcc:11.2.1_p20220115 [won't fix]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Thu Feb 10, 2022 1:35 pm    Post subject: mold wiki: patching gcc:11.2.1_p20220115 [won't fix] Reply with quote

wiki mentions sys-devel/gcc-11.2.1_p20211127 has to be patched as described.
EDIT: patch link doesn't seems to work here... :oops:
Currenty testing gcc-12 upstream commit at patching phase...

It doesn't say anything about later version...

gentoo gcc-git doesn't show anything in this respect.

But building gcc takes a kong time here, so I'd rather ask first.

Does anyone knows?

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.


Last edited by CaptainBlood on Fri Feb 11, 2022 9:29 am; edited 4 times in total
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Thu Feb 10, 2022 3:32 pm    Post subject: Reply with quote

Code:
diff -Naur ~/mold.patch /etc/portage/patches/sys-devel/gcc-11.2.1_p20220115/mold.patch
--- /root/mold.patch   2022-02-10 18:21:00.409413589 +0300
+++ /etc/portage/patches/sys-devel/gcc-11.2.1_p20220115/mold.patch   2022-02-10 18:23:32.979408061 +0300
@@ -46,7 +46,7 @@
       selected_linker = USE_LLD_LD;
 +   else if (strcmp (argv[i], "-fuse-ld=mold") == 0)
 +     selected_linker = USE_MOLD_LD;
-    else if (startswith (argv[i], "-o"))
+    else if (strncmp (argv[i], "-o", 2) == 0)
       {
         /* Parse the output filename if it's given so that we can make
 @@ -1048,7 +1052,7 @@ main (int argc, char **argv)
to patch above upstream git linked patch.

Currently building :).

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Thu Feb 10, 2022 11:50 pm    Post subject: Reply with quote

Testing fails getting stuck at
Code:
checking whether the C compiler works
Any idea welcome...
Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Fri Feb 11, 2022 9:14 am    Post subject: Reply with quote

As an example, trying to compile sys-apps/less, ps shows
Code:
grep mold
0   250 10365 10364  11  -9   4668  2676 ?      S<+  pts/0      0:00 x86_64-pc-linux-gnu-gcc -march=skylake -O2 -pipe -Wa,-mbranches-within-32B-boundaries -Wl,-O1 -Wl,-fuse-ld=mold conftest.c
0   250 10368 10365  11  -9   3996  2100 ?      S<+  pts/0      0:00 /usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/collect2 -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/lto-wrapper -plugin-opt=-fresolution=/var/tmp/portage/sys-apps/less-590/temp/ccWluawm.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../.. -O1 -fuse-ld=mold /var/tmp/portage/sys-apps/less-590/temp/ccy1qrZX.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64/crtn.o
0   250 10369 10368  11  -9  12520  2668 ?      S<+  pts/0      0:00 /usr/bin/ld.mold -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/lto-wrapper -plugin-opt=-fresolution=/var/tmp/portage/sys-apps/less-590/temp/ccWluawm.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../.. -O1 /var/tmp/portage/sys-apps/less-590/temp/ccy1qrZX.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/../../../../lib64/crtn.o
later shown command line remains stuck for ever...

According to man, mold doesn't have -plugin option.
Seconfly, -flto not activated here, i.e. at user level.

Any idea how to progress here?

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Fri Feb 11, 2022 9:25 am    Post subject: Reply with quote

Lol
Falling back to unpatched gcc:11 works fine here.
That may be the reason why the patch referenced by wiki doesn't exist anymore.

Carrying on testign mold here.

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Fri Feb 11, 2022 10:00 am    Post subject: Reply with quote

Much too much optimistic here,

uptream patches for mold

Previous post only reports patch patching for 2021-12-29.

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
Back to top
View user's profile Send private message
awilum
n00b
n00b


Joined: 04 Feb 2020
Posts: 3

PostPosted: Mon Jun 27, 2022 4:14 pm    Post subject: Reply with quote

This is my patch for gcc to use -fuse-mold, I made some little changes from the original, it works with gcc-11.2.1_p20220115 & gcc-1.3.0

Put it in the directory /etc/portage/patches/sys-devel/{gcc-11.2.1_p20220115|gcc-11.3.0}

fuse-ld-mold.patch:
Code:

From ad964f7eaef9c03ce68a01cfdd7fde9d56524868 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 21 Dec 2021 17:43:55 +0100
Subject: [PATCH] Support ld.mold linker.

gcc/ChangeLog:

        * collect2.c (main): Add ld.mold.
        * common.opt: Add -fuse-ld=mold.
        * doc/invoke.texi: Document it.
        * gcc.c (driver_handle_option): Handle -fuse-ld=mold.
        * opts.c (common_handle_option): Likewise.
---
 gcc/collect2.c      | 10 +++++++---
 gcc/common.opt      |  4 ++++
 gcc/doc/invoke.texi |  4 ++++
 gcc/gcc.c           |  4 ++++
 gcc/opts.c          |  1 +
 5 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index d47fe3f91959c..b322527847c70 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -776,6 +776,7 @@ main (int argc, char **argv)
       USE_GOLD_LD,
       USE_BFD_LD,
       USE_LLD_LD,
+      USE_MOLD_LD,
       USE_LD_MAX
     } selected_linker = USE_DEFAULT_LD;
   static const char *const ld_suffixes[USE_LD_MAX] =
@@ -784,7 +785,8 @@ main (int argc, char **argv)
       PLUGIN_LD_SUFFIX,
       "ld.gold",
       "ld.bfd",
-      "ld.lld"
+      "ld.lld",
+      "ld.mold"
     };
   static const char *const real_ld_suffix = "real-ld";
   static const char *const collect_ld_suffix = "collect-ld";
@@ -970,6 +970,8 @@
          selected_linker = USE_GOLD_LD;
        else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
          selected_linker = USE_LLD_LD;
+       else if (strcmp (argv[i], "-fuse-ld=mold") == 0)
+         selected_linker = USE_MOLD_LD;
        else if (strncmp (argv[i], "-o", 2) == 0)
          {
            /* Parse the output filename if it's given so that we can make
@@ -1048,7 +1052,7 @@ main (int argc, char **argv)
   ld_file_name = 0;
 #ifdef DEFAULT_LINKER
   if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD ||
-      selected_linker == USE_LLD_LD)
+      selected_linker == USE_LLD_LD || selected_linker == USE_MOLD_LD)
     {
       char *linker_name;
 # ifdef HOST_EXECUTABLE_SUFFIX
@@ -1317,7 +1319,7 @@
              else if (!use_collect_ld
                       && strncmp (arg, "-fuse-ld=", 9) == 0)
                {
-                 /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
+                 /* Do not pass -fuse-ld={bfd|gold|lld|mold} to the linker. */
                  ld1--;
                  ld2--;
                }
diff --git a/gcc/common.opt b/gcc/common.opt
index 2ed818d6057de..dba3fa886f9c6 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3046,6 +3046,10 @@ fuse-ld=lld
 Common Driver Negative(fuse-ld=lld)
 Use the lld LLVM linker instead of the default linker.
 
+fuse-ld=mold
+Common Driver Negative(fuse-ld=mold)
+Use the Modern linker (MOLD) linker instead of the default linker.
+
 fuse-linker-plugin
 Common Undocumented Var(flag_use_linker_plugin)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e644c63767b88..54fa75ba138ea 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -16266,6 +16266,10 @@ Use the @command{gold} linker instead of the default linker.
 @opindex fuse-ld=lld
 Use the LLVM @command{lld} linker instead of the default linker.
 
+@item -fuse-ld=mold
+@opindex fuse-ld=mold
+Use the Modern Linker (@command{mold}) instead of the default linker.
+
 @cindex Libraries
 @item -l@var{library}
 @itemx -l @var{library}
diff --git a/gcc/gcc.c b/gcc/gcc.c
index b75b50b87b2bf..06e18a75b52cc 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4282,6 +4282,10 @@ driver_handle_option (struct gcc_options *opts,
        use_ld = ".gold";
        break;
 
+    case OPT_fuse_ld_mold:
+       use_ld = ".mold";
+       break;
+
     case OPT_fcompare_debug_second:
       compare_debug_second = 1;
       break;
diff --git a/gcc/opts.c b/gcc/opts.c
index e4e47ff77b3d7..f820052307c36 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3105,6 +3105,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_ld_mold:
     case OPT_fuse_linker_plugin:
       /* No-op. Used by the driver and passed to us because it starts with f.*/
       break;


Best regards.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3595

PostPosted: Mon Jun 27, 2022 9:04 pm    Post subject: Reply with quote

Awilum,
Interesting...
Sadly, currently building latest gcc-12.1.p20220625 on a low-end 4Gb desktop, with two curious failures caused by user level outrage,
the one from in between the chair & the kerboard. Pity me ;).

Placing the patch in position still, waiting for the next upgrade.
It will be mainly for testing as lto is slowly spreading here & I'm unsure mold is at level with alternative there.

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum