Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

SDK • Re: Building several applications without recompiling the sdk

$
0
0
The SDK is specifically designed to be included with Pico projects as an "interface library", not a precompiled library. Interface libraries can greatly improve runtime performance.

As an interface library, the parts of the SDK that your project needs get pulled in as source code and compiled along with your project. Because the SDK routines you need are pulled in as source code, the compiler can perform lots of useful optimizations as it compiles because it can see what you are trying to do at compile time, not runtime. For example, something as simple as calling an SDK routine to set a GPIO would need to be a subroutine call if the SDK were precompiled. A real subroutine call would require the compiler to emit instructions to put the arguments to the GPIO call into the right call registers, and then the call and return instructions themselves, maybe even some instructions to save and restore temporary registers inside the routine being called. But when the GPIO SDK code gets compiled with your own program, the compiler has the freedom (and the ability!) to convert those calls to set a GPIO to be just the machine instructions required to set the GPIO. And if the GPIO pin you reference is a constant, then as an interface library, the compiler can do even better. So instead of a whole bunch of instructions to set a GPIO, it's just a couple with an interface library.

The bottom line: Interface libraries give you better runtime efficiency at the cost of increased compile time. But if you are using something like make or CMake to build your code, the build process is only slow the first time.

Statistics: Posted by mookiedog — Sat Feb 15, 2025 12:21 am



Viewing all articles
Browse latest Browse all 8621

Trending Articles