Skip to content

Conversation

@redvers
Copy link
Contributor

@redvers redvers commented Dec 2, 2025

Changes required to support cross-compilation and static support.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 2, 2025
@redvers redvers changed the title Added musl specific path Adding cross-compilation and static support to embedded lld for linux. Dec 2, 2025
@redvers redvers removed the discuss during sync Should be discussed during an upcoming sync label Dec 2, 2025
@redvers
Copy link
Contributor Author

redvers commented Dec 2, 2025

Just making notes as I validate and explore:

  1. Appropriate distinguishing of -L and -rpath. Ensure that there are no -rpaths when -static.
  2. What about arguments that the previous execution to clang had that don't make sense for lld? For example, -mcx16?
  3. There is a divergence between the arguments that we have provided and those that clang generates internally.

Differences on my local workstation:

WIP implementation clang generation
-z relro
--hash-style=both --hash-style=gnu
--build-id
  1. --as-needed and --no-as-needed is implemented by clang but not us. Why? Does it matter?

  2. The logic that clang uses to locate the library paths and correct flags for lld to use for the various cases we have to deal with is located in clang/lib/Driver/ToolChains. It appears to "guess" the paths for things like the candidate GCC libraries in much the same way we do:

Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64

It may be a good idea to at least initially synchronize our search paths to the ones that they use for "least surprise".

  1. Adding ZLIB support to LLVM (required for x86-musl), seems to break all the things.
  2. arm64 Apple Darwin image does not seem to have zlib installed.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 2, 2025
@redvers
Copy link
Contributor Author

redvers commented Dec 4, 2025

The -fsanitize=address,undefined operation adds the following to the linker:

--whole-archive
/usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan_static-x86_64.a
--no-whole-archive
--whole-archive
/usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan-x86_64.a
--no-whole-archive
--dynamic-list=/usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan-x86_64.a.syms

Since it requires clang to be installed, this may not be worth the squeeze.

@redvers
Copy link
Contributor Author

redvers commented Dec 4, 2025

Going to merge this into the other PR:

TODO:
0. sanitize.

  1. Inventory and implement LLVM / Cross compilation environmental variables.
  2. Refactor and doc.
  3. Investigate how cross compilation works outside of CI to better understand.
  4. Consider ponyc flag to force to use legacy linker.

@redvers redvers merged commit 8105082 into ponylang:embedded-lld-as-linker-2 Dec 4, 2025
20 of 21 checks passed
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Dec 4, 2025
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

Successfully merging this pull request may close these issues.

2 participants