buildinfo.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * Return a string describing everything we know about how this
  3. * particular binary was built: from what source, for what target
  4. * platform, using what tools, with what settings, etc.
  5. */
  6. #include "putty.h"
  7. char *buildinfo(const char *newline)
  8. {
  9. strbuf *buf = strbuf_new();
  10. put_fmt(buf, "Build platform: %d-bit %s",
  11. (int)(CHAR_BIT * sizeof(void *)), BUILDINFO_PLATFORM);
  12. #ifdef __clang_version__
  13. #define FOUND_COMPILER
  14. put_fmt(buf, "%sCompiler: clang %s", newline, __clang_version__);
  15. #elif defined __GNUC__ && defined __VERSION__
  16. #define FOUND_COMPILER
  17. put_fmt(buf, "%sCompiler: gcc %s", newline, __VERSION__);
  18. #endif
  19. #if defined _MSC_VER
  20. #ifndef FOUND_COMPILER
  21. #define FOUND_COMPILER
  22. put_fmt(buf, "%sCompiler: ", newline);
  23. #else
  24. put_fmt(buf, ", emulating ");
  25. #endif
  26. put_fmt(buf, "Visual Studio");
  27. #if 0
  28. /*
  29. * List of _MSC_VER values and their translations taken from
  30. * https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  31. *
  32. * The pointless #if 0 branch containing this comment is there so
  33. * that every real clause can start with #elif and there's no
  34. * anomalous first clause. That way the patch looks nicer when you
  35. * add extra ones.
  36. *
  37. * Mostly you can tell the version just from _MSC_VER, but in some
  38. * cases, two different compiler versions have the same _MSC_VER
  39. * value, and have to be distinguished by _MSC_FULL_VER.
  40. */
  41. #elif _MSC_VER == 1933
  42. put_fmt(buf, " 2022 (17.3)");
  43. #elif _MSC_VER == 1932
  44. put_fmt(buf, " 2022 (17.2)");
  45. #elif _MSC_VER == 1931
  46. put_fmt(buf, " 2022 (17.1)");
  47. #elif _MSC_VER == 1930
  48. put_fmt(buf, " 2022 (17.0)");
  49. #elif _MSC_VER == 1929 && _MSC_FULL_VER >= 192930100
  50. put_fmt(buf, " 2019 (16.11)");
  51. #elif _MSC_VER == 1929
  52. put_fmt(buf, " 2019 (16.10)");
  53. #elif _MSC_VER == 1928 && _MSC_FULL_VER >= 192829500
  54. put_fmt(buf, " 2019 (16.9)");
  55. #elif _MSC_VER == 1928
  56. put_fmt(buf, " 2019 (16.8)");
  57. #elif _MSC_VER == 1927
  58. put_fmt(buf, " 2019 (16.7)");
  59. #elif _MSC_VER == 1926
  60. put_fmt(buf, " 2019 (16.6)");
  61. #elif _MSC_VER == 1925
  62. put_fmt(buf, " 2019 (16.5)");
  63. #elif _MSC_VER == 1924
  64. put_fmt(buf, " 2019 (16.4)");
  65. #elif _MSC_VER == 1923
  66. put_fmt(buf, " 2019 (16.3)");
  67. #elif _MSC_VER == 1922
  68. put_fmt(buf, " 2019 (16.2)");
  69. #elif _MSC_VER == 1921
  70. put_fmt(buf, " 2019 (16.1)");
  71. #elif _MSC_VER == 1920
  72. put_fmt(buf, " 2019 (16.0)");
  73. #elif _MSC_VER == 1916
  74. put_fmt(buf, " 2017 version 15.9");
  75. #elif _MSC_VER == 1915
  76. put_fmt(buf, " 2017 version 15.8");
  77. #elif _MSC_VER == 1914
  78. put_fmt(buf, " 2017 version 15.7");
  79. #elif _MSC_VER == 1913
  80. put_fmt(buf, " 2017 version 15.6");
  81. #elif _MSC_VER == 1912
  82. put_fmt(buf, " 2017 version 15.5");
  83. #elif _MSC_VER == 1911
  84. put_fmt(buf, " 2017 version 15.3");
  85. #elif _MSC_VER == 1910
  86. put_fmt(buf, " 2017 RTW (15.0)");
  87. #elif _MSC_VER == 1900
  88. put_fmt(buf, " 2015 (14.0)");
  89. #elif _MSC_VER == 1800
  90. put_fmt(buf, " 2013 (12.0)");
  91. #elif _MSC_VER == 1700
  92. put_fmt(buf, " 2012 (11.0)");
  93. #elif _MSC_VER == 1600
  94. put_fmt(buf, " 2010 (10.0)");
  95. #elif _MSC_VER == 1500
  96. put_fmt(buf, " 2008 (9.0)");
  97. #elif _MSC_VER == 1400
  98. put_fmt(buf, " 2005 (8.0)");
  99. #elif _MSC_VER == 1310
  100. put_fmt(buf, " .NET 2003 (7.1)");
  101. #elif _MSC_VER == 1300
  102. put_fmt(buf, " .NET 2002 (7.0)");
  103. #elif _MSC_VER == 1200
  104. put_fmt(buf, " 6.0");
  105. #else
  106. put_fmt(buf, ", unrecognised version");
  107. #endif
  108. put_fmt(buf, ", _MSC_VER=%d", (int)_MSC_VER);
  109. #ifdef _MSC_FULL_VER
  110. put_fmt(buf, ", _MSC_FULL_VER=%d", (int)_MSC_FULL_VER);
  111. #endif
  112. #endif
  113. #ifdef BUILDINFO_GTK
  114. {
  115. char *gtk_buildinfo = buildinfo_gtk_version();
  116. if (gtk_buildinfo) {
  117. put_fmt(buf, "%sCompiled against GTK version %s",
  118. newline, gtk_buildinfo);
  119. sfree(gtk_buildinfo);
  120. }
  121. }
  122. #endif
  123. #if defined _WINDOWS
  124. {
  125. int echm = has_embedded_chm();
  126. if (echm >= 0)
  127. put_fmt(buf, "%sEmbedded HTML Help file: %s", newline,
  128. echm ? "yes" : "no");
  129. }
  130. #endif
  131. #if defined _WINDOWS && defined MINEFIELD
  132. put_fmt(buf, "%sBuild option: MINEFIELD", newline);
  133. #endif
  134. #ifdef NO_IPV6
  135. put_fmt(buf, "%sBuild option: NO_IPV6", newline);
  136. #endif
  137. #ifdef NO_GSSAPI
  138. put_fmt(buf, "%sBuild option: NO_GSSAPI", newline);
  139. #endif
  140. #ifdef STATIC_GSSAPI
  141. put_fmt(buf, "%sBuild option: STATIC_GSSAPI", newline);
  142. #endif
  143. #ifdef UNPROTECT
  144. put_fmt(buf, "%sBuild option: UNPROTECT", newline);
  145. #endif
  146. #ifdef FUZZING
  147. put_fmt(buf, "%sBuild option: FUZZING", newline);
  148. #endif
  149. #ifdef DEBUG
  150. put_fmt(buf, "%sBuild option: DEBUG", newline);
  151. #endif
  152. put_fmt(buf, "%sSource commit: %s", newline, commitid);
  153. return strbuf_to_str(buf);
  154. }