C++ Logo

sg14

Advanced search

[SG14] compiler flag sanity check for error handling research

From: Ben Craig <ben.craig_at_[hidden]>
Date: Mon, 4 Feb 2019 01:46:57 +0000
Hi all,


I'm doing some research on the size costs of various error handling techniques (exceptions, return values, std::expected, TLS, etc). I've got builds set up for MSVC, GCC, and Clang, but I would like other people to do a quick sanity check on my compiler and linker flags to make sure I've got things reasonably tuned for size.


My main caveats are as follows:

1) I'm not going to use LTO. My testing has lots of no-op functions, and LTO would make those functions disappear.

2) I _am_ statically linking as much as I can. I want to measure the cost of the runtime components as well as the extra code.

3) Be as conforming as I can, with the exception of toggling exception handling on and off.


With all that out of the way, here are where my flags are currently stored...


MSVC: https://github.com/ben-craig/error_bench/blob/master/windows.ninja#L17

GCC: https://github.com/ben-craig/error_bench/blob/master/gcc.ninja#L7

Clang: https://github.com/ben-craig/error_bench/blob/master/clang.ninja#L7


I am concerned about my current choices of flags because of the large baseline binaries I am getting. `int main() {return 0;}` gets me these rough sizes...


clang -fno-exceptions = ~800K
clang -fexceptions = ~1,200K
gcc -fno-exceptions = ~600K
gcc -fexceptions = ~700K
MSVC (no exceptions) = ~90K
MSVC (/EHs) = ~100K

The wide size disparity has me concerned, and makes me think I'm doing something wrong.

Received on 2019-02-03 19:48:19