ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

"gold" linker should be replaced with another linker

Open stefantalpalaru opened this issue 1 year ago • 4 comments

The "gold" linker is being used on Linux, but Gentoo devs dropped support for it, after declaring it dead upstream: https://bugs.gentoo.org/936112

Replacing it with an external "lld" is as easy as:

diff '--color=auto' -ur pony-0.58.5.orig/src/libponyc/codegen/genexe.c pony-0.58.5/src/libponyc/codegen/genexe.c
--- pony-0.58.5.orig/src/libponyc/codegen/genexe.c	2024-07-15 22:32:04.539142266 +0200
+++ pony-0.58.5/src/libponyc/codegen/genexe.c	2024-07-15 22:35:08.622074939 +0200
@@ -349,7 +349,7 @@
   const char* mcx16_arg = (target_is_lp64(c->opt->triple)
     && target_is_x86(c->opt->triple)) ? "-mcx16" : "";
   const char* fuseldcmd = c->opt->link_ldcmd != NULL ? c->opt->link_ldcmd :
-    (target_is_linux(c->opt->triple) ? "gold" : "");
+    (target_is_linux(c->opt->triple) ? "lld" : "");
   const char* fuseld = strlen(fuseldcmd) ? "-fuse-ld=" : "";
   const char* ldl = target_is_linux(c->opt->triple) ? "-ldl" : "";
   const char* atomic =

This issue has been separated from the similarly named https://github.com/ponylang/ponyc/issues/1837

stefantalpalaru avatar Jul 16 '24 18:07 stefantalpalaru

I updated the title to be more general - to satisfy this ticket we just need to replace it with any working linker - not necessarily LLD.

Though the embedded LLD mentioned in the other ticket would be a nice touch - it would be a lot more work than the simple change you have above.

Whatever linker we select should be a widely available one, since we'd need to expect ponyc users to have it on their machines, as a dependency (unless we use an embedded LLD to completely remove the external dependency).

jemc avatar Jul 23 '24 18:07 jemc

Support for mold would be nice. I am using it with Rust, and it cuts compile times qiute significantly.

burjui avatar Aug 06 '24 09:08 burjui

@burjui if mold is a drop in replacement for gold then you should be able to use it now on any platform where we are using gold.

SeanTAllen avatar Aug 06 '24 12:08 SeanTAllen

Discussed in the sync call today.

It's unclear how "dead" gold actually is, and it's still present on all the Linux distros we currently build for. Unless/until it starts to get dropped by other distros we build for, this probably won't be a priority. Whatever default it gets replaced with would need to be something that is present on all the distros that we need.

Note that if you're running on a system where gold is not present, you can override the linker command with the CLI option --link-ldcmd. See the help string for ponyc for other CLI options.

jemc avatar Aug 06 '24 18:08 jemc

@jemc this is starting to roll out into the world now with new binutils packages as of 2.44 not including gold. We could fall back to the system linker. It's pretty straightfoward to do that and we have --link-ldcmd for setting a different linker.

It isn't the fastest for linking but, it is certainly the lowest common denominator.

SeanTAllen avatar May 05 '25 13:05 SeanTAllen