Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gold / lld support for parallel linking #57

Open
rojer opened this issue May 29, 2024 · 9 comments
Open

gold / lld support for parallel linking #57

rojer opened this issue May 29, 2024 · 9 comments

Comments

@rojer
Copy link

rojer commented May 29, 2024

Linking phase is taking substantial amount of time on larger projects, it would be great to get support for -fuse-ld=gold and/or -fuse-ld=lld, both of which support parallel linking and are much faster than the default BFD linker.

@rojer
Copy link
Author

rojer commented May 29, 2024

@igrr how feasible is this?

i took a quick stab at gold support and found:

  • --dynconfig is not supported - not sure how big of a deal this is at linking stage
  • --no-warn-rwx-segments is not supported - probably minor
  • REGION_ALIAS linker script function is not supported. a bit annoying, but can be worked around with some linker script changes.

after that i ran into "unsupported ELF machine" error (i was using an amd64 build of gold, so not surpirsing)

@Lapshin
Copy link
Collaborator

Lapshin commented Jun 10, 2024

@rojer , gold has no xtensa support yet. It could not process required xtensa-specific relocations until not implemented. It will likely not get it due to very low priority.

@rojer
Copy link
Author

rojer commented Jun 10, 2024

ok, what about lld? for our app, it's not uncommon for linking to take 5-15 seconds (depending on hardware). fast incremental builds (1 source file change) are important for developer productivity and currently linking is the biggest factor here.

@Lapshin
Copy link
Collaborator

Lapshin commented Jun 10, 2024

@rojer , you can refer to LLVM project (but it is not stable yet). Seems LLD is supported for versions greater than esp-15.0.0-20221201. (See espressif/llvm-project#53)

@rojer
Copy link
Author

rojer commented Jun 10, 2024

ok, does this mean that it can be integrated into IDF as an option, or even the default? i'm looking at the toolchain distribution archive and not sure if the xtensa or risc-v variant is included, i only see amd64 and wasm variants (ld64.lld and wasm-ld):

[rojer@nbf ~/allterco/esp-idf 5.2.1-s2]$ tar tvf llvm-esp-16.0.0-20230516-linux-amd64.tar.xz | grep 'lld'
lrwxrwxrwx root/root         0 2023-05-17 10:58 esp-clang/bin/ld.lld -> lld
-rwxr-xr-x root/root   5296448 2023-05-17 10:58 esp-clang/bin/lld
lrwxrwxrwx root/root         0 2023-05-17 10:58 esp-clang/bin/lld-link -> lld
lrwxrwxrwx root/root         0 2023-05-17 10:58 esp-clang/bin/wasm-ld -> lld
lrwxrwxrwx root/root         0 2023-05-17 10:58 esp-clang/bin/ld64.lld -> lld
[rojer@nbf ~/allterco/esp-idf 5.2.1-s2]$ tar tvf clang-esp-17.0.1_20240419-x86_64-linux-gnu.tar.xz | grep 'lld'
lrwxrwxrwx root/root         0 2024-04-19 23:27 esp-clang/bin/lld-link -> lld
lrwxrwxrwx root/root         0 2024-04-19 23:27 esp-clang/bin/ld.lld -> lld
-rwxr-xr-x root/root  67654984 2024-04-19 22:54 esp-clang/bin/lld
lrwxrwxrwx root/root         0 2024-04-19 23:27 esp-clang/bin/ld64.lld -> lld
lrwxrwxrwx root/root         0 2024-04-19 23:27 esp-clang/bin/wasm-ld -> lld

@Lapshin
Copy link
Collaborator

Lapshin commented Jun 11, 2024

@gerekon PTAL

@gerekon
Copy link
Collaborator

gerekon commented Jun 12, 2024

@rojer LLD supplied with Espressif Clang toolchain supports Xtensa and RISCV archs, but it has some issues.

  1. For Xtensa it includes preliminary support and still has some issues with building IDF apps.
  2. RISCV support comes from the upstream, but again there are some issues with building IDF apps.

Currently we are working on fixing IDF builds with LLD for RISCV chips. Hopefully it will get into the next release.
After that we will start working on issues related to IDF builds with LLD for Xtensa chips.

@gerekon
Copy link
Collaborator

gerekon commented Jun 12, 2024

@rojer But note, that Xtensa support in Clang itself is not optimal as of now (code size and perf), e.g. direct calls are not implemented yet. espressif/llvm-project#90. So it seems to be early to switch to Clang toolchain completely. May be we can find a way to use LLD with GCC as an option.

@rojer
Copy link
Author

rojer commented Jun 12, 2024

oh yes, clang is hopeless in -Os mode, 30% bigger code or so last i checked.
what i was hoping for was to compile gcc and link with lld.

ok, thank you for the update, please know that this is eagerly awaited :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants