GCC explicitly has exceptions in the license for code that it inserts into your program during compilation.
https://www.gnu.org/licenses/gcc-exception-3.1.en.html
Also, I’d like to complain about your terminology—I don’t think “infected” is the right term. I think it’s a bit unfortunate that the word caught on. You’re never infected by the engine’s license, because you are never forced to use the same license.
It’s also not a question of whether you are extending the source itself, but whether you are creating a work based on something which is GPL. Extending the source of an engine makes it clear and unambiguous that you are making something based on the engine, but it’s not the only way. An engine really isn’t a tool. You can’t interact with the engine and a game made with it separately. You can’t really swap out engines. There’s not a ton of case law exploring this, though.