git clone https://github.com/eembc/coremark.git
cd coremark
export PATH=<path to zig>:$PATH
make clean && make && cat run1.log
make clean && CC="zig cc" make && cat run1.log
I’m not sure what you think is interesting about this.
Does it give lower CoreMark ratings than clang?
Because if you’re racing clang and gcc that has nothing to do with Zig. If you wanted to race clang and zig cc and the scores were substantially different, that might be interesting.
The medium-term plan for Zig is for the LLVM dependency, and therefore the zig cc compiler, to be an optional part of a Zig system. The main issue is #16720, which links to the rest of them.
By that same token it might well be possible to provide gcc as an option for integrating with Zig, but that would be a lot of work which interested parties would have to do.
In the meantime, when you invoke zig cc, you get clang. GCC and clang have a lot of people working hard to make them efficient, some benchmarks favor one, some favor the other.
What I meant to indicate is just that Zig as a language can’t do anything about that. Even if the team wanted to take some time to buff up zig cc performance, that would have to be done by improving clang or LLVM, not Zig.
A difference between zig cc and clang, however, might be actionable. But for structural reasons it’s also unlikely.
if that’s the case, why would there ever be a difference between zig cc and clang (assuming the same LLVM version)???
i’m also a little confused by this issue, which suggests there is a difference… sounds like one could/should use zig build-exe over zig cc to gain finer control over optimization???
but let’s pop back up and allow me to ask the following question:
given a body of legacy C code (eg, CoreMark), how to i generate the “fastest” executable using zig without modifying the sources???
while CoreMark is nominally used to measure CPU performance, in practice it has become a standard C compiler benchmark per se… using whatever combination of (zig build-exe) options it takes, how would i maximize speed over space???
i’m less concerned how the various -O? options map… anytime i move to a “new” C compiler, i’m well prepared to make whatever adjustments are needed to maximize performance…