{"id":25917333,"url":"https://github.com/dslm4515/CMLFS","last_synced_at":"2025-03-03T14:01:27.946Z","repository":{"id":44335567,"uuid":"355317044","full_name":"dslm4515/CMLFS","owner":"dslm4515","description":"Clang-Built Musl Linux From Scratch ","archived":false,"fork":false,"pushed_at":"2024-05-25T23:02:14.000Z","size":4463,"stargazers_count":99,"open_issues_count":12,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-02T11:04:15.964Z","etag":null,"topics":["clang","lfs","llvm","musl","musl-libc"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dslm4515.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-06T20:09:23.000Z","updated_at":"2024-06-23T14:39:29.000Z","dependencies_parsed_at":"2023-10-11T04:56:53.548Z","dependency_job_id":"4ee00741-ea1d-40d2-a451-e14a6de7d692","html_url":"https://github.com/dslm4515/CMLFS","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dslm4515%2FCMLFS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dslm4515%2FCMLFS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dslm4515%2FCMLFS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dslm4515%2FCMLFS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dslm4515","download_url":"https://codeload.github.com/dslm4515/CMLFS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241678151,"owners_count":20001682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","lfs","llvm","musl","musl-libc"],"created_at":"2025-03-03T14:00:41.449Z","updated_at":"2025-03-03T14:01:27.915Z","avatar_url":"https://github.com/dslm4515.png","language":"Shell","funding_links":[],"categories":["Active","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# CMLFS - Clang Musl Linux From Scratch\n\nCMLFS can either mean \"Clang-built Musl Linux from Scratch\" or \"Clang MLFS\". It started as a hobby to see if a Linux system can be built with clang as primary toolchain and GCC as secondary (for packages that cannot be built with clang). This is based on [Linux From Scratch](www.linuxfromscratch.org) and my previous work [MLFS](https://github.com/dslm4515/Musl-LFS). Big thanks to [Chimera-Linux](https://chimera-linux.org) that had patches that fixed a lot of issues.\n\n## DISCLAIMER\n\nUse at you own risk. This builds a Unix-like system that may not be stable enough as a 'daily driver' for most users. Security-hardening of the built system is beyound the scope of this project. This repo started as means to backup and archive my work.\n\n## Getting Started\n\nThe master branch may be unstable when I am working on upgrading CMLFS. \n\nTo build this project, pick a branch other than master OR choose a tag. Each branch \u0026 tag are based on the LLVM version.\nAs of this writing, llvm-15.0.6 is stable. Older branches maybe incomplete or unstable (may not compile).\n\nWhen I have time later, I will write a more thorough introduction for users new to CMLFS.\n\n## Specification\n\u003cul\u003e\n\u003cli\u003eC Runtime Library (system libc): Musl \u003c/li\u003e\n\u003cli\u003eDefault C Compiler: clang (LLVM)\u003c/li\u003e\n\u003cli\u003eDefault C++ compiler: clang++ (LLVM)\u003c/li\u003e\n\u003cli\u003eDefault linker: lld (LLVM)\u003c/li\u003e\n\u003cli\u003eDefault binary tools: elftoolchain\u003c/li\u003e\n\u003cli\u003eSecondary C Compiler: GCC\u003c/li\u003e\n\u003cli\u003eSecondary C++ compiler: GCC\u003c/li\u003e\n\u003cli\u003eSecondary binary tools: GNU Binutils \u0026 LLVM\u003c/li\u003e\n\u003cli\u003eSecondary linker(s): bfd, gold\u003c/li\u003e\n\u003cli\u003eC++ standard library: libcxx (LLVM)\u003c/li\u003e\n\u003cli\u003eC++ ABI library: libcxxabi (LLVM)\u003c/li\u003e\n\u003cli\u003eUnwinding Library: libunwind (LLVM)\u003c/li\u003e\n\u003cli\u003eInit system: skarnet's S6 \u0026 S6-rc\u003c/li\u003e\n\u003cli\u003eDevice manager: Udev \u003c/li\u003e\n\u003cli\u003eTLS Implementaion: LibreSSL\u003c/li\u003e\n\u003cli\u003eSecondary TLS Implementaion: OpenSSL\u003c/li\u003e\n\u003cli\u003eSystem Shell: Bash \u003c/li\u003e\n\u003cli\u003eSystem Gettext: gettext-tiny\u003c/li\u003e\n\u003cli\u003eCurses Library: netbsd-curses \u003c/li\u003e\n\u003c/ul\u003e\n\n## Supported Architectures\n\n\u003cul\u003e\n\u003cli\u003eAMD64/x86_64: Toolchains and final system build sucessfully (musl \u0026 glibc hosts) .\u003c/li\u003e\n\u003cli\u003ei686: Pending\u003c/li\u003e\n\u003cli\u003eAARCH64/ARM64: Pending\u003c/li\u003e\n\u003cli\u003eARMV7L: Pending\u003c/li\u003e\n\u003c/ul\u003e\n\n## Goals\n\n\u003cul\u003e\n\u003cli\u003e [x] Build a toolchain (llvmtools) with LLVM+stage1_clang but without GCC\u003c/li\u003e\n\u003cli\u003e [x] Build final root filesystem with LLVM\u003c/li\u003e\n\u003cli\u003e [x] Set default linker as lld(LLVM)\u003c/li\u003e\n\u003cli\u003e [x] Set default C++ standard library as libcxx(LLVM)\u003c/li\u003e\n\u003cli\u003e [x] Set default C++ ABI library as libcxxabi(LLVM)\u003c/li\u003e\n\u003cli\u003e [x] Set default stack unwinding library as libunwind(LLVM)\u003c/li\u003e\n\u003cli\u003e [x] Eliminate dependacy on GCC's libgcc_s\u003c/li\u003e\n\u003cli\u003e [x] Build GCC as a secondary systen compiler. \u003c/li\u003e\n\u003cli\u003e [x] Build toolchain (llvmtools) with GCC as secondary compiler\u003c/li\u003e\n\u003cli\u003e [x] Merge cross-tools build with cgnutools \u003c/li\u003e\n\u003cli\u003e [x] Build successfully on a Glibc host \u003c/li\u003e\n\u003cli\u003e [x] Build final system without GCC \u003c/li\u003e\n\u003cli\u003e [x] Replace binutils with elftoolchain \u003c/li\u003e\n\u003cli\u003e [ ] Reduce LLVM size \u0026 build time for cgnutools and llvmtools \u003c/li\u003e\n\u003cli\u003e [ ] Create initramfs with busybox \u0026 mdev \u003c/li\u003e\n\u003cli\u003e [ ] Build on aarch64\u003c/li\u003e\n\u003c/ul\u003e\n\n## Host System Requirements\n\n\u003cul\u003e\n \u003cli\u003eCMake\u003c/li\u003e\n \u003cli\u003eNinja/Samurai\u003c/li\u003e\n \u003cli\u003ewget/cURL\u003c/li\u003e\n\u003c/ul\u003e\n\n## Required Base Development tools (may refer to LFS)\n\u003cul\u003e\n \u003cli\u003ebash 3.2 (/bin/sh should be a symbolic or hard link to bash) \u003c/li\u003e\n \u003cli\u003ebinutils 2.25 \u003c/li\u003e\n \u003cli\u003ebison 2.7 (/usr/bin/yacc should be a link to bison or small script that executes bison) \u003c/li\u003e\n \u003cli\u003ebzip2 1.0.4 \u003c/li\u003e\n \u003cli\u003ecoreutils 6.9 \u003c/li\u003e\n \u003cli\u003ediffutils 2.8.1 \u003c/li\u003e\n \u003cli\u003efindutils 4.2.31 \u003c/li\u003e\n \u003cli\u003egawk 4.0.1 (/usr/bin/awk should be a link to gawk) \u003c/li\u003e\n \u003cli\u003eGCC 6.2 (including the C++ compiler, g++) \u003c/li\u003e\n \u003cli\u003eGlibc 2.11 / Musl Libc 1.20 \u003c/li\u003e\n \u003cli\u003eGrep 2.5.1a \u003c/li\u003e\n \u003cli\u003egzip 1.3.12 \u003c/li\u003e\n \u003cli\u003elinux kernel 3.2 (not sure if it matters, as most distros are running 4.x/5.x kernels\u003c/li\u003e\n \u003cli\u003em4 1.4.10\u003c/li\u003e\n \u003cli\u003emake 4.0 \u003c/li\u003e\n \u003cli\u003epatch 2.5.4 \u003c/li\u003e\n \u003cli\u003ePython 3.4 \u003c/li\u003e\n \u003cli\u003esed 4.1.5 \u003c/li\u003e\n \u003cli\u003etar 1.22 \u003c/li\u003e\n \u003cli\u003etexinfo 4.7 \u003c/li\u003e\n  \u003cli\u003exz 5.0.0 \u003c/li\u003e\n\u003c/ul\u003e\n * (if hostdistro is MLFS/LFS, then all development packages are installed)\n\n## Current Method\n\nBuild 'cross-tools' with [Mussel](https://github.com/firasuke/mussel) to cross-compile a stage0 LLVM+clang. This stage0 clang will still link to `libgcc_s` [in cgnutools] but will later be used to build a stage1 clang free of `libbgcc_s`. The goal is to build clang+friends with clang and not GCC.\n\n* Some packages can be built once to be used by the toolchain [llvmtools] and the final system, but will be built twice to make it easy to implement a package managment system [which is outside the scope of this project]. \n\n\u003col\u003e\n\u003cli\u003eBootstrap build of cgnutools with mussel\u003c/li\u003e\n\u003cli\u003eUse mussel-built toolchain (cgnutools) to build stage0 LLVM+clang\u003c/li\u003e\n\u003cli\u003eUse cgnutools to build stage1 LLVM+clang with sysroot at llvmtools with stage0 LLVM+clang\u003c/li\u003e\n\u003cli\u003eBuild enough of llvmtools to enter a chroot with stage1 LLVM+clang\u003c/li\u003e\n\u003cli\u003eBuild the rest of llvmtools under chroot \u003c/li\u003e\n\u003cli\u003eBuild final system with llvmtools \u003c/li\u003e\n\u003c/ol\u003e\n\n## Issues\n\u003cul\u003e\n\u003cli\u003eTest for C++11/14 fails when testing stage0 \u0026 stage1 LLVM's. Not sure what issue this will cause or if test needs to be revised..\u003c/li\u003e\n\u003cli\u003eCoreutils will not build for llvmtools under 32-bit x86 (i386/i586/i686)\u003c/li\u003e\n\u003cli\u003eNinja for llvmtools fails to compile with python3. For now use cmake instead of python3\u003c/li\u003e \n\u003c/ul\u003e\n\n## Change log\n\n\u003cul\u003e\n\u003cli\u003e4.0.0: Upgraded to LLVM 17.0.5 \u003c/li\u003e\n\u003cli\u003e3.0.0: Upgraded to LLVM-15.0.6. cgnutools is now bootstrapped with mussel. Replaced binutils with elftoolchain. Most of llvmtools will be build under chroot to avoid contamination from host. \u003c/li\u003e\n\u003cli\u003e2.0.0: Upgraded to LLVM-12.0.0. Upgraded GCC to 10.3.1-x Replace ninja with samurai. Replace zlib with zlib-ng. Patched elfutils to build libelf under clang. No longer using /llvmtools/gnu and /opt/gnu.\u003c/li\u003e\n\u003cli\u003e1.2.0: Incomplete: LLVM-11.0.0, Install GCC \u0026 Binutils in /llvmtools \u0026 /usr instead of /llvmtools/gnu and /opt/gnu \u003c/li\u003e\n\u003cli\u003e1.1.0: Sucessfully merged cross-tools and cgnutools to include GCC \u0026 binutils.\u003c/li\u003e\n\u003cli\u003e1.0.0: Sucessfully built on x86_64. GCC built as secondary compiler in /opt/gnu \u003c/li\u003e\n\u003cli\u003e0.1.3: Configure Stage1 clang correctly with x86_64-pc-linux-musl.cfg.\u003c/li\u003e\n\u003cli\u003e0.1.2: Use stage0 to build a stage1 clang...Stage1 clang will be used in chroot. Stage1 clang fails to compile\u003c/li\u003e\n\u003cli\u003e0.1.1: Build stage0 clang by building clang, lld, compiler-rt, libunwind, libcxxabi, libcxx together in llvm source tree. Stage0 builds binaries with host's dynamic linker in /lib\u003c/li\u003e\n\u003cli\u003e0.1.0: Build cross-tools with GCC to build stage 1 clang... first build libunwind, libcxxabi \u0026 libcxx - stage1 Clang broken\u003c/li\u003e\n\u003cli\u003e0.0.0: First attempt, modeled afer Genshen's repo: Stage 2 clang fails to build.\u003c/li\u003e\n\u003c/ul\u003e\n\n## Projects of Interest\n\u003cul\u003e\n\u003cli\u003e [Mussel](https://github.com/firasuke/mussel)\u003c/li\u003e\n\u003cli\u003e [Musl Linux From Scratch](https://github.com/dslm4515/Musl-LFS) - Based on LFS, but uses Musl instead of Glibc \u003c/li\u003e\n\u003cli\u003e [Beyond MLFS](https://github.com/dslm4515/BMLFS) - The Musl version of LFS's BLFS \u003c/li\u003e\n\u003cli\u003e [MLFS-S6-Bootscripts](https://github.com/dslm4515/MLFS-S6-Bootscripts) - Boot scripts for CMLFS/MLFS/LFS using skarnet's S6+S6-rc init system \u003c/li\u003e\n\u003cli\u003e [MLFS-Pkgtool](https://github.com/dslm4515/MLFS-pkgtool) - Musl LFS with Slackware's pkgtools \u003c/li\u003e\n\u003cli\u003e [Genshen's docker-clang-toolchain](https://github.com/genshen/docker-clang-toolchain)\u003c/li\u003e\n\u003cli\u003e [Build a freestanding libc++](https://blogs.gentoo.org/gsoc2016-native-clang/2016/05/05/build-a-freestanding-libcxx/) \u003c/li\u003e\n\u003c/ul\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdslm4515%2FCMLFS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdslm4515%2FCMLFS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdslm4515%2FCMLFS/lists"}