René's URL Explorer Experiment


Title: Fix kfunc/extern codegen so sched_ext_simple compiles by congwang-mk · Pull Request #21 · multikernel/kernelscript · GitHub

Open Graph Title: Fix kfunc/extern codegen so sched_ext_simple compiles by congwang-mk · Pull Request #21 · multikernel/kernelscript

X Title: Fix kfunc/extern codegen so sched_ext_simple compiles by congwang-mk · Pull Request #21 · multikernel/kernelscript

Description: Summary sched_ext_simple.ks (and other examples using extern kfunc declarations) compiled in KernelScript but produced eBPF C that failed to build. This branch fixes the three distinct problems found along the way. 1. Lower kfunc declarations into the IR extern kfunc declarations were registered in the type checker and symbol table but never lowered into the IR, so the eBPF C backend never emitted extern ... __ksym; declarations for them — generated .ebpf.c called kfuncs like scx_bpf_dsq_insert with no declaration in scope. Both kernel-provided extern kfuncs and locally-defined @kfunc prototypes are now represented as a new IRDeclKfuncDecl source declaration, emitted in source order from the IR. This replaces the ~kfunc_declarations / ~extern_declarations side-channel arguments that previously smuggled AST fragments past the IR into the backend. 2. Skip __ksym externs for standard BPF helpers KernelScript uses extern for both kfuncs and BPF helpers, and shipped examples (extern_kfunc_demo.ks, include_demo.ks) declare helpers like bpf_ktime_get_ns with it. Emitting extern ... __ksym; for those clashed with libbpf's bpf_helpers.h, which already declares every helper. A new Bpf_helpers module enumerates the standard helpers (mirroring libbpf's bpf_helper_defs.h); the backend skips the __ksym declaration for any extern naming one. Real kfuncs are unaffected. 3. Compile eBPF objects with -fno-builtin struct_ops method names come from the kernel struct, so a sched_ext_ops scheduler must define an exit method. eBPF objects never link libc, but clang still recognises exit as a compiler builtin (void(int) noreturn) regardless of -target bpf — it compiled the fall-through body away to a zero-size section, and libbpf then rejected the object. -fno-builtin is added to the generated Makefile's BPF_CFLAGS. eBPF C relies only on __builtin_* intrinsics (KernelScript emits __builtin_memcpy, never bare memcpy; struct-copy lowering uses the llvm.memcpy intrinsic) — none of which -fno-builtin affects. Testing Full suite: 85 test suites pass, 0 failures. New tests cover extern-kfunc IR codegen, the BPF-helper skip, and verbatim emission of builtin-named struct_ops methods. sched_ext_simple now builds fully end-to-end (.ebpf.o, skeleton, userspace binary). Verified every example's eBPF object builds with -fno-builtin. 🤖 Generated with Claude Code

Open Graph Description: Summary sched_ext_simple.ks (and other examples using extern kfunc declarations) compiled in KernelScript but produced eBPF C that failed to build. This branch fixes the three distinct problems fou...

X Description: Summary sched_ext_simple.ks (and other examples using extern kfunc declarations) compiled in KernelScript but produced eBPF C that failed to build. This branch fixes the three distinct problems fou...

