[OE-core] [PATCH 2/6] gcc: strip line numbers from generated code in gcc-plugins on target

Khem Raj raj.khem at gmail.com
Wed Mar 11 17:20:53 UTC 2020



On 3/10/20 4:28 PM, Richard Purdie wrote:
> From: Ross Burton <ross.burton at intel.com>
> 
> The line numbers are influenced by the gcc version on the host used to generate
> the code. Remove these to ensure the shipped source code is the same.
> 

Please send this paatch to gcc mailing lists for review, I am not sure 
if this will cause regressions for plugin writers since it does not seem 
simple debug info that it is adding, and external plugins might rely on 
this information. While I understand it might solve our usecaase its a 
kind of patch that I worry about to carry out of tree.

> Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
> ---
>   meta/recipes-devtools/gcc/gcc-9.2.inc         |   1 +
>   .../gcc/gcc-9.2/gen-no-line-numbers.patch     | 170 ++++++++++++++++++
>   2 files changed, 171 insertions(+)
>   create mode 100644 meta/recipes-devtools/gcc/gcc-9.2/gen-no-line-numbers.patch
> 
> diff --git a/meta/recipes-devtools/gcc/gcc-9.2.inc b/meta/recipes-devtools/gcc/gcc-9.2.inc
> index 2bae85afe3a..2368f358675 100644
> --- a/meta/recipes-devtools/gcc/gcc-9.2.inc
> +++ b/meta/recipes-devtools/gcc/gcc-9.2.inc
> @@ -70,6 +70,7 @@ SRC_URI = "\
>   	   file://CVE-2019-15847_2.patch \
>   	   file://CVE-2019-15847_3.patch \
>              file://re-PR-target-91102-aarch64-ICE-on-Linux-kernel-with-.patch \
> +           file://gen-no-line-numbers.patch \
>   "
>   S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}"
>   SRC_URI[md5sum] = "3818ad8600447f05349098232c2ddc78"
> diff --git a/meta/recipes-devtools/gcc/gcc-9.2/gen-no-line-numbers.patch b/meta/recipes-devtools/gcc/gcc-9.2/gen-no-line-numbers.patch
> new file mode 100644
> index 00000000000..8e2c3f58095
> --- /dev/null
> +++ b/meta/recipes-devtools/gcc/gcc-9.2/gen-no-line-numbers.patch
> @@ -0,0 +1,170 @@
> +Inserting line numbers into generated code means its not always reproducible wth
> +differing versions of host gcc. Void the issue by not adding these.
> +
> +Upstream-Status: Inappropriate [OE Reproducibility specific]
> +Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
> +
> +diff --git a/gcc/gengtype.c b/gcc/gengtype.c
> +index 53317337c..bbb261516 100644
> +--- a/gcc/gengtype.c
> ++++ b/gcc/gengtype.c
> +@@ -991,7 +991,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt,
> + /* Create a fake field with the given type and name.  NEXT is the next
> +    field in the chain.  */
> + #define create_field(next,type,name) \
> +-    create_field_all (next,type,name, 0, this_file, __LINE__)
> ++    create_field_all (next,type,name, 0, this_file, 0)
> +
> + /* Like create_field, but the field is only valid when condition COND
> +    is true.  */
> +@@ -1024,7 +1024,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name,
> + }
> +
> + #define create_optional_field(next,type,name,cond)	\
> +-       create_optional_field_(next,type,name,cond,__LINE__)
> ++       create_optional_field_(next,type,name,cond,0)
> +
> + /* Reverse a linked list of 'struct pair's in place.  */
> + pair_p
> +@@ -5186,7 +5186,7 @@ main (int argc, char **argv)
> +       /* These types are set up with #define or else outside of where
> +          we can see them.  We should initialize them before calling
> +          read_input_list.  */
> +-#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__; \
> ++#define POS_HERE(Call) do { pos.file = this_file; pos.line = 0; \
> + 	Call;} while (0)
> +       POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
> +       POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));
> +diff --git a/gcc/genmodes.c b/gcc/genmodes.c
> +index f33eefa24..07bef9eeb 100644
> +--- a/gcc/genmodes.c
> ++++ b/gcc/genmodes.c
> +@@ -429,7 +429,7 @@ complete_all_modes (void)
> + }
> +
> + /* For each mode in class CLASS, construct a corresponding complex mode.  */
> +-#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, __LINE__)
> ++#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, 0)
> + static void
> + make_complex_modes (enum mode_class cl,
> + 		    const char *file, unsigned int line)
> +@@ -487,7 +487,7 @@ make_complex_modes (enum mode_class cl,
> + /* For all modes in class CL, construct vector modes of width
> +    WIDTH, having as many components as necessary.  */
> + #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W) \
> +-  make_vector_modes (MODE_##C, #PREFIX, W, __FILE__, __LINE__)
> ++  make_vector_modes (MODE_##C, #PREFIX, W, __FILE__, 0)
> + #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W)
> + static void ATTRIBUTE_UNUSED
> + make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
> +@@ -538,7 +538,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
> + /* Create a vector of booleans called NAME with COUNT elements and
> +    BYTESIZE bytes in total.  */
> + #define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \
> +-  make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__)
> ++  make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, 0)
> + static void ATTRIBUTE_UNUSED
> + make_vector_bool_mode (const char *name, unsigned int count,
> + 		       unsigned int bytesize, const char *file,
> +@@ -560,7 +560,7 @@ make_vector_bool_mode (const char *name, unsigned int count,
> + /* Input.  */
> +
> + #define _SPECIAL_MODE(C, N) \
> +-  make_special_mode (MODE_##C, #N, __FILE__, __LINE__)
> ++  make_special_mode (MODE_##C, #N, __FILE__, 0)
> + #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
> + #define CC_MODE(N) _SPECIAL_MODE (CC, N)
> +
> +@@ -573,7 +573,7 @@ make_special_mode (enum mode_class cl, const char *name,
> +
> + #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
> + #define FRACTIONAL_INT_MODE(N, B, Y) \
> +-  make_int_mode (#N, B, Y, __FILE__, __LINE__)
> ++  make_int_mode (#N, B, Y, __FILE__, 0)
> +
> + static void
> + make_int_mode (const char *name,
> +@@ -586,16 +586,16 @@ make_int_mode (const char *name,
> + }
> +
> + #define FRACT_MODE(N, Y, F) \
> +-	make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, __LINE__)
> ++	make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, 0)
> +
> + #define UFRACT_MODE(N, Y, F) \
> +-	make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, __LINE__)
> ++	make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, 0)
> +
> + #define ACCUM_MODE(N, Y, I, F) \
> +-	make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, __LINE__)
> ++	make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, 0)
> +
> + #define UACCUM_MODE(N, Y, I, F) \
> +-	make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, __LINE__)
> ++	make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, 0)
> +
> + /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
> +    FILE, and LINE.  */
> +@@ -616,7 +616,7 @@ make_fixed_point_mode (enum mode_class cl,
> +
> + #define FLOAT_MODE(N, Y, F)             FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
> + #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
> +-  make_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
> ++  make_float_mode (#N, B, Y, #F, __FILE__, 0)
> +
> + static void
> + make_float_mode (const char *name,
> +@@ -633,7 +633,7 @@ make_float_mode (const char *name,
> + #define DECIMAL_FLOAT_MODE(N, Y, F)	\
> + 	FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F)
> + #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F)	\
> +-  make_decimal_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
> ++  make_decimal_float_mode (#N, B, Y, #F, __FILE__, 0)
> +
> + static void
> + make_decimal_float_mode (const char *name,
> +@@ -648,7 +648,7 @@ make_decimal_float_mode (const char *name,
> + }
> +
> + #define RESET_FLOAT_FORMAT(N, F) \
> +-  reset_float_format (#N, #F, __FILE__, __LINE__)
> ++  reset_float_format (#N, #F, __FILE__, 0)
> + static void ATTRIBUTE_UNUSED
> + reset_float_format (const char *name, const char *format,
> + 		    const char *file, unsigned int line)
> +@@ -669,7 +669,7 @@ reset_float_format (const char *name, const char *format,
> +
> + /* __intN support.  */
> + #define INT_N(M,PREC)				\
> +-  make_int_n (#M, PREC, __FILE__, __LINE__)
> ++  make_int_n (#M, PREC, __FILE__, 0)
> + static void ATTRIBUTE_UNUSED
> + make_int_n (const char *m, int bitsize,
> +             const char *file, unsigned int line)
> +@@ -698,7 +698,7 @@ make_int_n (const char *m, int bitsize,
> + /* Partial integer modes are specified by relation to a full integer
> +    mode.  */
> + #define PARTIAL_INT_MODE(M,PREC,NAME)				\
> +-  make_partial_integer_mode (#M, #NAME, PREC, __FILE__, __LINE__)
> ++  make_partial_integer_mode (#M, #NAME, PREC, __FILE__, 0)
> + static void ATTRIBUTE_UNUSED
> + make_partial_integer_mode (const char *base, const char *name,
> + 			   unsigned int precision,
> +@@ -725,7 +725,7 @@ make_partial_integer_mode (const char *base, const char *name,
> + /* A single vector mode can be specified by naming its component
> +    mode and the number of components.  */
> + #define VECTOR_MODE(C, M, N) \
> +-  make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__);
> ++  make_vector_mode (MODE_##C, #M, N, __FILE__, 0);
> + static void ATTRIBUTE_UNUSED
> + make_vector_mode (enum mode_class bclass,
> + 		  const char *base,
> +@@ -768,7 +768,7 @@ make_vector_mode (enum mode_class bclass,
> +
> + /* Adjustability.  */
> + #define _ADD_ADJUST(A, M, X, C1, C2) \
> +-  new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__)
> ++  new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, 0)
> +
> + #define ADJUST_NUNITS(M, X)    _ADD_ADJUST (nunits, M, X, RANDOM, RANDOM)
> + #define ADJUST_BYTESIZE(M, X)  _ADD_ADJUST (bytesize, M, X, RANDOM, RANDOM)
> 


More information about the Openembedded-core mailing list