# New Driverkit + kernel-crawler multi builder images
## Kernel-crawler
Tries hard to fetch required gcc version and output it in the json.
Sometimes, gcc version that was used to build a kernel can be found in the package metadata.
Other times, we might extract the kernel package and try to find it, using same algo as: https://github.com/draios/probe-builder/blob/dev/probe_builder/builder/choose_builder.py
If none can be found, driverkit will have a fallback logic to choose the GCC version (it should have it anyway, given that it can be run externally from our pipeline, with no kernel-crawler).
## Driverkit
Given a kernelrelease:
* runtime discovery of supported builder images: `docker search` on `facosecurity/driverkit` dockerhub repo
* driverkit will let users configure the list repositories to be searched, in a priority based manner (like, the first repo has higher prio), so that a custom builder images can override a falcosecurity provided one
* builder images will be (template): `driverkit-builder-$target-$arch_$gcc0_$gcc1_$gcc2...`
* found images will be indexed by `$target-$arch-$gcc` for each gcc provided
* falcosecurity will ship some default builder images that will have `$target == "any"`, and will be used as fallback images when no other image is found
* if targetGCC is not user-set (ie: not discovered by kernel-crawler), an internal simple algorithm will try to figure out the correct version based on kernel release + distro
* given all of the above, the algorithm to choose a builder will just be (pseudo GOish code)
```
func findImage(myTarget, myArch, requestedGCC) string {
// Try to find perfect-match
key := myTarget + myArch + requestedGCC
image, ok := imagesMap[key]
if ok {
return image
}
// Try to find a generic image that provides the gcc
anyKey := "any" + myArch + requestedGCC
image, ok := images[key]
if ok {
return image
}
// Try to find image that provides nearest gcc.
// It can be both a specific one(that takes precedence)
// or a generic one,
// we don't care at this point
return findMinimumDistanceImage(requestedGCC, imagesMap)
}
```