TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How to Cross-Compile with Clang?

1 pointsby paulriddleover 5 years ago
From x86_64 to AArch64 on Linux. Without:<p><pre><code> - Relying on GCC, but glibc is ok. - Recompiling LLVM for AArch64. - Recompiling LLVM for x86_64 but during that compilation process using whatever is in clang&#x2F;cmake&#x2F;caches, so that runtime stuff like compiler-rt gets compiled for both x86_64 and AArch64. Without that. - Without using Zig. - Without using build setups based on CMake, Meson, Autotools, or Makefiles. </code></pre> I looked in many places but couldn&#x27;t find anything helpful. If you think you know how to do this but never done it, then you are probably wrong, it is not straightforward. To clarify why I want to do this:<p>1. LLVM toolchain can be used independetly of GCC, so even though I have a working GCC cross-compiler, I don&#x27;t want to use it to supply missing bits, because missing bits can be supplied in other ways. Missing bits are the linker, runtime library, libc++, libc++abi. I&#x27;m concerned only with C though.<p>2. Clang is a native cross-compiler, cross-compiling it to AArch64 is missing the point.<p>3. I&#x27;m NOT going to rebuild the whole LLVM monstrosity, it is impractical. It literally freezes my laptop for 1+ day. I aborted complitation. It is ok to recompile something small like compiler-rt but then the question is how to use in a non-hacky way because Clang keeps looking for complier-rt related stuff in it&#x27;s own directory as installed by my Linux distribution (Arch Linux by the way), and -L and -I flags do not help.<p>4. Zig can cross-compile C with just one option without any preparation but I don&#x27;t know how to pass flags to Clang via zig command line interface. For example I cant pass -O0.<p>5. These are useful for bigger projects, here I&#x27;m just interested in cross-compiling hello world.<p>Please do not give links to anything you might find in the official LLVM docs, youtube, first few pages of search engine results. I know about it.

no comments

no comments