nordlow / compiler-benchmark

Benchmarks compilation speeds of different combinations of languages and compilers.
MIT License
138 stars 18 forks source link

please add cproc for C #4

Closed rofl0r closed 4 years ago

rofl0r commented 4 years ago

https://github.com/michaelforney/cproc

should be several times faster than GCC. (of course, if your goal is to make DMD look good, then you probably don't want to add this :-)

nordlow commented 4 years ago

Thanks. I'll look into it.

nordlow commented 4 years ago

I've built cproc using ./configure and make.

But when I build

int main() { return 0; }

as

./cproc main.c -o main

it errros as

cproc: codegen: spawn "qbe": No such file or directory
cproc: compile: process signaled: Terminated
cproc: preprocess: process signaled: Terminated

Are you saying I should benchmark generation to QBE-IR using cproc-qbe main.c -o main.qbe instead?

rofl0r commented 4 years ago

you need to run "make qbe" and then put the produced qbe binary in qbe/ into your PATH, then run cproc

cproc executable runs qbe as a subprocess (sorry about that)

nordlow commented 4 years ago

That seems awkward. It would be nice if you add an install target to the Makefile that installs both cproc and qbe using an install PREFIX variable called via something like

make PREFIX=~/local/bin install-all

.

rofl0r commented 4 years ago

cproc isnt my project, but i contacted its author regarding this. thanks for your patience!

nordlow commented 4 years ago

Note that D performs a set of extra semantic passes for instance dead code elimination. So you must take into account all those passes or disable them to get a fair comparison.

rofl0r commented 4 years ago

of course: qbe does that too and a lot more. according to its website it's designed to achieve 70% of llvm performance while staying reasonably simple. but since your benchmark focuses on compilation speed, this is where cproc/qbe shine the most: even just compiling cproc itself takes less than one second on my system.

nordlow commented 4 years ago

Nice. I'm gonna have look at QBE.

nordlow commented 4 years ago

of course: qbe does that too and a lot more.

Note quite the same. D-compilers has dead-code elimination in the frontend that can diagnose to the user mistakes in the data flow.

nordlow commented 4 years ago

you need to run "make qbe" and then put the produced qbe binary in qbe/ into your PATH, then run cproc

cproc executable runs qbe as a subprocess (sorry about that)

I suppose you mean put the qbe/obj/qbe into the path.

nordlow commented 4 years ago

Ok, I build qbe aswell and put into the path.

When I build

int main(void) { return 0; }

as

cproc f.c -o f

it fails during linking as

//usr/lib/x86_64-linux-gnu/crt1.o:function _start: error: undefined reference to 'main'
cproc: link: process 402367 exited with status 1
nordlow commented 4 years ago

Is there a flag to to perform syntax only like -fsyntax-only in GCC?

michaelforney commented 4 years ago

Thanks for taking a look at cproc!

I'm not sure what's going wrong during linking. Could you provide your system details, and also the output of cproc -v f.c -o f?

according to its website it's designed to achieve 70% of llvm performance while staying reasonably simple

I think this is more of an aspirational goal, I am not exactly sure how close it is to meeting that goal.

Is there a flag to to perform syntax only like -fsyntax-only in GCC?

Not currently, no.

michaelforney commented 4 years ago

Thinking about -fsyntax-only, I think you could get part of the way there using -emit-qbe -o /dev/null. That would still generate QBE IL, but skip running qbe itself.

nordlow commented 4 years ago

Thinking about -fsyntax-only, I think you could get part of the way there using -emit-qbe -o /dev/null. That would still generate QBE IL, but skip running qbe itself.

Seems like a good idea. Hang on. I'll update ./benchmark.

Update: I've updated now. It runs both a compile to machine code and an emit of qbe.

rofl0r commented 4 years ago

Update: I've updated now. It runs both a compile to machine code and an emit of qbe.

cool! looking forward to see cproc results in README.md

nordlow commented 4 years ago

cool! looking forward to see cproc results in README.md

However cproc hangs (enters an infinte loop?) for

./benchmark --languages=C --function-count=20 --function-depth=46 --run-count=1

but not for

./benchmark --languages=C --function-count=20 --function-depth=45 --run-count=1

Happens both with and without the -emit-qbe flag.

So I can't get any interesting benchmarks.

michaelforney commented 4 years ago

I'm unable to reproduce the hang on my system. I will try on ubuntu 20.04, since that is what the install script mentions.

nordlow commented 4 years ago

I'm unable to reproduce the hang on my system. I will try on ubuntu 20.04, since that is what the install script mentions.

Strange.

Yes, I'm sitting on Ubuntu 20.04.

Hangs for

./benchmark --languages=C --function-count=21 --function-depth=45 --run-count=1

aswell.

michaelforney commented 4 years ago

Hmm... I don't seem to be able to reproduce on Ubuntu 20.04 either: https://builds.sr.ht/~mcf/job/307438

If it's not too much trouble, could you use gdb -p to attach to the hung process and get a backtrace?

nordlow commented 4 years ago

I had a dirty checkout. Things work now. Sorry for the wait. I'll update the numbers soon.

nordlow commented 4 years ago

One thing. cproc forgets to set executable permissions on outputted executable on Linux.

michaelforney commented 4 years ago

One thing. cproc forgets to set executable permissions on outputted executable on Linux.

cproc just calls the system linker, which should be setting the appropriate executable permissions. I tested lld and GNU ld, and both create a binary with the executable bit set, so I'm not sure why it isn't getting set for you.

rofl0r commented 4 years ago

thanks, closing this now as https://github.com/nordlow/compiler-benchmark/commit/7f64bbb41a9b32948e608dade4b15b9dabbcb6cb has been committed.