#Ultra

1 messages · Page 14 of 1

ornate jasper
#

based on my reading of the current announcement message id say it having been reviewed by you and the general structure architected by you makes it fit here

#

the announcement doesnt (currently, im too lazy to try and look at edit history) make any mention of requiring things here to be 0% AI, just not full vibecoding

sinful river
#

I have 0% AI generated code apart from tests too

#

I'd say the no-ai distinction is a bit useless, and it'd be pointless to move the thread and lose history

ornate jasper
#

idk

#

i have a firm no-ai policy even in issues/docs/descriptions so moving there is right for my project

sinful river
#

Why

ornate jasper
#

ai shit is harder to read. it adds a lot of fluff that frankly makes it harder to get to the point of things, and it cannot be trusted to correctly interpret intention

haughty notch
lost raptor
#

could always just do a complete rewrite and not use ai moving forward if its a big thing for you

haughty notch
sinful river
haughty notch
#

it's 70k LoC I think

sinful river
haughty notch
ornate jasper
#

if the existence of a no-ai category is invalidating you rather than seeming like a place to stick the weirdo hardliners like me then uh maybe examine that feeling ig

sinful river
#

I'm not a native English speaker and it sure helps with writing technical documentation

willow fern
#

my experience of AI is that it can often turn out things where there don't have to be too many subtleties and considerations, but unfortunately kernels don't have much of that

ornate jasper
sinful river
#

why?

haughty notch
lost raptor
sinful river
willow fern
#

and if you try to get them to do anything where there are these considerations, you end up with them adding more and more flags and states and you end up with a combinatorial explosion

haughty notch
ornate jasper
# sinful river why?

its a plagiarism machine that takes as much effort to edit into something actually useful as it wouldve been to just do shit myself in the first place

haughty notch
willow fern
haughty notch
#

(except for a couple of places in 2023 I think, when the AI was all the hype, which I'm rewriting/not really using anyway because it's an unmaintainable mess)

willow fern
#

just today i had heard that claude 4.7 is a genius so i asked him how he would add auto-restart to the service manager i am writing for keyronex and the proposal was horrible

sinful river
ornate jasper
ornate jasper
sinful river
#

There's a difference between writing complex code and reading it

#

And even then, it's not like you can't just review and edit lol

willow fern
#

it was a mess and maybe it would have worked but i couldn't understand it, i have a single state variable to drive the service lifecycle and it proposed 4 new variables which all have subtle effects and turned my state machine with clearly defined inputs like "PID exited" or "Stop requested" into a monstrosity

ornate jasper
sinful river
#

I doubt that

haughty notch
#

I haven't been using AI for documentation because I don't really have documentation chad

#

Also, I think AI models kinda get confused by microkernels?

ornate jasper
# sinful river There's a difference between writing complex code and reading it

maybe but docs are also meant to capture intent and ideas imo not just the raw what the code does. i can look at some weird linux code and understand what its doing and maybe ai could quickly whip up docs about what its doing, but if thats true than why do the docs need to exist for what its doing, the docs are for WHY and THAT is what ai cant be trusted to figure out imo

willow fern
#

this exactly reflects my last experience where i asked claude to make some improvements to my TCP stack. he wanted to introduce all kinds of new code paths while i deliberately had stayed to the course set by the BSD stack, where you have a single output function and output is programmatically determined based on the current states. just obnoxious work, i think AI seems to be allergic to that style of programming

sinful river
willow fern
#

on the other hand they are alright for documenting and testing for the most part

ornate jasper
haughty notch
#

Oh, I write doc comments myself

#

If that's what people mean by documentation, then I try to comment my stuff

ornate jasper
haughty notch
#

I mean I let copilot autocomplete it, if that's more or less I'm writing anyway

ornate jasper
#

everyone saw docs and thought something different

haughty notch
#

I wanted to write a high level overview of what I have, eventually

#

Because the code comments are not a good documentation in my eyes, I guess

sinful river
#

by doc comments I mean large top-level comments of like > 30 lines

haughty notch
sinful river
ornate jasper
prime wraith
#

this one is ai assisted

ornate jasper
#

literally my point

sinful river
#

idk for me specifically it helps, I am not a native english speaker and I would rather have something be slightly ai generated that was written in a better manner and faster than something all written by myself that takes longer to do and is less well written

ornate jasper
#

then leave your thread in this forum and its fine

sinful river
#

my stance is "no stance" basically

ornate jasper
#

as much as im anti-ai for my own stuff i wont really begrudge anyone else as long as its not in the place where bsky is rn where its fully 100% vibe-coded and breaking every 5 seconds because of it lmao

#

(in which case i just wont use it and still wont care)

#

yall do your own things lmao its fine

haughty notch
#

I think the thing that doesn't help is that I kinda dislike AI, but have tainted my stuff with it

ornate jasper
#

yeah thats your own issue to unpack

sinful river
#

I wouldn't say I like AI, but I do find it useful in some cases

#

I have been using it as a studying method (generating quizzes etc) and it works really well

sinful river
#

i thought u saw my name from the linux patch

#

I am obviously not english native 😭

prime wraith
#

I did but I didn't pay attention lmfao

prime wraith
#

So you're from french Canada?

sinful river
#

quebec yeah

prime wraith
#

Makes sense

sinful river
#

I literally have the least english name possible which is a bit of a shame

#

its hard to pronounce

haughty notch
#

idk tbh

#

it doesn't matter

prime wraith
#

x86 and PA-RISC are the only two architectures that select HAVE_UNSTABLE_SCHED_CLOCK KEKW

haughty notch
#

where?

#

What does it do, and why does Linux need it? trl

prime wraith
#

aka unstable tsc on x86

haughty notch
#

Is it because of tsc offset firmware mess?

prime wraith
#

no

#

just because tsc can change frequency at runtime

#

if its not constant

haughty notch
#

then why use tsc in the first place?

prime wraith
#

let me explain

sinful river
#

if no invariant tsc I fallback to hpet

haughty notch
#

me too, I use hpet/pmtmr

sinful river
#

yeah if no hpet then pm timer

haughty notch
#

I decided not to support PIT in any form

#

with kvmclock you would read the kvm struct anyway

prime wraith
#

