No announcement yet.

GCC 12 Adds Support For Using The Mold Linker

  • Filter
  • Time
  • Show
Clear All
new posts

  • GCC 12 Adds Support For Using The Mold Linker

    Phoronix: GCC 12 Adds Support For Using The Mold Linker

    A small but noteworthy change that landed today for the GCC 12 compiler itself is support for using the Mold linker...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    But first declining the patch ... But yeah, its good that it got merged.


    • #3
      Question, is GNU ld the same thing as Gold?


      • #4
        Originally posted by tildearrow View Post
        Question, is GNU ld the same thing as Gold?
        No. GNU ld AKA the BFD linker AKA ld.bfd is different from the Gold linker AKA An operating system typically has an ld symlink to the linker (.e.g. ld.bfd,, ld.lld. ld.mold, etc.)


        • #5
          Originally posted by atomsymbol

          $ ls -hlL /usr/bin/ld.*
          -rwxr-xr-x 2 root root 4.3M Sep 21 17:22 /usr/bin/ld.bfd
          -rwxr-xr-x 1 root root 12M Sep 21 17:22 /usr/bin/
          -rwxr-xr-x 1 root root 65k Nov 6 15:48 /usr/bin/ld.lld
          -rwxr-xr-x 1 root root 9.5M Dec 20 21:08 /usr/bin/ld.mold
          $ ld.bfd --version
          GNU ld 2.37
          $ --version
          GNU gold 1.16
          Interesting your size difference.
          [FONT=monospace][COLOR=#b218b2]❯[/COLOR][COLOR=#000000] [/COLOR][COLOR=#005fd7]ls[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00afff]-hlL[/COLOR][COLOR=#000000] [/COLOR][COLOR=#00afff]/usr/bin/ld.[/COLOR][COLOR=#00a6b2]*[/COLOR][COLOR=#000000] [/COLOR]
          -rwxr-xr-x 2 root root 2.8M Dec 28 19:04 [COLOR=#54ff54][B]/usr/bin/ld.bfd[/B][/COLOR][COLOR=#000000] [/COLOR]
          -rwxr-xr-x 1 root root 3.8M Dec 28 19:04 [COLOR=#54ff54][B]/usr/bin/[/B][/COLOR][COLOR=#000000] [/COLOR]
          -rwxr-xr-x 1 root root 5.8M Dec 28 19:48 [COLOR=#54ff54][B]/usr/bin/ld.lld[/B][/COLOR][COLOR=#000000] [/COLOR]
          -rwxr-xr-x 1 root root 3.6M Dec 29 19:59 [COLOR=#54ff54][B]/usr/bin/ld.mold[/B][/COLOR][/FONT]


          • #6
            This tests of speed are a little subjective, and to do a honest test, it would take quite a lot of work..
            The linker also has runtime.

            Depending on the distribution some library dependencies could be compiled statically, and so the linker will be faster to launch, since it has less dynamic linker activities to be done, and that will of-course influence the speed..

            In my case, I have small linker binaries, which means tons of shared libraries to link, when the linker runs(so will be slower, but uses less space in disk..):
            $ ls -lhH /usr/bin/ld.*
            -rwxr-xr-x 1 root root 1,7M fev 20 2021 /usr/bin/ld.bfd
            -rwxr-xr-x 1 root root 2,2M fev 20 2021 /usr/bin/


            • #7
              Does the use of different linkers influence the performance of the resulting binary when not using LTO?


              • #8
                Oh no, yet another attack on freedom! I can't wait to hear Stallman's tantrum on this one.


                • #9
                  Is there a runtime performance difference or is it all buildtime?


                  • #10
                    I'm having trouble building the kernel with gcc-12 from the ubuntu toolchains PPA.

                     CC /home/ph/kernel_main/build/linux-5.16-rc7/debian/build/build-generic/tools/objtool/check.o
                    check.c: In function ‘validate_call’:
                    check.c:2836:58: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
                    2836 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
                    | ^~
                    In function ‘call_dest_name’,
                    inlined from ‘call_dest_name’ at check.c:2824:27,
                    inlined from ‘validate_call’ at check.c:2908:3:
                    check.c:2836:50: note: directive argument in the range [-268435456, 268435455]
                    2836 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
                    If anyone knows how to fix, I'd appreciates.