Skip to content

Commit fa77442

Browse files
nasamuffingitster
authored andcommitted
bugreport: add compiler info
To help pinpoint the source of a regression, it is useful to know some info about the compiler which the user's Git client was built with. By adding a generic get_compiler_info() in 'compat/' we can choose which relevant information to share per compiler; to get started, let's demonstrate the version of glibc if the user built with 'gcc'. Signed-off-by: Emily Shaffer <[email protected]> Helped-by: Danh Doan <[email protected]> Helped-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d14e00c commit fa77442

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

Documentation/git-bugreport.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The following information is captured automatically:
2727

2828
- 'git version --build-options'
2929
- uname sysname, release, version, and machine strings
30+
- Compiler-specific info string
3031

3132
This tool is invoked via the typical Git setup process, which means that in some
3233
cases, it might not be able to launch - for example, if a relevant config file

bugreport.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "strbuf.h"
55
#include "time.h"
66
#include "help.h"
7+
#include "compat/compiler.h"
78

89
static void get_system_info(struct strbuf *sys_info)
910
{
@@ -25,6 +26,11 @@ static void get_system_info(struct strbuf *sys_info)
2526
uname_info.release,
2627
uname_info.version,
2728
uname_info.machine);
29+
30+
strbuf_addstr(sys_info, _("compiler info: "));
31+
get_compiler_info(sys_info);
32+
strbuf_addstr(sys_info, _("libc info: "));
33+
get_libc_info(sys_info);
2834
}
2935

3036
static const char * const bugreport_usage[] = {

compat/compiler.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef COMPILER_H
2+
#define COMPILER_H
3+
4+
#include "git-compat-util.h"
5+
#include "strbuf.h"
6+
7+
#ifdef __GLIBC__
8+
#include <gnu/libc-version.h>
9+
#endif
10+
11+
static inline void get_compiler_info(struct strbuf *info)
12+
{
13+
int len = info->len;
14+
#ifdef __clang__
15+
strbuf_addf(info, "clang: %s\n", __clang_version__);
16+
#elif defined(__GNUC__)
17+
strbuf_addf(info, "gnuc: %d.%d\n", __GNUC__, __GNUC_MINOR__);
18+
#endif
19+
20+
#ifdef _MSC_VER
21+
strbuf_addf(info, "MSVC version: %02d.%02d.%05d\n",
22+
_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000);
23+
#endif
24+
25+
if (len == info->len)
26+
strbuf_addstr(info, _("no compiler information available\n"));
27+
}
28+
29+
static inline void get_libc_info(struct strbuf *info)
30+
{
31+
int len = info->len;
32+
33+
#ifdef __GLIBC__
34+
strbuf_addf(info, "glibc: %s\n", gnu_get_libc_version());
35+
#endif
36+
37+
if (len == info->len)
38+
strbuf_addstr(info, _("no libc information available\n"));
39+
}
40+
41+
#endif /* COMPILER_H */

0 commit comments

Comments
 (0)