Opengraph URL: https://github.com/multikernel/kernelscript/pull/21

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a3907f80-69e1-6d1c-1440-6020eb15dafc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD058:36DFDE:936E62:D3E8A8:6A621556
html-safe-nonce8c974d07f1477b818530054422ecdd300cfbe12c05dca220b61633ab4652dedc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDU4OjM2REZERTo5MzZFNjI6RDNFOEE4OjZBNjIxNTU2IiwidmlzaXRvcl9pZCI6IjY2NzAxOTM1MzIyNzUzOTc5NzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaced45b7e31c65aa79f9e20cc17b7c39cde278fddcefccb1c0ce8bc0f0c58961cb
hovercard-subject-tagpull_request:3685051289
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/multikernel/kernelscript/pull/21/files
twitter:imagehttps://avatars.githubusercontent.com/u/227915880?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/227915880?s=400&v=4
og:image:altSummary sched_ext_simple.ks (and other examples using extern kfunc declarations) compiled in KernelScript but produced eBPF C that failed to build. This branch fixes the three distinct problems fou...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneccf61cb7ab435725b916ed640f57c45b2c4721db9469bc32656080efc5214b3e
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/multikernel/kernelscript git https://github.com/multikernel/kernelscript.git
octolytics-dimension-user_id202362072
octolytics-dimension-user_loginmultikernel
octolytics-dimension-repository_id1019261571
octolytics-dimension-repository_nwomultikernel/kernelscript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1019261571
octolytics-dimension-repository_network_root_nwomultikernel/kernelscript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea7585b3d2ee639495a70ce464d0a18bad88ea12c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/multikernel/kernelscript/pull/21/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmultikernel%2Fkernelscript%2Fpull%2F21%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmultikernel%2Fkernelscript%2Fpull%2F21%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=multikernel%2Fkernelscript
Reloadhttps://github.com/multikernel/kernelscript/pull/21/files
Reloadhttps://github.com/multikernel/kernelscript/pull/21/files
Reloadhttps://github.com/multikernel/kernelscript/pull/21/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/21/files
multikernel https://github.com/multikernel
kernelscripthttps://github.com/multikernel/kernelscript
Notifications https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Fork 23 https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Star 501 https://github.com/login?return_to=%2Fmultikernel%2Fkernelscript
Code https://github.com/multikernel/kernelscript
Issues 2 https://github.com/multikernel/kernelscript/issues
Pull requests 0 https://github.com/multikernel/kernelscript/pulls
Actions https://github.com/multikernel/kernelscript/actions
Projects https://github.com/multikernel/kernelscript/projects
Security and quality 0 https://github.com/multikernel/kernelscript/security
Insights https://github.com/multikernel/kernelscript/pulse
Code https://github.com/multikernel/kernelscript
Issues https://github.com/multikernel/kernelscript/issues
Pull requests https://github.com/multikernel/kernelscript/pulls
Actions https://github.com/multikernel/kernelscript/actions
Projects https://github.com/multikernel/kernelscript/projects
Security and quality https://github.com/multikernel/kernelscript/security
Insights https://github.com/multikernel/kernelscript/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmultikernel%2Fkernelscript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmultikernel%2Fkernelscript%2Fissues%2Fnew%2Fchoose
congwang-mkhttps://github.com/congwang-mk
mainhttps://github.com/multikernel/kernelscript/tree/main
fix-extern-kfunc-codegenhttps://github.com/multikernel/kernelscript/tree/fix-extern-kfunc-codegen
Conversation 1 https://github.com/multikernel/kernelscript/pull/21
Commits 5 https://github.com/multikernel/kernelscript/pull/21/commits
Checks 1 https://github.com/multikernel/kernelscript/pull/21/checks
Files changed https://github.com/multikernel/kernelscript/pull/21/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/21/files
Fix kfunc/extern codegen so sched_ext_simple compiles https://github.com/multikernel/kernelscript/pull/21/files#top
Show all changes 5 commits https://github.com/multikernel/kernelscript/pull/21/files
dd5f6b7 Lower kfunc declarations into the IR congwang-mk May 14, 2026 https://github.com/multikernel/kernelscript/pull/21/commits/dd5f6b74848ce1397b146f0c6da104c4e7712441
93314d7 Skip __ksym externs for standard BPF helpers congwang-mk May 14, 2026 https://github.com/multikernel/kernelscript/pull/21/commits/93314d71ebbd3db9cba63765f21c1c6226eb5616
271a8bb Compile eBPF objects with -fno-builtin congwang-mk May 14, 2026 https://github.com/multikernel/kernelscript/pull/21/commits/271a8bb3ff3a514118adfdc3806d30e6c4da9173
0fdef1d Update sched_ext_simple to current sched_ext kfunc ABI congwang-mk May 17, 2026 https://github.com/multikernel/kernelscript/pull/21/commits/0fdef1d710d3f7764b0e0761edcefe162a3afd50
4a30dea Sync struct_ops kfunc-call test with sched_ext ABI update congwang-mk May 17, 2026 https://github.com/multikernel/kernelscript/pull/21/commits/4a30dea720256a92a6e9ee72b3bb140a029c8aed
Clear filters https://github.com/multikernel/kernelscript/pull/21/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/21/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/21/files
sched_ext_simple.ks https://github.com/multikernel/kernelscript/pull/21/files#diff-f3b9d6c0ad712688d7f1fafdc20aef507fb1cf3889dece7f00f96e9e047bae85
bpf_helpers.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-61b2b8d98b7dbf0510a658f290e418c4725255c4442eafbf256b928207f8ec92
dune https://github.com/multikernel/kernelscript/pull/21/files#diff-89dcf9a56d39ea34f1baeb3a03af39e2753429508913492aaf53e3d1697bdf46
ebpf_c_codegen.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-087a8faac5edce9a796f07749864a234f146bca085c99e2bc5761e20f2018b6c
ir.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-2b848748d43816bd815a34efc941358ca8f66627a72d289483be0541be7b640a
ir_generator.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-7b7b3d36c6a326e1a022a7eaf0e67082de1abe843a789dc49e3580493ba9ffdf
main.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-0d32fcae43114eceb0a0089619caca3700eacbb76b225ab4dd746843a121a805
userspace_codegen.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-1864935d68899925ab1485ad4f91071ac537e818db74b2dfc6c5979902c7efbf
test_definition_order.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-c5f1ca5f3c5a5512ec3d6f3d4d1969efd145f9eb47cf967fa5a210d5a91e0ca3
test_extern.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-9acb94392120985c50103017d4ec8d42e99f9691d42432fff4591860623fd797
test_kfunc_attribute.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-605121b3fe5f64408fadbc97e04c1b041f48b457794a14551f602880712b8a7f
test_struct_ops.ml https://github.com/multikernel/kernelscript/pull/21/files#diff-59d1bbf5846dd3d6bdd854a25296f3b8b187d21b08d149cd441a6a8459d40555
examples/sched_ext_simple.kshttps://github.com/multikernel/kernelscript/pull/21/files#diff-f3b9d6c0ad712688d7f1fafdc20aef507fb1cf3889dece7f00f96e9e047bae85
View file https://github.com/multikernel/kernelscript/blob/4a30dea720256a92a6e9ee72b3bb140a029c8aed/examples/sched_ext_simple.ks
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/21/{{ revealButtonHref }}
https://github.com/multikernel/kernelscript/pull/21/files#diff-f3b9d6c0ad712688d7f1fafdc20aef507fb1cf3889dece7f00f96e9e047bae85
https://github.com/multikernel/kernelscript/pull/21/files#diff-f3b9d6c0ad712688d7f1fafdc20aef507fb1cf3889dece7f00f96e9e047bae85
https://github.com/multikernel/kernelscript/pull/21/files#diff-f3b9d6c0ad712688d7f1fafdc20aef507fb1cf3889dece7f00f96e9e047bae85
src/bpf_helpers.mlhttps://github.com/multikernel/kernelscript/pull/21/files#diff-61b2b8d98b7dbf0510a658f290e418c4725255c4442eafbf256b928207f8ec92
View file https://github.com/multikernel/kernelscript/blob/4a30dea720256a92a6e9ee72b3bb140a029c8aed/src/bpf_helpers.ml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/21/{{ revealButtonHref }}
src/dunehttps://github.com/multikernel/kernelscript/pull/21/files#diff-89dcf9a56d39ea34f1baeb3a03af39e2753429508913492aaf53e3d1697bdf46
View file https://github.com/multikernel/kernelscript/blob/4a30dea720256a92a6e9ee72b3bb140a029c8aed/src/dune
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/multikernel/kernelscript/pull/21/{{ revealButtonHref }}
https://github.com/multikernel/kernelscript/pull/21/files#diff-89dcf9a56d39ea34f1baeb3a03af39e2753429508913492aaf53e3d1697bdf46
https://github.com/multikernel/kernelscript/pull/21/files#diff-89dcf9a56d39ea34f1baeb3a03af39e2753429508913492aaf53e3d1697bdf46
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/21/files
Please reload this pagehttps://github.com/multikernel/kernelscript/pull/21/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.