I noticed that the command being executed has the -ldl out of place w.r.t. the source code.
[DEBUG] command: "/usr/bin/cc" "-Wl,-dynamic-linker,/lib64/ld-linux-x86-64.so.2" "-ldl" "-o" "/tmp/magicpak_resolver_14160520991579680778_3249826909874418912" "-xc" "/tmp/.tmpsNXfuc"
However, the following command succeeds:
$ "/usr/bin/cc" "-Wl,-dynamic-linker,/lib64/ld-linux-x86-64.so.2" "-o" "/tmp/magicpak_resolver_14160520991579680778_3249826909874418912" "-xc" "/tmp/.tmpsNXfuc" "-ldl"
$ echo $?
0
My current workaround is to create a wrapper script around GCC with a hardcoded -ldl as the last option and pass it to magicpack using --cc.