Stream: ideas

Topic: Switch legacy linker to `.a` files


view this post on Zulip Brendan Hansknecht (Nov 05 2023 at 22:29):

Currently the legacy linker expects .o object files. I think we should switch it to .a files.

A .a is just an archive that contains one of more .o files. It is strictly more flexible.

This comes up for example when you have a platform that depends on a static lib. You can move the platform .o and the static library .a file into a single larger .a file. That puts all dependencies into a single distributable file.

To generate a .a from a .o is just a matter of calling ar and most compilers probably can generate the .a directly.

If wanted, we could leave in a fallback check to use the .o file if the .a doesn't exist.

Thoughts?

view this post on Zulip Richard Feldman (Nov 05 2023 at 22:31):

I don't have strong feelings, other than generally wanting to drop the legacy linker as soon as we can :big_smile:

view this post on Zulip Brendan Hansknecht (Nov 05 2023 at 22:32):

That's fair, but I think this will enable some interesting platforms. For example, @Luke Boswell is messing with statically linking SDL2, where this came up.

view this post on Zulip Brendan Hansknecht (Nov 05 2023 at 22:33):

Seems trivial enough to fix that it is worth just quickly patching.

view this post on Zulip Luke Boswell (Nov 05 2023 at 22:40):

Yes please. It would be really useful to be able to package SDL2 and users not have to have the dylib already installed on their system. So just roc run myApp.roc and everything just works.

view this post on Zulip Richard Feldman (Nov 05 2023 at 23:20):

works for me! :thumbs_up:

view this post on Zulip Brendan Hansknecht (Nov 05 2023 at 23:24):

Also, I think I'll leave it as .o as fallback to avoid any need to update existing platforms.


Last updated: Jun 16 2026 at 16:19 UTC