fil-c README

README проекта с github.com/pizlonator/fil-c. Одним файлом markdown: README.md.

Fil-C 0.687

Fil-C is a fanatically compatible memory-safe implementation of C and C++. Lots of software compiles and runs with Fil-C with zero or minimal changes. All memory safety errors are caught as Fil-C panics. Fil-C achieves this using a combination of concurrent garbage collection and invisible capabilities (each pointer in memory has a corresponding capability, not visible to the C address space). Every fundamental C operation (as seen in LLVM IR) is checked against the capability. Fil-C has no unsafe statement and only limited FFI to unsafe code.

Fil-C is special because:

License

The compiler (clang + LLVM) is covered by LLVM-LICENSE.txt. The runtime is covered by PAS-LICENSE.txt (see libpas/LICENSE.txt in the source distribution). In the case of the classic musl-based Fil-C distribution, the musl libc is covered by MUSL-LICENSE.txt (see projects/yolomusl/COPYRIGHT and projects/usermusl/COPYRIGHT in the source distribution). For Peregrine Fil-C, the cosmo libc and APE machinery is covered by COSMO-LICENSE.txt (see projects/yolocosmo/LICENSE and projects/usercosmo/LICENSE in the source distribution). In the case of the /opt/fil distribution, glibc is covered by glibc-LICENSE.txt, and all other included programs are covered by the respective -LICENSE.txt files. The C++ libraries (libc++/libc++abi) are covered by LLVM-LICENSE.txt.

You can fetch the source for the compiler, runtime, libc++/libc++abi, libc (musl and glibc), and all included programs from github. The source distribution also includes many additional programs that have been ported to Fil-C in the projects/ and pizlix/ directories, and they have a variety of licenses. The /opt/fil distribution includes builds of a variety of additional programs and their licenses are in additional-licenses/ in that distribution.

Requirements

Fil-C works natively on Linux/X86_64 or Linux/ARM64.

Peregrine Fil-C uses APEs and a Cosmo-derived libs, which allows binaries it produces to run on Linux/X86_64, Darwin/ARM64, and Windows/X86_64. Peregrine Fil-C is still experimental and requires a Linux/x86_64 host to build.

Previous versions natively worked on Darwin/ARM64 and FreeBSD. At some point I switched to focusing on Linux because it allowed me to do a faithful job of implementing all of libc. There's nothing fundamentally stopping Fil-C from working natively on other architectures or OSes other than Linux. Patches welcome.

Getting Started

If you downloaded Fil-C binaries, run:

./setup.sh

This has a different effect depending on which binary distribution you selected:

If you downloaded Fil-C source, run:

./build_all_fast.sh

Then you'll be able to use Fil-C from within this directory.

The binary distribution of Fil-C comes with musl as the libc. Using ./build_all_fast.sh in the source distribution also builds Fil-C using musl. If you are using source, then you can also:

Things That Work

Lots of software packages work in Fil-C with zero or minimal changes, including big ones like openssl, CPython, SQLite, and many others. Fil-C is powerful enough to support a fully memory safe Linux userland.

Fil-C has full support for C and C++ plus almost all of the extensions that clang 20 supports. Fil-C has excellent support for atomics and SIMD intrinsics, for example.

Fil-C catches all of the stuff that makes memory safety in C hard, like:

Fil-C comes with a reasonably complete POSIX libc and even supports tricky features like threads, signal handling, mmap/munmap, longjmp/setjmp, and C++ exceptions.

Learn More

You can learn more about Fil-C by visiting the website.

You can also e-mail me: [email protected]

Follow me on Twitter.

File issues at GH.

fil-c (pizlonator/fil-c)

Ищем в базе…

3.9K ·GitHub
Что это такое?Fil-C — это реализация языков C и C++ с исключительно высокой совместимостью и защитой памяти: большая часть существующего ПО на C/C++ компилируется и работает на нём без изменений или почти без них, а каждое нарушение безопасности памяти перехватывается как паника Fil-C, а не тихо портит память.
Это санитайзер вроде AddressSanitizer или что-то более фундаментальное?Fil-C — это полноценный компилятор и среда выполнения, а не дополнительный санитайзер: это компилятор на основе clang/LLVM в паре с рантаймом на основе капабилити, который использует параллельную сборку мусора, поэтому каждый указатель несёт невидимую capability, проверяемую при каждом обращении. В отличие от AddressSanitizer, HWAsan или MTE, у него нет обходного лаза.
Как это запустить?Если вы скачали бинарный релиз, просто запустите ./setup.sh (он настраивает текущую директорию для сборки на musl или устанавливает в /opt/fil для сборки на glibc). Из исходников запустите ./buildallfast.sh, чтобы собрать рабочий тулчейн Fil-C прямо на месте.
Могу ли я перейти в небезопасный код, когда это нужно?Нет. В Fil-C нет ключевого слова unsafe, и компоновка с кодом, не относящимся к Fil-C, намеренно ограничена, поэтому нет лаза, через который можно было бы отключить его защиту памяти, как это позволяют другие языки с безопасной работой с памятью.
Какие платформы компилятор реально поддерживает?Fil-C сейчас работает только на Linux/x86-64 или Linux/ARM64. Более ранние версии поддерживали Darwin/ARM64 и FreeBSD, но разработка теперь сосредоточена исключительно на Linux.
Какое ПО уже удалось запустить на Fil-C?OpenSSL, CPython, SQLite и многие другие пакеты работают под Fil-C без изменений или почти без них, а дополнительные портированные программы находятся в директориях projects/ и pizlix/ исходного дистрибутива.
Чем Fil-C отличается от аппаратных capability CHERI?Fil-C достигает уровня безопасности, близкого к аппаратным capability вроде CHERI, но работает на обычном железе x86-64 или ARM64 и не требует специального процессора CHERI.
Поддерживает ли Fil-C исключения C++ и потоки?Да — в комплекте достаточно полная реализация POSIX libc с поддержкой потоков, обработки сигналов, mmap/munmap, longjmp/setjmp и исключений C++.
Какие есть похожие проекты?goose, zenc-lang, compiler, rust, mimalloc, gcc, solo, linux
Автор
pizlonator
Размер
4.1 GB
Звёзды
3.9K
Возраст
2 г
Коммиты · 90 дней