{"id":24516184,"url":"https://github.com/chentao-kernel/kbuild","last_synced_at":"2025-03-15T10:42:08.553Z","repository":{"id":252776179,"uuid":"841057200","full_name":"chentao-kernel/kbuild","owner":"chentao-kernel","description":"build linux kernel with container env;build mini os based on latest kernel and ubuntu rootfs run with qemu","archived":false,"fork":false,"pushed_at":"2025-01-20T12:41:59.000Z","size":170,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T13:48:34.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chentao-kernel.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":"2024-08-11T14:12:07.000Z","updated_at":"2025-01-20T12:42:01.000Z","dependencies_parsed_at":"2024-11-13T18:29:38.091Z","dependency_job_id":null,"html_url":"https://github.com/chentao-kernel/kbuild","commit_stats":null,"previous_names":["chentao-kernel/kbuild"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chentao-kernel%2Fkbuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chentao-kernel%2Fkbuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chentao-kernel%2Fkbuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chentao-kernel%2Fkbuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chentao-kernel","download_url":"https://codeload.github.com/chentao-kernel/kbuild/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719371,"owners_count":20336596,"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":[],"created_at":"2025-01-22T01:21:38.864Z","updated_at":"2025-03-15T10:42:08.533Z","avatar_url":"https://github.com/chentao-kernel.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kbuild\n* build for linux kernel with container env\n* build mini os based on latest kernel and ubuntu rootfs run in qemu\n# Quick Start\n## Env\nubuntu 24.04 run in vmware\n## build container to compile kernel\nbuild container use build_containers.sh,\nbuild kenrel with gcc 13, clang 13, and use ubuntu 23.04 docker image\n```\nsudo bash build_containers.sh -g 13 -c 13 -u 23.04\n\nHey, we gonna use sudo for running docker\nGCC VERSION:13,CLANG VERSION:13,UBUNTU VERSION:23.04\n\nBuilding a container with CLANG_VERSION=13 and GCC_VERSION=13 from UBUNTU_VERSION=23.04\nDEPRECATED: The legacy builder is deprecated and will be removed in a future release.\n            Install the buildx component to build images with BuildKit:\n```\nfinally images successfully builded show\n```\n...\nRemoving intermediate container da4b0a463bb7\n ---\u003e 58fcca287fc2\nSuccessfully built 58fcca287fc2\nSuccessfully tagged kernel-build-container:gcc-13-clang-13\n```\n## build kernel\nbuild kernel use main.py to set kernel source path, output path, target contaer, etc.\n```\nsudo python3 main.py -a x86_64 -k /boot/config-5.15.0-60-generic -s /home/dylane/code/linux -o /home/tmp -c gcc-13-clang-13 -- -j$(nproc)\n```\nbuilding result\n```\n=== Building with gcc-13-clang-13 ===\nOutput subdirectory for this build: /home/tmp/config-5.15.0-60-generic-x86_64-gcc-13-clang-13\nOutput subdirectory doesn't exist, create it\nNo \".config\", copy \"/boot/config-5.15.0-60-generic\" to \"/home/tmp/config-5.15.0-60-generic-x86_64-gcc-13-clang-13/.config\"\nGoing to save build log to \"build_log.txt\" in output subdirectory\nRun the container: bash ./start_containers.sh gcc-13-clang-13 /home/dylane/code/linux /home/tmp/config-5.15.0-60-generic-x86_64-gcc-13-clang-13 -n -- make O=../out/ -j2 2\u003e\u00261\n    Hey, we gonna use sudo for running docker\n    Run docker in NON-interactive mode\n    Starting \"kernel-build-container:gcc-13-clang-13\"\n    Mount source code directory \"/home/dylane/code/linux\" at \"/home/root/src\"\n    Mount build output directory \"/home/tmp/config-5.15.0-60-generic-x86_64-gcc-13-clang-13\" at \"/home/root/out\"\n    Gonna run command \"make O=../out/ -j2 2\u003e\u00261\"\n    \n    make[1]: Entering directory '/home/root/out'\n      SYNC    include/config/auto.conf.cmd\n      GEN     Makefile\n      HOSTCC  scripts/basic/fixdep\n      HOSTCC  scripts/kconfig/confdata.o\n      HOSTCC  scripts/kconfig/conf.o\n      HOSTCC  scripts/kconfig/expr.o\n      LEX     scripts/kconfig/lexer.lex.c\n      YACC    scripts/kconfig/parser.tab.[ch]\n      HOSTCC  scripts/kconfig/menu.o\n      HOSTCC  scripts/kconfig/parser.tab.o\n      ...\n```\ncompile result log\n```\n/home/tmp/config-5.15.0-60-generic-x86_64-gcc-13-clang-13/build_log.txt\n```\nif you want add ebpf btf file in /sys/kernel/btf path, you can add these config options\n```\n#\n# Compile-time checks and compiler options\n#\nCONFIG_DEBUG_INFO=y\n# CONFIG_DEBUG_INFO_NONE is not set\n# CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT is not set\n# CONFIG_DEBUG_INFO_DWARF4 is not set\nCONFIG_DEBUG_INFO_DWARF5=y\n# CONFIG_DEBUG_INFO_REDUCED is not set\nCONFIG_DEBUG_INFO_COMPRESSED_NONE=y\n# CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set\n# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set\n# CONFIG_DEBUG_INFO_SPLIT is not set\nCONFIG_DEBUG_INFO_BTF=y\nCONFIG_PAHOLE_HAS_SPLIT_BTF=y\nCONFIG_PAHOLE_HAS_LANG_EXCLUDE=y\nCONFIG_DEBUG_INFO_BTF_MODULES=y\n```\n## build rootfs\nbuild rootfs use build_rootfs.sh, the rootfs based on ubuntu/debian\n```\nsudo bash build_rootfs2.sh --arch=amd64 --dist=noble --tar=ubuntu-noble-amd64.tar.bz2 --include=net-tools\n```\nbuilding result\n```\ndebian_mirror not found:, use: http://archive.ubuntu.com/ubuntu/\n\nCreating Debian noble RFS for amd64 in '/tmp/tmp.R6X0DH3gJl/ubuntu-noble-amd64'...\n\nI: Retrieving InRelease\nI: Checking Release signature\nI: Valid Release signature (key id F6ECB3762474EDA9D21B7022871920D1991BC93C)\nI: Retrieving Packages\nI: Validating Packages\nI: Resolving dependencies of required packages...\nI: Resolving dependencies of base packages...\nI: Checking component main on http://archive.ubuntu.com/ubuntu...\nI: Retrieving adduser 3.137ubuntu1\nI: Validating adduser 3.137ubuntu1\n```\nat last you will see the  rootfs_debian_amd64.ext4 img\n```\ndylane@2404:~/code/kbuild$ ls\nbuild_containers.sh  Dockerfile_ubuntu_compile  main.py    rm_containers.sh          tmpfs\nbuild_rootfs2.sh     finish_containers.sh       qemu2.sh   rootfs_debian_amd64.ext4  ubuntu24-base.ext4\n```\n## Run your os\nCongratulations, you can finally use start_qemu.sh to run your os now.\n```\nsudo bash start_qemu.sh --kernel=/home/dylane/code/linux-next/arch/x86_64/boot/bzImage --rootfs=rootfs_debian_amd64.ext4\n```\nsystem starting...\n```\n[  OK  ] Started serial-getty@ttyS0.service - Serial Getty on ttyS0.\nStarting setvtrgb.service - Set console scheme...\n[  OK  ] Started dbus.service - D-Bus System Message Bus.\n[  OK  ] Finished setvtrgb.service - Set console scheme.\n[  OK  ] Created slice system-getty.slice - Slice /system/getty.\n[  OK  ] Started getty@tty1.service - Getty on tty1.\n[  OK  ] Reached target getty.target - Login Prompts.\n[  OK  ] Started systemd-logind.service - User Login Management.\n[  OK  ] Started rsyslog.service - System Logging Service.\n[  OK  ] Finished e2scrub_reap.service - Re…line ext4 Metadata Check Snapshots.\n[  OK  ] Reached target multi-user.target - Multi-User System.\n[  OK  ] Reached target graphical.target - Graphical Interface.\nStarting systemd-update-utmp-runle…- Record Runlevel Change in UTMP...\n[  OK  ] Finished systemd-update-utmp-runle…e - Record Runlevel Change in UTMP.\n\nUbuntu 24.04 LTS debian ttyS0\n\ndebian login:\n```\nDebugging your ebpf tools from kernel to application\n```\nroot@debian:/boot# ./cpudist\nTracing on-CPU time... Hit Ctrl-C to end.\n^C\n     usecs               : count    distribution\n         0 -\u003e 1          : 0        |                                        |\n         2 -\u003e 3          : 0        |                                        |\n         4 -\u003e 7          : 0        |                                        |\n         8 -\u003e 15         : 0        |                                        |\n        16 -\u003e 31         : 0        |                                        |\n        32 -\u003e 63         : 0        |                                        |\n        64 -\u003e 127        : 1        |********                                |\n       128 -\u003e 255        : 1        |********                                |\n       256 -\u003e 511        : 1        |********                                |\n```\n**The specific usage of all scripts can be viewed through the help command**\n# Acknowledgements\nThis project makes use of the following open source projects:\n- [kernel-build-containers](https://github.com/a13xp0p0v/kernel-build-containers) under the Apache License 3.0\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchentao-kernel%2Fkbuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchentao-kernel%2Fkbuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchentao-kernel%2Fkbuild/lists"}