Re: [PATCH v8 06/15] bugreport: add compiler info
- From
Danh Doan <congdanhqx@gmail.com>
- Date
- Feb 20, 2020, 02:49 UTC
- Message-ID
- <20200220024903.GC8390@danh.dev>
- In-Reply-To
- <20200220015858.181086-7-emilyshaffer@google.com>
On 2020-02-19 17:58:49-0800, Emily Shaffer <emilyshaffer@google.com> wrote:
Show 21 quoted lines
> 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__);
> +#endifI think we're better having
- get_compiler_info placed under #ifdef __GNUC__ gate, - get_libc_info under #ifdef __GLIBC
Then have a function to merge those information together. Correct me if I were wrong, as it is now, this is only useful for Linux people with glibc.
Anyway, clang also defines __GNUC__ and __GNUC_MINOR__, IIRC, FreeBSD people started to move to use clang instead of gcc as their default compiler.
Gentoo forks are also known to use clang to compile their ports.
-- Danh