Re: [PATCH v8 06/15] bugreport: add compiler info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Emily Shaffer <emilyshaffer@xxxxxxxxxx> writes:

> @@ -24,6 +25,10 @@ static void get_system_info(struct strbuf *sys_info)
>  			    uname_info.release,
>  			    uname_info.version,
>  			    uname_info.machine);
> +
> +	strbuf_addstr(sys_info, "compiler info: ");
> +	get_compiler_info(sys_info);
> +	strbuf_complete_line(sys_info);
>  }
>  
>  static const char * const bugreport_usage[] = {
> diff --git a/compat/compiler.h b/compat/compiler.h
> new file mode 100644
> index 0000000000..ef41177233
> --- /dev/null
> +++ b/compat/compiler.h
> @@ -0,0 +1,27 @@
> +#ifndef COMPILER_H
> +#define COMPILER_H
> +
> +#include "git-compat-util.h"
> +#include "strbuf.h"
> +
> +#ifdef __GLIBC__
> +#include <gnu/libc-version.h>
> +
> +static inline void get_compiler_info(struct strbuf *info)
> +{
> +	strbuf_addf(info, "glibc: %s\n", gnu_get_libc_version());
> +#ifdef __GNUC__
> +	strbuf_addf(info, "gnuc: %d.%d\n", __GNUC__, __GNUC_MINOR__);
> +#endif
> +}
> +
> +#else
> +
> +static inline void get_compiler_info(struct strbuf *info)
> +{
> +	strbuf_addstr(info, "get_compiler_info() not implemented");

i18n/l10n?  Also don't deliberately leave the buffer end with an
incomplete line like so---doing so _requires_ the caller above to
have strbuf_complete_line() call, but there is no reason to do so.

strbuf_complete_line() does make sense if you insert something that
is not controlled by us (e.g. "Please type whatever other comments
you may have" to let the user give us free-form text, which may or
may not end with a complete line), but otherwise it probably is a
sign of being unnecessary sloppy.

> +}

OK, so the idea is to insert "#elif ..." and definition of
get_compiler_info() for non GLIBC systems?

I am not sure why you want to make this a header with static inline
implementations.  Is it expected for this to be included from
multiple source files?  It would be more understandable if these
were in the same file as where get_system_info() is, perhaps
immediately before that function.

Also, it would probably be easier to manage if you have two separate
helpers, one for what compiler is in use, and the other for what
libc is in use.

> +
> +#endif
> +
> +#endif /* COMPILER_H */

Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux