This was still bugging me enough that I went ahead and tracked down the call chain.
The filter update script imports dns.asyncresolver, which in turn imports trio (/usr/local/lib/python3.9/site-packages/trio/_core/_thread_cache.py). Trio needs the pthread library, so it calls ctypes.util.find_library("pthread"), which in turn calls _findLib_gcc.
_findLib_gcc in /usr/local/lib/python3.9/ctypes/util.py is what ends up invoking the c compiler, it apparently tries to compile a test program with the library in question to determine if the library exists. This does seem like unwanted behavior on a firewall, but I'm not 100% sure how to get rid of it given the call chain.
The filter update script imports dns.asyncresolver, which in turn imports trio (/usr/local/lib/python3.9/site-packages/trio/_core/_thread_cache.py). Trio needs the pthread library, so it calls ctypes.util.find_library("pthread"), which in turn calls _findLib_gcc.
_findLib_gcc in /usr/local/lib/python3.9/ctypes/util.py is what ends up invoking the c compiler, it apparently tries to compile a test program with the library in question to determine if the library exists. This does seem like unwanted behavior on a firewall, but I'm not 100% sure how to get rid of it given the call chain.