ossama-othman / MaRC

MaRC - Map Reprojections and Conversions
GNU Lesser General Public License v2.1
1 stars 0 forks source link

Use of spdlog increases object file sizes significantly #96

Closed ossama-othman closed 5 years ago

ossama-othman commented 6 years ago

Describe the bug MaRC Object file sizes corresponding to source files that use the new spdlog based logging have increased significantly.

To Reproduce Steps to reproduce the behavior:

  1. Include <MaRC/Log.h> to pull in spdlog:

Without Spdlog

$ git diff lib/MaRC/Mercator.cpp
diff --git a/lib/MaRC/Mercator.cpp b/lib/MaRC/Mercator.cpp
index 6f9b5d3..86e860a 100644
--- a/lib/MaRC/Mercator.cpp
+++ b/lib/MaRC/Mercator.cpp
@@ -27,7 +27,7 @@
 #include "Mathematics.h"
 #include "root_find.h"
 #include "OblateSpheroid.h"
-#include "Log.h"
+// #include "Log.h"

 #include <functional>
 #include <limits>
$ size lib/MaRC/.libs/libMaRC_la-Mercator.o 
   text    data     bss     dec     hex filename
   3339     168       0    3507     db3 lib/MaRC/.libs/libMaRC_la-Mercator.o

In this case, the source file did not perform any spdlog based logging, and merely included <MaRC/Log.h> to pull in the MaRC logging function templates that are implemented in terms of spdlog. The function templates in question aren't used in the source file, meaning the observed increase in object file size should be brought on by including <spdlog/spdlog.h>.

With Spdlog

$ size lib/MaRC/.libs/libMaRC_la-Mercator.o 
   text    data     bss     dec     hex filename
  61074    3961    1240   66275   102e3 lib/MaRC/.libs/libMaRC_la-Mercator.o

With spdlog we go from a total binary size of 3507 bytes to 66275.

Expected behavior Some increase in binary size is expected, but the order of magnitude increase was unexpected. Ideally, the binary size should not increase so much.

Desktop (please complete the following information):

Additional context See the related question I posted to the spdlog repository at gabime/spdlog#774.

ossama-othman commented 6 years ago

Assuming the size increase caused by using spdlog can't addressed any time soon, switching to simple logging directly through fmtlib is probably the better way to go.