Re: LLVM-libc FreeBSD Port
Seigo Tanimura <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.hackers |
|---|---|
| Message-ID | <CAJ=YaSDeZ+9Gu-R3z-J2W7b5_7YxoKyP5bnxVWhgRzWzZgnFwQ@mail.gmail.com> |
Hello Schrodinger, Some personal insights out of porting LLVM BOLT instrumentation to FreeBSD: (I have been working on it for about a month merely for my own interest) There are at least two usages of the system calls in the LLVM-generated codes, namely: - LLVM libc - Instrumentation (my work, mainly for profiling) For the instrumentation usage, I have implemented the mostly-assembly system call library PoC with the common and architecture/OS-dependent parts separated somehow. As of now, it builds and runs on FreeBSD and Linux, amd64 and arm64. (NB I cannot publish the PoC right now because I am out of my town for now) To my belief, such the library works because it is not a generic library. It is sufficient to only support the system calls required for profiling, mainly the file I/O, mmap(2) and alikes. They are almost completely defined by POSIX and hence easy. Even under this constraint, some system calls require special care, e.g. open(2) implemented as the call to openat(2), and the Linux-only *64() system calls. Having said above, it would be great if LLVM had the common instrumentation library for the profiling code. Not only that such the library has to deal with the problem more controllable than libc, but also it has the clear and present benefit, i.e. optimization. Best regards, -- Seigo Tanimura <[email protected]> Den sön 10 maj 2026 22:17Schrodinger ZHU Yifan <[email protected]> skrev: > The existing PR was really just a PoC. > > As for syscall stubs, it depends on the recommended method from the Oses. > I can try to come up with a libsys version if that is the suggested way to > do it. > > On Linux, we also have a separated syscall_wrapper module; but that is > more like a header library. > > Yifan > > > [image: image] > Schrodinger ZHU Yifan, Ph.D. Student > Computer Science Department, University of Rochester > > *Personal Email:* [email protected] > *Work Email:* [email protected] > *Website:* https://www.cs.rochester.edu/~yzhu104/Main.html > *Github:* SchrodingerZhu > *GPG Fingerprint:* BA02CBEB8CB5D8181E9368304D2CC545A78DBCC3 > > > Sent from Proton Mail <https://proton.me/mail/home> for iOS. > > > -------- Original Message -------- > On Sunday, 05/10/26 at 21:35 Minsoo Choo <[email protected]> wrote: > > On Sunday, May 10th, 2026 at 3:37 PM, Schrodinger ZHU Yifan <[email protected]> > wrote: > > Hi all, > > I am one of the maintainers of LLVM libc, mainly responsible for its > threading support, and I currently daily drive FreeBSD. > > LLVM libc is a from-scratch implementation of the C standard library > developed as part of the LLVM project. It is designed to be modular, so > individual components can be used independently; multiplatform, targeting > Linux, GPUs, bare-metal embedded systems, UEFI, macOS, Windows, and more; > and written in modern C++ with a focus on correctness, performance, and > safety. See also https://libc.llvm.org/ . > > We recently had a casual discussion on our Discord about bringing up > FreeBSD support. This would be an interesting step toward broadening LLVM > libc’s perspective from Linux-only to more general *nix portability, which > should also help improve its overall structure. The initial bring-up was > fairly straightforward (the PR is a bit outdated but can be fixed without > much effort): https://github.com/llvm/llvm-project/pull/124459. This > already delivers LLVM libc’s correctly rounded math and mathvec support to > FreeBSD. > > However, moving toward completeness will require more work. We would also > need CI pipelines and stable maintainers before FreeBSD could be added to > the list of supported platforms. > > Personally, I think bringing a modular libc design with modern features > that continue to evolve rapidly would also be a plus for the FreeBSD > community, especially given FreeBSD’s close relationship with LLVM. If > anyone is interested, please feel free to ping me at i [at] zhuyi [dot] fan. > > By the way, the Discord link on your website appears to be broken. > > Best, > Yifan > > > [image: image] > Schrodinger ZHU Yifan, Ph.D. Student > Computer Science Department, University of Rochester > > *Personal Email:* [email protected] > *Work Email:* [email protected] > *Github:* SchrodingerZhu > > > Hi Schrodinger, > > Glad to hear that you are working on this project. I'm working on LLDB for > FreeBSD, so feel free to reach me out if you have any questions on FreeBSD. > > So I want to clarify here: LLVM's libc has its own header and > implementation, so it is possible to compile FreeBSD libc on other OSes, > right? This also means llvm's libc doesn't use our libsys library but has > its own syscall assemblies, which I see from your GitHub PR. > > -- > Minsoo Choo > >