linux has the following clock types:

  • struct clocksource, an abstraction over a counter (this can potentially be very expensive to read but it provides precise timestamps, client code uses ktime_get() to access the best clocksource
  • sched_clock(), this is designed to be a very fast reentrant and nmi safe clock used on very hot paths, linux uses TSC even if its not constant for this purpose, since the scheduler just needs to know the amount of ticks that have elapsed on this specific CPU and doesnt care much if it drifts a bit
  • struct clock_event_device, an abstraction over an event generating clock, e.g. deadline lapic etc
  • jiffies, just a global variable but generic code makes sure to increment it with ticks, this is the fastest but most coarse clock source, used as fallback etc
  • wall_clock, a thing that returns struct timespec64, actual irl time
sinful river
#

I have recently renamed my TimeCounter to ClockSource actually

#

slowly turning into linux nooo

prime wraith
#

i kinda hate the name clocksource

#

its way too broad

#

ill probably call it a counter

sinful river
#

a counter is way more broad lol

prime wraith
#

all it does is count

#

so sounds precise to me

sinful river
#

so TimeCounter was a better name maybe meme

prime wraith
#

clocksource sounds like something that gives u a wall clock

sinful river
#

timecounter is a BSD name

prime wraith
#

i want to maybe have a similar prefix/suffix for event and counter clock types

sinful river
#

I renamed it because I liked clock.zig better than time.zig

prime wraith
#

clock sounds like it should return a timespec

#

a monotonic counter is definitely not a clock

sinful river
#

ok maybe I should revert the commit meme

prime wraith
#

lol

#

just saying my thoughts

sinful river
prime wraith
#

based

sinful river
#

I think you're right that clock is a weird name

prime wraith
#

yeah

#

at least according to this definition

#

kvm has a separate msr that returns an actual wall clock

#

its u32 sec, u32 nsec

sinful river
#

I should leverage hypervisors more

#

i only support pvclock

prime wraith
#

yeah kvm supports some super cool stuff

#

ipis, tlb helpers etc

sinful river
#

like what? Also what about vmware

prime wraith
prime wraith
#

and hyperv has even more

#

most of arch specific stuff like that will be entirely offloaded

sinful river
#

actually idk if I want to rely on cool features more

#

because then it's not as portable

#

idk

prime wraith
#

hm? lol

#

u dont panic("no hypervisor") right

#

just optionally support them

sinful river
#

no

prime wraith
#

by overriding arch callbacks

sinful river
#

but then you get super fast tlb shootdown or IPI or something on kvm but not on other platforms

prime wraith
#

arch.tlb_flush = vmware_tlb_flush

#

and by default its just arch.tlb_flush = native_tlb_flush

sinful river
#

that is slow though

prime wraith
#

what is?

sinful river
#

that is extreme overhead

#

using a function pointer for that is insane

prime wraith
#

ur joking right KEKW

sinful river
#

are you out of your mind

prime wraith
#

yes its phenomenal overhead

#

but yeah in reality since linux has a static_call mechanism and they didnt bother using it for this

sinful river
#

I don't really need that tho since my tlb shootdown wont be synchronous

prime wraith
#

that means it doesnt matter

prime wraith
sinful river
#

what would that do

prime wraith
#

start async work

#

the cool part is like, the vcpu you're trying flush the tlb of might be preempted on the host, so u can just skip flushing stuff on it

#

and kvm allows you to detect that

sinful river
#

I dont think I need architectural support at all for async shootdowns

#

only a way to invalidate a page

prime wraith
#

on vcpu resume

#

u cmpxchg a flag that tells the kvm to do it

#

also pvspinlocks are insanely cool

#

you can force kick vcpus to schedule them over yourself on the host etc

#

u can tell kvm that you're try to acquire a spinlock currently held by a preempted vcpu so it will schedule it

sinful river
prime wraith
#

ye

#

in terms of features

#

tlb flushing is just a hypercall

#

There's also XEN ofc

#

which offloads even more

#

but thats a bare metal hypervisor

#

and pvclock was invented by XEN

haughty notch
prime wraith
#

fuck i could really use kconfig integration now

ornate jasper
#

so they can do secure vs nonsecure kernel memes

carmine token
#

not for perf

#

isn't it?

ornate jasper
#

yup

carmine token
#

yeah

#

Static calls use code patching to hard-code function pointers into
direct branch instructions. They give the flexibility of function
pointers, but with improved performance. This is especially important
for cases where retpolines would otherwise be used, as retpolines can
significantly impact performance.

prime wraith
#

it is for performance ofc

carmine token
#

well it is to recover perf lost to retpolines

prime wraith
#

no

#

thats just one advantage if reptolines are enabled

carmine token
#

it literally says so in the cover letter that added them

ornate jasper
#

yeah

#

added perf for normal things is a bonus

prime wraith
#

its still used for hot function pointers

#

e.g. apic accessors

ornate jasper
#

it was originally as a less-shit-perf replacement for retpolines, but now can get used for other stuff because its also just better perf sometimes

ornate jasper
# prime wraith yep

the secure/nonsecure kernel memes are actually really cool tbh, maybe once my kernel is fully working for normal shit i can look into making that sort of thing (esp since aarch64 has hardware support for that too)

carmine token
#

All other usecases are bonus, but it would certainly be interesting to
investigate the impact of using these APIs for tracing: that too is a
feature enabled everywhere but utilized only by a small fraction of Linux
users - so literally every single cycle or instruction saved or hot-path
shortened is a major win.

#

static calls are still slower than the alternatives mechanism that linux has

prime wraith
#

alternatives are for patching instructions, not call targets

carmine token
#

can't you patch the whole call?

prime wraith
#

to what? another call?

#

I guess in theory u can, but thats not something they do

carmine token
#

apparently on some archs static calls compile to two calls

#

because these archs cannot patch call isns

ornate jasper
#

the one use of alternatives ive actually seen looking at their code is that the mmio read is changed by it to use load-acquire on some stupid early apple hardware lol

carmine token
#

so they patch a trampoline instead

prime wraith
#

like the original reason was to patch hot repolined stuff, but these days im pretty sure most uses that are arch specific are for avoiding indirection on hot paths

prime wraith
carmine token
#

apparently only x86 and ppc have STATIC_CALL_INLINE

carmine token
prime wraith
#

slower for other arches or?

carmine token
#

since static calls still need to prepare the calling conv

#

while patching out stuff entirely doesn't

prime wraith
#

not sure what u mean by that

carmine token
#

for example, for tracing it is preferable to have no call at all (only nops)

#

if it's off

prime wraith
#

oh ok

carmine token
#

(and also no mov rdi, #first_arg etc)

prime wraith
#

but the most common use case is just replacing the call target

#

so even if u did alternatives its just the offset u patch

carmine token
#
$ grep -r 'select HAVE_STATIC_CALL'
arch/Kconfig:      Where an architecture does not select HAVE_STATIC_CALL_INLINE, any
arch/powerpc/Kconfig:    select HAVE_STATIC_CALL            if PPC32
arch/powerpc/Kconfig:    select HAVE_STATIC_CALL_INLINE        if PPC32
arch/x86/Kconfig:    select HAVE_STATIC_CALL
arch/x86/Kconfig:    select HAVE_STATIC_CALL_INLINE        if HAVE_OBJTOOL
prime wraith
#

why cant u patch these on arm btw

carmine token
#

you can probably but ARM doesn't have retpolines either

#

but also, on ARM the call isns immediates are smaller

prime wraith
#

apparently arm uses static calls only for CFI

#

its just extra hardening i guess

carmine token
#

according to Kconfig, arm does not have special support for static calls and it just compiles them to function pointers

prime wraith
#

yes

#

only enabled if you have control flow integrity on

carmine token
#

ah, this is not in my local linux clone

#

it was probably added fairly recently

prime wraith
#

perhaps

carmine token
#

yeah this was added in 7.0

#

also HAVE_STATIC_CALL is the variant with trampolines

#

Unlike on x86, there is no pressing need on arm64 to avoid indirect
calls at all cost, but hiding it from the compiler as is done here does
have some benefits:

  • the literal is located in .text, which gives us the same robustness
    advantage that code patching does;
  • no performance hit on CFI enabled Clang builds that decorate compiler
    emitted indirect calls with branch target validity checks.
#

this is the rationale for adding it

sinful river
#

meanwhile I just branch directly 😎

#

if (x2apic) x2apic_write

ornate jasper
#

same actually

#

for now at least

sinful river
#

no runtime tricks and is perfectly predictable

prime wraith
#

Especially the first one

carmine token
sinful river
#

especially on hot paths

#

I noticed this when I was benchmarking a triangle rasterization function

carmine token
#

yeah

prime wraith
sinful river
#

the cpu is better at predicting a branch even if that branch is in a hot loop than doing an indirect call

prime wraith
#

Cpus have branch target buffers for predicting this stuff

carmine token
#

they are fairly small and even then there are other costs

prime wraith
#

Anyway u have to profile to know for sure

carmine token
#

yes

#

doing any optimization w/o profiling is a bad idea

#

but it's true that check + branch is usually better than indirect branch

prime wraith
sinful river
#

patching code is a runtime trick

prime wraith
#

Don't think there's a single kernel on here that supports code patching

sinful river
#

we were talking about linux

prime wraith
#

It wouldn't work on Linux since it would have many more branches than just x2 and x apics

#

Due to pv support etc

#

Also conditionally enabled with kernel configs

ornate jasper
#

static call trampoline code patching is actually something im considering trying to implement specifically for the apic/x2apic split even though thats basically my only use case

sinful river
prime wraith
sinful river
#

I am more linux larping than you

#

this is not good...

prime wraith
#

Yeah

sinful river
#

actually we should come up with a saner thing

#

in json or something

prime wraith
carmine token
#

I'd just implement load time code patching

#

patch in prekernel

prime wraith
#

So alternatives?

carmine token
#

Not sure how alternatives work

sinful river
#

for the apic use case this is really overkill

prime wraith
carmine token
#

But I'd just let the prekernel patch either isn sequences or call targets

prime wraith
#

Although alternatives support runtime patching

carmine token
#

runtime patching seems like a bad idea

sinful river
prime wraith
#

Modules are the primary use case

carmine token
#

well, module load time != runtime, right?

prime wraith
ornate jasper
sinful river
prime wraith
sinful river
#

I think KConfig is also like insane to parse

prime wraith
prime wraith
#

Ill just use a python library

sinful river
#

there is python kconfiglib

prime wraith
#

Yeah that

ornate jasper
carmine token
sinful river
#

what I do is I try running kconfig-nconf first, or else I fallback to a python script using kconfiglib

carmine token
#

that's what Managarm does

sinful river
#

or just pass the kernel config to the loader

ornate jasper
prime wraith
carmine token
#

we use ELF notes

prime wraith
#

Completely changes with paravirt

#

Unless you dont want to support that at all

ornate jasper
#

oh i dont do paravirt

#

at least not yet

sinful river
prime wraith
#

Yeah elf notes seems perfect for config detection

ornate jasper
#

if i figure out how to actually write elf notes ill def do something like that for my feature tags

sinful river
#

you should add kconfig too

ornate jasper
#

me? nah

#

i aint touching kconfig

prime wraith
#

Why not lol

#

Its really good

#

For describing dependencies for features etc

ornate jasper
#

because i hate external deps

prime wraith
#

Its just a text file

#

Like a makefile etc

ornate jasper
#

yeah that part is fine its the utility to manage them that i dont want to bring in, and then id need to write my own parser for them in zig too, and that just increasingly sounds like more work than i want to do

sinful river
#

no you dont

#

well

#

it's a tiny key=value parser

prime wraith
#

The output of kconfig is a trivial to parse .config file

#

Yeah just kv pairs

ornate jasper
#

ok then that wouldnt be a problem

prime wraith
#

And kconfig itself is configured via a frontend like python or anything, there's tons of them

ornate jasper
#

yeah but that frontend is an external dep which rubs me the wrong way lol

#

esp if its python

#

i hate python more than anything else in software lmao

prime wraith
#

Yeah the frontend is external, but it can be of users choice

ornate jasper
#

idk

prime wraith
#

Standard utilities like that

ornate jasper
#

i also prefer to keep build option selection tightly integrated with the build process itself

prime wraith
#

Oh well

#

I think later down the line you inevitably have to reinvent something similar

carmine token
#

just enable everything unconditionally halfmemeleft

ornate jasper
#

yeah if i need more config options in future ill consider it

carmine token
#

and use load time patching to remove the stuff that you don't need

prime wraith
#

The 30 meg kernel

carmine token
#

that sounds more like a serenity skill issue

prime wraith
#

A lot of it is c++ template bloat also

wide ether
prime wraith
#

Yeah lol

sinful river
#

there are also gui frontends

#

which is neat

carmine token
#

Managarm is also C++ but nowhere near 30M

prime wraith
#

Well its a microkernel lol

sinful river
#

looks very cool

ornate jasper
#

i actually dont know how big my kernel is

#

maybe ill check that today

#

i know its more than a 16-bit number of sectors because thats why i swapped off of bootelf to limine (before eventually from limine to my own bootloader)

#

or maybe it was 16 bit bytes i dont remember

sinful river
#

wtf even with releasesmall mine is 1.2mb

prime wraith
#

💀

#

1.2M hello world

sinful river
#

ah no nvm

#

I forgot to install with releasesmall too

#

it's 392kb

#

not bad

ornate jasper
#

esp if you use zig's formatting that aint bad

sinful river
ornate jasper
#

the one downside to zig string formatting is it template explodes

carmine token
#

90M pkg-builds/managarm-system/drivers/gfx/nvidia-open/gfx_nvidia_open

#

wtf

sinful river
#

I think

carmine token
#

the NVIDIA driver just takes 90M 💀

ornate jasper
carmine token
#

but this is with debugging symbols

sinful river
#

idk but like I was running formatting in some functions for debugging and the stack would overflow

ornate jasper
#

i had that more with debug symbols than formatting

carmine token
#

it's 16M without and that's the largest driver

sinful river
#

actually maybe it was unrelated and it didnt overflow

#

it was probably because of my pmm sharing pages bug

#

but it appeared less often when making stacks bigger

ornate jasper
#

if its in debugging code and youre using zig's dwarf unwind that may be part of it

sinful river
#

I don't

ornate jasper
#

that stuff uses a ton of stack and ive not been able to pin down why

sinful river
#

I don't use DWARF

#

I generate my own symbol table

ornate jasper
#

then idk

sinful river
#

like it said it probably wasnt a stack overflow at all

#

now that I think of it

ornate jasper
#

mhm

haughty notch
prime wraith
haughty notch
#

did managarm get kde in the end?

latent geode
#

doesn't say much as it barely does anything though

#

(most of it is .text iirc)

wide ether
latent geode
wide ether
#

trust

ornate jasper
#

(releasesafe with full debug info)

#

lets try a stripped releasesmall build

#

stripped releasesmall (does still have eh frame just not full dwarf)

obtuse sparrow
#

A little bit more than that

sinful river
#

that's pretty big

ornate jasper
#

yeah im a bit surprised

#

wonder how much of that is log template explosion

#

but also cant be assed to actually check

carmine token
stable orchid
#

kde in managarm before gta 6 is real

carmine token
#

there's probably no major stuff left, just bug fixing

#

we get to the point where plasma/kwin start and run but for some reason output doesn't work yet

prime wraith
#

Clanker suggested some solutions for uploading .config into cmake, lets see if it works

#
macro(load_kconfig config_file)
    if (NOT EXISTS "${config_file}")
        message(FATAL_ERROR "Invalid config file path: ${config_file}")
    endif()

    set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${config_file}")
    file(STRINGS "${config_file}" config_lines)
    
    foreach(line IN LISTS config_lines)
        # 1. Match 'n' (Unset Booleans/Tristates)
        if(line MATCHES "^# (CONFIG_[A-Za-z0-9_]+) is not set")
            set(${CMAKE_MATCH_1} OFF)
            
        # 2. Match 'y' (Boolean/Tristate True)
        elseif(line MATCHES "^(CONFIG_[A-Za-z0-9_]+)=y$")
            set(${CMAKE_MATCH_1} ON)
            
        # 3. Match 'm' (Tristate Module)
        # CMake doesn't have a native tristate, so we use the string "m"
        elseif(line MATCHES "^(CONFIG_[A-Za-z0-9_]+)=m$")
            set(${CMAKE_MATCH_1} "m")
            
        # 4. Match Strings
        # We strip the quotes for CMake, but set a hidden _IS_STRING 
        # variable so we know to put the quotes back for the C compiler!
        elseif(line MATCHES "^(CONFIG_[A-Za-z0-9_]+)=\"(.*)\"$")
            set(${CMAKE_MATCH_1} "${CMAKE_MATCH_2}")
            set(${CMAKE_MATCH_1}_IS_STRING TRUE)
            
        # 5. Match Numbers / Hex / Anything else
        elseif(line MATCHES "^(CONFIG_[A-Za-z0-9_]+)=(.*)$")
            set(${CMAKE_MATCH_1} "${CMAKE_MATCH_2}")
        endif()
    endforeach()
endmacro()
#

unironically works great

#

and sanitization is handled transparently by olddefconfig

#

thats insanely convenient

#

clanker is truly great at scripting

#

and this is stuff i hate working on so its a W for me

latent geode
#

straight to openslopware :^)

prime wraith
#

lol

#

nah the actual kernel will be almost 0 ai

#

clanker is not yet at the level where i would let it touch any c code thats not like something that has been solved a billion times before

latent geode
#

some parts of my build system is also llm generated/translated

prime wraith
#

like write a strstr impl etc

prime wraith
#

most of mine is handwritten also

#

since it predates llms

#

being useful

#

neat ig

haughty notch
latent geode
#

mint added it

prime wraith
#

that one is fair because it has 0 ai loc

#

even for scripts/tests etc

sinful river
prime wraith
#

why do u need a bash script?

prime wraith
#

oh yeah i have my python wrapper for initial configuration like that Ill just add a warning there probably

sinful river
#

I hate the kconfiglib UI

#

so that's why I have that

prime wraith
#

arent u using it anyway

#

or do mean u like tui more

sinful river
#

than the python -m menuconfig one

prime wraith
#

i get that one if i just do menuconfig

#
$ which menuconfig
/home/infy/.local/bin/menuconfig
#

all these tools are from kconfiglib i guess

#

but olddefconfig is truly the goat

sinful river
#

what is that

prime wraith
#

it auto-sanitizes the config

#

so i can safely pass it into cmake

sinful river
#

the dark one

prime wraith
#

ah

sinful river
#

it's in kconfig-frontends

#

it's the default one linux uses now too I think

prime wraith
# sinful river what is that
infy@DESKTOP-IGT40G0:/mnt/d/Ultra$ cat .config
CONFIG_MODULES=m
CONFIG_ARCH_X86=y
# CONFIG_ARCH_ARM is not set
# CONFIG_ARCH_RISCV is not set
CONFIG_STUFF=m
# CONFIG_X86_STUF is not set
infy@DESKTOP-IGT40G0:/mnt/d/Ultra$ olddefconfig
.config:1: warning: 'm' is not a valid value for the bool symbol MODULES (defined at Kconfig:3). Assignment ignored.
Loaded configuration '.config'
Configuration saved to '.config'
infy@DESKTOP-IGT40G0:/mnt/d/Ultra$ cat .config
CONFIG_MODULES=y
CONFIG_ARCH_X86=y
# CONFIG_ARCH_ARM is not set
# CONFIG_ARCH_RISCV is not set
CONFIG_STUFF=m
# CONFIG_X86_STUF is not set
#

it also converts =n into is not set, so its always the same to parse

#

basically this thing is amazing

sinful river
#

ah it sanitizes it

#

well I parse =n anyway

prime wraith
#

yeah so u cant insert bullshit values or incorrect values or mess up dependencies etc

#

if u manually edit it

sinful river
#

it's a weird name tho lol

prime wraith
#

it is indeed

ornate jasper
#

do you have static_call in ultra btw?

wide ether
obtuse sparrow
wide ether
#

wat

obtuse sparrow
#

To remove overhead

wide ether
#

you mean inlining?

obtuse sparrow
#

Not really

wide ether
#

that sounds awful

prime wraith
#

if im doing something like that ill do alternatives first

prime wraith
#

it does that for hot paths that would otherwise have to be turned into a retpoline

#

which is slow af

#

its a vulnerability workaround

#

on those cpus u cant use function pointers at all

#

(without it being a vulnerability)

prime wraith
#

In CMake, if you pass multiple separate strings to set(), it creates a list.
When CMake converts a list back into a single string (like when you write it to a file), it automatically joins the list elements with semicolons (;).

Look closely at how you defined the variable:

    set(
        CONFIG_HDR
        "/*\n"                                           # Element 1
        "* Auto-generated kernel configuration header\n" # Element 2
        "* Do not edit manually!\n"                      # Element 3
        "*/\n\n"                                         # Element 4
    )

Because they are separate strings, CMake treats this as an array of 4 items. When it writes them out, it glues them together: Element 1 + ; + Element 2 + ; etc., resulting in those unwanted semicolons.

How to fix it

There are two ways to fix this.

Method 1: Use a single quoted string

Wrap the entire block of text in a single pair of double quotes, rather than four separate strings:

    set(CONFIG_HDR
        "/*\n* Auto-generated kernel configuration header\n* Do not edit manually!\n*/\n\n"
    )

Method 2: Use CMake's "Bracket Syntax" (Recommended)

If you have CMake 3.0 or newer, there is a much cleaner way to write multi-line strings without needing \n or quotes. You use [=[ and ]=].

This tells CMake "Treat everything in here as one exact string, preserving all newlines."

    set(CONFIG_HDR [=[
/*
 * Auto-generated kernel configuration header
 * Do not edit manually!
 */

]=])

This makes writing C-style templates inside CMake much easier to read, and it completely avoids the semicolon/list problem!

#

cmake is a fucking joke lol

#

but on the bright side kconfig integration works way better than expected

#

automatically notices changes + regenerates config.h + detects variable changes and lazily rebuilds only stuff thats actually needed

prime wraith
#

no I wrote that myself trl

#

but yeah clanker is better at cmake than me

ornate jasper
#

cmake is great for like. most things. this is the one where it isn't lol

prime wraith
#

somehow they absolutely fucked up multiline strings

ornate jasper
#

yeah

prime wraith
#

and most languages did tbh

#

zig is the only one i know where it's done well

ornate jasper
#

zig did em good yeah

#

for cmake big strings like that I always preferred template files where possible but idk offhand how well that integrates with variables

#

but also I've not touched cmake in like 8 years now

prime wraith
#

yeah, or ill just write a series of appends

prime wraith
#

I had to add a vscode option to launch a cmake debugger ☠️

ornate jasper
#

oof

prime wraith
#

yeah turns out you shouldnt let it glob recurse itself

sinful river
#

using zon and ncurses

#

because parsing kconfig is actually ass

ornate jasper
#

maybe sometime yeah

sinful river
#

so it'd use its own syntax based on zon

ornate jasper
#

oh if own syntax im def in

#

(also could easily output zon too as an option, that can then be @imported by zig later)

#

is there good zig binds for ncurses?

sinful river
#

something like this

sinful river
#

I'm aware there are zig libraries for TUIs but I'm scared to depend on zig stuff

ornate jasper
#

mhm

sinful river
ornate jasper
#

cool

sinful river
#

idk just a thought I had

ornate jasper
#

yeah no i do like it

sinful river
#

the only annoying part will be the TUI

ornate jasper
#

yeah for sure

sinful river
#

and probably managing dependencies

#

but that shouldnt be too hard (build a DAG)

#

zconfig it should be called

ornate jasper
#

mhm

sinful river
#

idk if I actually want to start work on this right now though

ornate jasper
#

yeah me neither

sinful river
#

but in the future that could be a really cool thing to work on

ornate jasper
#

yeah

#

ill keep the idea in the back of my mind lol

sinful river
#

wouldnt take too long to get an MVP and we can get community backing easily I'm sure

ornate jasper
#

my thing is rn my kernel doesnt need any non-bool options so my existing wacky config setup is fine

sinful river
#

in fact we could get an MVP tonight if I vibecode it but I won't do that

ornate jasper
#

so its a low priority for me

sinful river
prime wraith
sinful river
#

not just for kernel stuff

sinful river
prime wraith
#

range 0 3

sinful river
#

we could have that built in

#

for ReleaseSmall,ReleaseFast,Debug, etc

ornate jasper
#

compiler optimization is already built into build.zig as a thing to pass as an option

sinful river
#

yes

#

but now you get a TUI

#

technically you could all pass this as options

ornate jasper
#

loading from a config could be nice ig yeah

ornate jasper
sinful river
#

the idea is more for larger projects with large configurations

prime wraith
#

ill definitely abuse this for CI

#

have like premade configs for different tests

ornate jasper
sinful river
#
  1. make this popular
  2. tigerbeetle adopts it (VC funded zig startup)
  3. we get sponsored
  4. profit trl
ornate jasper
#

just not a priority for me atm if noone else is also working on it

sinful river
#

id start work on it right now if you wanted to too

#

or well, asap

ornate jasper
#

mhm

sinful river
#

cant take more than like a week right trl

ornate jasper
#

lmaooo

#

im way more into like console prompts than a full TUI personally tbh

sinful river
#

I also thought about that

#

we can detect if ncurses is present during build

#

and if its not then it can be a console prompt

#

linux has that too

#

but it sucks obviously for large configs

ornate jasper
#

oh is ncurses a dynamic library? that kinda sucks

sinful river
#

?

#

I meant more like in the build script we check if we can find ncurses on the system

ornate jasper
#

oh

sinful river
#

and if we can't we fallback to a cli

ornate jasper
#

ah ok

sinful river
#

idk I'll try something and I'll ping you if I can come up with something good

ornate jasper
#

👍

sinful river
#

might not be tonight

prime wraith
#

are u gonna vibe code it

sinful river
#

i have homework

ornate jasper
#

yeah no worries

prime wraith
#

sounds like the perfect thing to vibe code

sinful river
prime wraith
#

khitiara might not like that

ornate jasper
#

if its vibe coded then im not going to be involved or use it personally

sinful river
#

but anyway id need to modify most of it since AIs dont work well with zig

sinful river
#

i dont really have time to invest learning how ncurses works

ornate jasper
#

eh? idk how i feel about that. would be more willing to consume that but idk if id want to be involved then

ornate jasper
#

or just like. maybe a better library than ncurses lmao

sinful river
#

ncurses isnt bad

prime wraith
#

ncurses cant be that hard

sinful river
#

but my problem like I said is mostly portability

#

ncurses works everywhere

#

and is present on most distros by default even

#

I don't wanna vibecode it because I would be ashamed to release something I vibecoded

#

I dont mind vibecoding useless stuff only I play with

prime wraith
#

tbh this json like stuff it can one shot

#

but yeah

#

depends how q&d u want it to be

sinful river
#

it's literally zig syntax

ornate jasper
#

zig has a builtin parser for zon yeah

prime wraith
#

yeah using the zig parser

#

i mean if u give it a predefined format

ornate jasper
sinful river
#

yeah like the only annoying part is gonna be the UI

#

(and the dependency stuff)

ornate jasper
#

mhm

#

ui is always the part part

prime wraith
#

the only downside of using cmake stuff is its really damn slow, especially over wsl with its crappy p9 impl

ornate jasper
#

fwiw when i said console prompts i wasnt talking about cli args i meant readline-type stuff

prime wraith
#

it takes like 5 seconds to reparse the config

#

and regen the header

ornate jasper
prime wraith
#

i could actually build it on windows using clang --target i guess

sinful river
#

linux has that

prime wraith
#

but im too lazy

ornate jasper
sinful river
#

where it goes through every config option individually and asks you

prime wraith
#

yeah this definitely is not gonna brick my pc :clueless:

ornate jasper
#

lmao

#

good luck

prime wraith
#

nah im not installing it

#

they definitely have a billion regressions there

#

it already has a problem waking up from suspend every now and again

#

i have to do a literal power cycle

ornate jasper
#

oof

prime wraith
#

suspend is an unsolved problem in computing

ornate jasper
#

yeah

prime wraith
#

and they made it even more fragile with s2idle

#

to appease microsoft wanting to do stupid background updates

#

anyway im loving how this ended up

ornate jasper
#

hell yeah

prime wraith
#

very happy with the end result and tbh i expected it to be way harder to integrate

ornate jasper
#

yeah config headers are super nice

sinful river
#

I think kconfiglib can auto generate C headers too

#

dunno if you use that

prime wraith
#

yeah it can

#

i dont use it tho

sinful river
#

i parse it on my own and generate a zig file

#

yea

ornate jasper
#

build.zig can generate headers too actually, theres a ConfigHeader step that can take a number of different input formats

prime wraith
#

i just want a bit more control i guess

#

since i have these variables in cmake anyway

ornate jasper
prime wraith
#

Nah it just regex parses the .config to transform that into in local cmake variables and also at the same time appends them into the config.h header

ornate jasper
#

ah

#

(cmakedefine is a special syntax you can use to have cmake do config header processing using cmake variables)

prime wraith
#

i never actually looked into that

#

what does it do exactly

prime wraith
#

ah interesting

#

but then u need someone to put a cmakedefine in there i guess

ornate jasper
#

yeah

prime wraith
#

i know you wouldnt like my parsing logic since the regex was developed by clanker 😭

ornate jasper
#

F

sinful river
#

honestly i dont see why someone would be against AI for something like that

ornate jasper
#

yeah regex is hell on earth i can absolutely understand that case lmao

sinful river
#

didnt humans keep inventing stuff so we have to do less boring work

ornate jasper
#

i wouldnt do it but i can kinda understand using it for regex

prime wraith
#

regex is justifiable i guess

#

but everyone has their own line that they draw for that stuff

ornate jasper
#

my line is different for things ill silently judge, things i wont use, and things i wont do lmao

prime wraith
#

like i wouldnt feel bad if i had vibecoded the entire parser in zig, but i would feel bad if i actually vibecoded something important in the kernel

#

tools/buildsystems/tests is where my line mostly is

ornate jasper
#

my lines are that i wont use them for anything myself, but my i wont use something someone else made using it line is about where yours is for your own use

prime wraith
#

lol

#

that was complicated to parse

ornate jasper
#

yeah ive not been very good at words today lmao

sinful river
#

kinda funny we're three people all not talking in their native language

#

I think

#

unless khitiara you're english native idk

prime wraith
#

isnt khitiara from the us

sinful river
#

idk

ornate jasper
#

im from pennsylvania, usa

#

english is my only non-code language

sinful river
#

americans nooo

ornate jasper
#

(i know german grammar almost completely but my ability to remember vocabulary is approximately null so i dont really speak it)

eternal sparrow
ornate jasper
#

yeah lmao

eternal sparrow
#

My English isn’t even good

sinful river
#

knowing one language

inland wave
#

I'll have you know I know one and know a little bit of another pepekek

prime wraith
prime wraith
#

this is so much more cleaner than random cmake variables scattered everywhere

haughty notch
#

I just have a bunch of makefile targets...

prime wraith
#

L

carmine token
#

Why does the build system not auto detect gcc vs clang?

prime wraith
#

wdym by autodetect

#

its decided by the toolchain file

#

its a user choice

haughty notch
#

How do you compile your kernel in the first place?

prime wraith
#
olddefconfig && mkdir build && cd build && cmake -DCONFIG_FILE=../.config && cmake --build .
#

but i have a python script for covenience that does image generation etc

#

if u select clang it just uses the host clang with --target

#

for gcc it builds one from source

haughty notch
prime wraith
#

fair

#

i dont use any of that stuff

#

I did have to add this check into cmake because it really doesnt like changing the toolchain after configure

#

but i usually just let my build.py create separate directories so i can test different toolchains in parallel

haughty notch
#

My makefiles do that trl

#

Also, I'm using my patched toolchain for both userspace and kernel, so I "can't" use host's toolchain anyway

prime wraith
#

yeah fair

#

no linux abi sucks right trl

#

UX final boss

sinful river
prime wraith
proper tulip
haughty notch
#

at least the bootloader is NIHed trl

proper tulip
#

so is Hyper

sinful river
ornate jasper
#

what does NIH even mean?

latent geode
eternal sparrow
#

Crap

ornate jasper
#

ah ok

latent geode
#

skrill tissue

ornate jasper
#

lol

eternal sparrow
prime wraith
#

Finished improving my python script for Kconfig support

#

It's so convenient now

#

./build.py -> makes a build directory that's build-{toolchain}-{arch}, makes a default config inside the build directory, builds it
./build.py --arch aarch64 -> same thing but replaces defaults with CONFIG_AARCH64
./build.py --config .config -> creates a build-user-config, builds using it
./build.py {--menuconfig,--guiconfig} -> convenience helpers for editing the autogenerated config, also works with --config

#

not to mention it already had --make-image/--run/--debug/--ide-debug etc

#

wait wtf did i do

#

ah nvm

#

also my aarch64 bitrotted 😭

prime wraith
#

fuck, i had the vscode setting that auto trims whitespace off

#

i have to go through a shitload of commits and check all code now

prime wraith
#
try:
    from kconfiglib import Kconfig
except ImportError:
    print("Could not import kconfiglib, trying to install in-place...")

    subprocess.check_call(
        [sys.executable, "-m", "pip", "install", "--user", "kconfiglib"]
    )

    user_site_packages = site.getusersitepackages()
    if user_site_packages not in sys.path:
        sys.path.append(user_site_packages)

    importlib.invalidate_caches()
    from kconfiglib import Kconfig

Least cursed build script

#

it might be cursed but i like when my build stuff does dependency shit itself

sinful river
#

wait what

#

This pip installs kconfig or what

#

cursed

prime wraith
#

yeah

#

the price of not NIHing kconfig

edgy remnant
#

so you don‘t need to pip install stuff

prime wraith
#

vendor how?

edgy remnant
#

like just put the kconfiglib there

prime wraith
#

hell nah

#

im not putting random code into my repo

edgy remnant
#

it‘s a single file, that‘s just what I mean

prime wraith
#

its definitetly not a single file

edgy remnant
#

aside from all the menus

prime wraith
#

i need the menus also

#

otherwise how tf am i supposed to edit it lol

#

and if i have to install menus separately why would I vendor a 7k loc file

edgy remnant
#

well that‘s true then

prime wraith
#

whats interesting is the pip package maintenance was overtaken by zephyr

#

because the guy that originally made the repo abandoned it

#

this is the current repo

#

thanks to zephyr otherwise idk what i would do

edgy remnant
#

I took the kconfig stuff from zephyr too lol

prime wraith
#

whats your os

edgy remnant
#

I‘m redoing a bunch of things and just started reading some os books again so not much to show currently

prime wraith
#

oh ok

#

but u already use kconfig for it?

edgy remnant
#

I had it setup on an old kernel and copied the build system for my new one

prime wraith
#

do u use make?

edgy remnant
#

cmake

prime wraith
#

oh cool

#

so how do u integrate .config into it

edgy remnant
#

iirc it even was a bit of zephyrs cmake, i found the cmake integration on a github repository

prime wraith
#

oh ok

#

i had to do a shit ton of work to make sure it picked up changes to .config and all Kconfig files + sanitized it so that all options are set correctly etc

edgy remnant
#

do you have some sort of fixdeps.c equivalent

prime wraith
#

what is that?

edgy remnant
#

as in the linux tool

prime wraith
#

yeah but what does it do

edgy remnant
prime wraith
#

oh I see

#

it's so that not everything depends on autoconf

#

i dont atm

edgy remnant
#

yes

prime wraith
#

but might be something to look into

#

did u have one?

edgy remnant
#

I found it interesting

edgy remnant
prime wraith
#

ah ok

#

i wanted to optimize it by just using cmake definitions for most common options

edgy remnant
#

though IDK how feasible it is with cmake

prime wraith
#

so that most code can avoid including config.h

#

but its probably not scalable

edgy remnant
#

i mean

#

that wouldn't really remove the dependency, would it?

prime wraith
#

nah it has a diff purpose

#

some options are basically never changed but needed by a lot of code

#

e.g. the current arch, or the current arch bitness

#

or endianness

edgy remnant
#

ah

#

yeah makes sense

#

iirc I just set arch as a cmake option and add a C define

prime wraith
#

but yeah let me know if u figure out how to do that fixdep thing

prime wraith
#

this allows me to include the respective kconfig of the arch subdir etc

#

pretty covenient

edgy remnant
#

true

prime wraith
#

fixdep would probably require digging into cmake internals

edgy remnant
prime wraith
#

to figure out how it does that depepndency stuff

edgy remnant
#

yup

prime wraith
#

may be possible

#

especially with clanker help

edgy remnant
#

kconfiglib includes a function similar to the linux kconfig

#

something something sync directory

prime wraith
#

what does that do?

edgy remnant
#

like this functionality

* kconfig populates a tree in include/config/ with an empty file
 * for each config symbol and when the configuration is updated
 * the files representing changed config options are touched
 * which then let make pick up the changes and the files that use
 * the config symbols are rebuilt.
#

so i think the major challenge is getting the cmake side working

prime wraith
#

interesting

#

yeah that definitely sounds doable

#

so do u vendor kconfiglib or do u expect the user to install it

edgy remnant
#

vendor

prime wraith
#

damn

edgy remnant
#

i pasted that whole library in lol

prime wraith
#

like the entire 8k file?

#

oh lol

edgy remnant
#

ya lol

#

I wouldn't want my build to invoke pip

prime wraith
#

why not?

edgy remnant
#

I'd want to ensure it doesn't break or depend on the network further, though I mean it's possibly cleaner

prime wraith
#

hmm, but don't u have other network dependency like the compiler sources etc?

edgy remnant
#

that's not really part of my kernel build process

sinful river
#

You can always require deps but still have your build fully offline

edgy remnant
#

sure

sinful river
#

Installing network stuff in the build script is a bit stupid tho I agree

prime wraith
#

i kinda hate the alternatives tho

#

just copy paste a 30k loc library trl

edgy remnant
#

i just did it like zephyr :p

prime wraith
#

I could submodule it I suppose

#

but that's also a network dep trl

edgy remnant
#

well

sinful river
prime wraith
sinful river
edgy remnant
#

not part of the build as a literal call to pi

#

copy paste

#

wait

#

jsut checked

prime wraith
#

interesting

edgy remnant
#

kconfiglib doesn't really change much anways

prime wraith
#

and the frontend is 3k

sinful river
#

yes but mine is like 2.5k

edgy remnant
#

kconfiglib is like so much comment

sinful river
#

for now

edgy remnant
prime wraith
# edgy remnant nvm that lol

unironically it's very difficult to parse since options can recursively depend on other options for their values and ranges etc

#

you probably have to make a multi-pass option resolver

#

and run it in a loop as long as you make progress

sinful river
#

kconfig syntax is also like poorly defined

#

It's hard to parse

prime wraith
#

kconfig syntax is whatever linux parser accepts trl

sinful river
#

zonfig with a shitton of { ftw

prime wraith
#

let me know when it supports recursive options trl

prime wraith
# sinful river What is that
config FOO_4
    bool

config FOO_8
    bool

config FOO
    int
    default 4 if FOO_4
    default 8 if FOO_8

config BAR
    int
    range 0 FOO

config X
    def_bool y
    select FOO_4

U can do stuff like that

#

BAR depends on FOO for its value, which is selected only later by X (which may depend on other options for its values)

sinful river
#

idk if thats useful

prime wraith
#

heres an example

#

literally all properties of an option are dynamic

edgy remnant
#

I'll have to look into how linux exactly modifies the dep files

#

also this would only work for makefiles/ninja

prime wraith
edgy remnant
#

yes

#

I atleast removed the generated config header dep already

#

now would just need to scan the file for CONFIG_* stuff, I think that's how linux does it

prime wraith
#

damn

prime wraith
edgy remnant
#

yeah that makes sense of course

prime wraith
#

and the headers it gets from the dep file that the compiler produced

edgy remnant
#

wait right, the compiler generates the file list for you

prime wraith
#

yeah, so this whole thing only starts working after build 1

edgy remnant
#

before build 1 this wouldn't even make sense

#

as the config.h would've just been generated the first time

prime wraith
#

ye

prime wraith
#

@edgy remnant i decided to follow your advice but with a submodule instead of direct copy paste

#

i think thats cleaner

edgy remnant
#

yup

#

i got this dep file thing working

prime wraith
#
  File "/mnt/d/Ultra/scripts/kconfiglib/guiconfig.py", line 263, in _detect_system_dark_mode
    if sys.platform == "win32":
       ^^^
NameError: name 'sys' is not defined. Did you forget to import 'sys'?

wait do they even test their code

#

they use sys without importing it

prime wraith
#

can u show

edgy remnant
prime wraith
#

wait so how do u intercept/overwrite cmake dep files?

edgy remnant
#
set_target_properties(program PROPERTIES C_COMPILER_LAUNCHER
    "python3;${CMAKE_SOURCE_DIR}/fixdep.py;${KCONFIG_SYNC_DIR}")
#

and this one

#

It works only for make and ninja as this LAUNCHER thing is only supported for those two, but I only use ninja anyways

prime wraith
#

interesting

edgy remnant
#

the script removes the config.h from the dep list and adds for every CONFIG_* symbol the stamp file to the dep list

#

it parses the call the CC and if it finds an argument -MF it takes the next arg as <dep file>, if it doesn't find anything I just do nothing

prime wraith
#

makes sense

#

for whatever reason if i call menuconfig not via subprocess but via menuconfig.menuconfig() it starts in some half corrupted state

#
if args.menuconfig or args.guiconfig:
    os.environ["KCONFIG_CONFIG"] = args.config
    module = mc if args.menuconfig else gc
    kconfig = root_kconfig()

    with enter_work_dir(pg.project_root()):
        module.menuconfig(kconfig)
    sys.exit(0)
#

like what does it want from me

#

it parses the options but they're not modifyable

edgy remnant
#

lol what

prime wraith
#

yeah lmao

#

ill just keep using subprocess lmao

#

and ill have to send a pr to fix their crappy guiconfig

edgy remnant
#

which repo do u use

prime wraith
#

u use that repo as well right?

edgy remnant
prime wraith
#

that one is abandoned

edgy remnant
#

ah

prime wraith
#

u use the old one?

edgy remnant
#

i use what zephyr uses lmao

prime wraith
#

why do they have two copies of the same repo??

edgy remnant
#

zephyr doesnt seem to check the changes they do, the old repo does it correctly?

edgy remnant
prime wraith
#

but for some reason the actual kernel has some copy pasted code

#

instead of submoduling this one

edgy remnant
#

yes

#

weird setup idk

#

anyways I checked and my guiconfig still is the version that supports python2

#

i have the version from 2019

prime wraith
#

but they didnt pull in the commit that dropped python2 support

prime wraith
#

menuconfig.py does from Kconfiglib import ..., that was importing Kconfiglib from pip instead of kconfiglib.py, which was causing isinstance checks to fail

#

from .Kconfiglib fixed it lol

edgy remnant
#

ah wow

prime wraith
#

this seems to be the more general fix:

import scripts.kconfiglib.kconfiglib as kc
# Make sure the rest of "import kconfiglib" always references this
sys.modules["kconfiglib"] = kc
edgy remnant
#

also something I noticed with my dep file solution is that a missing kconfig symbol makes it so that the file is recompiled every time lol

#

was wondering why it didn't work but I never added that option to Kconfig

prime wraith
#

oh right

#

but how did it appear in the dep then?

edgy remnant
#

well I used it from actual code

#

I guess I could warn when I encounter non-existant kconfig variables or something like that

prime wraith
#

wouldnt the compilation fail in that case anyway?

#

or well

edgy remnant
#

not if I do something like
#if CONFIG_OPTION
#endif

prime wraith
#

right right

#

its definitely possible to check that it exists yeah

#

although from python it might be slow af

edgy remnant
#

ig this could be helpful to catch typos

prime wraith
#

to run for every source file

edgy remnant
#

as I create a stamp file for every option anyway

prime wraith
#

is it a flat hirerachy?

edgy remnant
#

it turns _ into /

prime wraith
#

wdym

edgy remnant
#

iirc the reasoning from linux was that some filesystems dont like thousands of small files

prime wraith
#

like whats the conversion path from CONFIG_FOO to its location on the fs?

edgy remnant
prime wraith
#

oh ok

#

CONFIG_FOO_BAR is config/foo/bar?

edgy remnant
#

yes

prime wraith
#

linux has flat include/config these days

edgy remnant
#

well I based myself on the 2019 kconfiglib code idk

#

though it's not that big of a difference

#

as in I can easily just change the paths

prime wraith
#

yeah it seems zephyr's one still does that

edgy remnant
prime wraith
edgy remnant
#

yes

#

I extracted the sync_deps stuff and did it seperatly from the kconfiglib.py so that integrating is easier and doesn't require a patched lib

prime wraith
#

ill probably just fork it

#

and fix the sys import + patch to allow configuring deps layout

prime wraith
#

u could just import the function from kconfiglib

edgy remnant
prime wraith
#

like u do from kconfliglib import sync_deps right?

edgy remnant
#

I might want to be able to update kconfiglib or smth idk, seemed better to me

edgy remnant
#

cmake+ninja requires that the file actually exists

#

linux did some sort of makefile wildcard thing that would not require a rebuild if the dep stamp file is not there

#

as would be the case if the option is =n

prime wraith
#

so u copied basically the entire sync_deps code into the script that patches cmake deps?

edgy remnant
#

no that would get so slow

#

as that would need to parse all the kconfig files, no?

prime wraith
#

im just confused as to what u did exactly

#

u have to call sync_deps anyway right

edgy remnant
#

yes