upvote
AFAIK, GCC toolchain does not have a separate partial evaluator, so how do you do it?
reply
GDB, calling C code from the interactive prompt?

Even though it is its own project, most folks use it alongside GCC.

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Calli...

reply
That is not Partial Evaluation but interactive REPL evaluation. See also https://news.ycombinator.com/item?id=50609165

For Partial Evaluation, you must generate a "residual" version of the original program by specialization where all static data is already bound and evaluated.

Simplest example would be compiling in configuration parameters, so a specific code-path is preselected before runtime. Another classic example would be C++ template meta-programming where that part of the program is not evaluated at runtime.

I first came to know of these techniques from the classic Generative Programming: Methods, Tools, and Applications by Krzysztof Czarnecki and Ulrich W. Eisenecker which is still relevant today.

Checking with Google, it seems GCC does not have a separate partial evaluator but one can use coding techniques+aggressive optimization switches to approximate it. For separate "Futamura Projection" like partial evaluators there seem to be C-Mix/LLPE etc.

reply