Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It seems like part of decision was reached because of limitations in LLVM[1]. This makes me a bit uneasy, but I guess it has to follow C to meet its goals.

1) "LLVM does support tail call optimization, but it requires using a different calling convention than C and slowing down all function calls" from https://mail.mozilla.org/pipermail/rust-dev/2013-April/00355... and http://llvm.org/docs/CodeGenerator.html#tail-call-optimizati...



They could also add their own calling convention to LLVM to support what they want like GHC and HiPE have done.


No they can't, at least not without compromising on several points laid out in TFA. Mainly these two:

    - Tail calls also "play badly" with assumptions in C 
      tools, including platform ABIs and dynamic linking.

    - Tail calls require a calling convention that is a 
      performance hit relative to the C convention.
See other posts in this discussion for examples of the impacts of some alternate calling convention choices.


Then how can GCC and clang do TCE in C programs?


1) They can't do it all the time

2) Some of the times they can do it, they do it when they control both the caller and the callee. In that case you can violate the ABI to your heart's content.

3) I don't really see TCE as an issue in Rust, since they seem to be going the RAII route and, as others have commented, RAII and TCE don't play well together (for the same reason a call at the end of a dynamic binding can't be TCE'd in common-lisp).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: