0

I'm looking for gcc and clang compiler options that effectively tell the compiler to emit constant-time object code. Ideally there'd be a compiler option equivalent to -Os that instead of optimizing for size, optimizes for constant-timeness of the emitted code. Current compilers to my knowledge do not provide such an option, so what I'm asking for really is a set of compiler options that would have a similar effect.

nebel
  • 171
  • 12
  • 2
    I think you have answered your own question: gcc and clang do not support this. It would necessarily limit you to a subset of C with no loops except maybe obviously constant ones. – Nate Eldredge Jul 31 '21 at 18:59
  • Basically a duplicate of https://stackoverflow.com/questions/68327985/require-compiler-to-emit-branchless-constant-time-code, which is unanswered but has comments explaining that it's not feasible. – Nate Eldredge Aug 01 '21 at 17:28
  • Well I was thinking of options such as `-ftree-loop-if-convert` (`gcc`) that can have such an effect on the emitted code. Unlike the linked question, I'm not looking for a perfect solution. – nebel Aug 02 '21 at 19:02

0 Answers0