ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.68k stars 410 forks source link

"gold" linker should be replaced with another linker #4521

Open stefantalpalaru opened 2 months ago

stefantalpalaru commented 2 months ago

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

jemc commented 1 month ago

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).

burjui commented 1 month ago

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

SeanTAllen commented 1 month ago

@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.

jemc commented 1 month ago

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.