Most benchmarks for compilation that I've seen, Apple Silicon tends to outcompete its x86 counterparts. Geekbench actually has a compilation subtest in it, look for "Clang". Here's an example for the two computers:
Benchmark results for a Mac mini (2024) with an Apple M4 Pro processor.
browser.geekbench.com
Benchmark results for a Micro-Star International Co., Ltd. MS-7E12 with an AMD Ryzen 7 7800X3D processor.
browser.geekbench.com
M4 Pro Clang (Multicore): 33942
7800X3d Clang (Mutlicore): 23497
Obviously here the M4 Pro is expected to compile things faster than the 7800X3D by quite a bit. You'd have to give a bit more detail as to your compiler/linker to know why the behavior you observed was different in your actual workflow. (Edit: I see you've replied since I started typing)
In general, Geekbench 6 gives a decent overview of a variety of different workloads. There are two things to keep in mind however. First, is that the multicore tests are not all equal. Some, like Clang, are embarrassingly parallel but others are deliberately designed to mimic "work-sharing" algorithms where the benefits of multiple cores plateaus after a while. Jon Poole, the head of Geekbench's dev Primate Labs, has stated this was to mimic real life desktop processes that many consumers commonly run and to avoid chipmakers and manufacturers from using Geekbench to push multicore systems that most users don't need or even cause them to buy worse systems (because lightly threaded and single threaded applications can suffer). However, if you are doing dev work that concern might apply less you to and instead of looking at the overall score which is a arithmetic and geometric mean of various subscores, you should focus on the subscores that matter most to you. Here is a manual for Geekbench and what each of the tests does:
The second thing is that Geekbench subtests are very, very short. Generally this favors x86 processors which often have very high instantaneous turbo boost modes that ARM and Apple lack, so that wouldn't exaggerate the Apple processor's but is still something to, again, keep in mind when looking at GB6 scores.
Compiler speed differences will probably come from the Ryzen having extensions (and thus optimizations) the M4 simply lacks: like AVX and SSE. X3Ds also obviously have much larger caches (3x bigger than the M4 Pro I'd guess.) Also depends on if you're using the same compiler/linker.
I think really only the last one, the compiler/linker applies. M4 has NEON extensions but regardless most of those vector processors don't come into play in integer heavy tasks like compilation as far as I know - they're designed to speed up floating point operations. Further, X3D is mostly beneficial for gaming not productivity, but I'll admit that's a generalization and I don't know about compilation in particular. Prior to the current Ryzens in fact they were typically seen as slower than the non-X3D models for productivity because clock speeds had to be lowered to compensate for the extra cache dies.
Thanks for the info, I did not know that.
I used gcc compiler.
I can see clang in geekbench results, and the MBP is 75% faster. However, I compiled tor from source and the ryzen was faster.
I'm wondering whether I should try something with much bigger compile times. Any suggestions?
Even if you are using gcc on the Mac, did you actually download and point to gcc? For instance, I haven't but I can still compile something typing in "gcc ...." and my Mac will simply silently switch that to use the default clang compiler.
I found this list of compiler benchmarks, some longer some shorter, most (but not all) multiplatform:
openbenchmarking.org
Here's a video of someone doing code compilation tests, not your particular models but still, it should give you a sense of what should be: