Originally posted by geearf
View Post
GCC 12 Adds Support For Using The Mold Linker
Collapse
X
-
Originally posted by CommunityMember View Post
Primarily the difference is link speed, which can matter a lot for CI functionality(*), and nearly nothing for the users of the resulting binary. There are, of course, edge cases where two linkers that happen to combine certain things in differnet orders may influence the performance on specific processor implementations, but those cases tend to be in the noise
Leave a comment:
-
-
Here is a patch, which works for GCC 11, for those who want to use a stable GCC.
Code:--- gcc/collect2.c +++ 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"; @@ -957,6 +959,8 @@ main (int argc, char **argv) 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 @@ -1283,7 +1287,7 @@ main (int argc, char **argv) else if (!use_collect_ld && startswith (arg, "-fuse-ld=")) { - /* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */ + /* Do not pass -fuse-ld={bfd|gold|lld|mold} to the linker. */ ld1--; ld2--; } --- gcc/common.opt +++ 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) --- gcc/gcc.c +++ 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; --- gcc/opts.c +++ gcc/opts.c @@ -3094,6 +3094,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;
Leave a comment:
-
-
Originally posted by kiffmet View PostDoes the use of different linkers influence the performance of the resulting binary when not using LTO?
(*) And for some projects, that is a lot of linking (every commit is built and tested across dozens of platforms), which can use lots of resources even before first release/deployment, and delay feedback to developers (and developers hate waiting for feedback, except for those wanting to slack off and do some chair sword play: https://xkcd.com/303/ )
Leave a comment:
-
-
Originally posted by cl333r View PostThe /usr/bin/ld symlink chain on my Ubuntu PC:
Screenshot_20211230_044415.png
So, ld => x86_64-linux-gnu-ld => x86_64-linux-gnu-ld.bfd
PS: is there any phoronix option to avoid the downsizing the uploaded image like this?
Leave a comment:
-
-
Originally posted by brad0 View Post
No. GNU ld AKA the BFD linker AKA ld.bfd is different from the Gold linker AKA ld.gold. An operating system typically has an ld symlink to the linker (.e.g. ld.bfd, ld.gold, ld.lld. ld.mold, etc.)
Screenshot_20211230_044415.png
So, ld => x86_64-linux-gnu-ld => x86_64-linux-gnu-ld.bfd
PS: is there any phoronix option to avoid the downsizing the uploaded image like this?Last edited by cl333r; 29 December 2021, 10:51 PM.
Leave a comment:
-
-
I'm having trouble building the kernel with gcc-12 from the ubuntu toolchains PPA.
Code: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);
Leave a comment:
-
-
Oh no, yet another attack on freedom! I can't wait to hear Stallman's tantrum on this one.
Leave a comment:
-
Leave a comment: