From c4df5bbeb87a445dbc84b9ed677b2c721e5051b5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 2 Jul 2020 18:10:49 +0200 Subject: sim/igen: Fix linker error with -fno-common GCC 10 enables -fno-common by default. This resulted in multiple definition linker errors since a global variable was declared and defined in a header file: ld: libsim.a(idecode.o):sim/v850/idecode.h:71: multiple definition of `idecode_issue'; libsim.a(irun.o):sim/v850/idecode.h:71: first defined here ld: libsim.a(engine.o):sim/v850/idecode.h:71: multiple definition of `idecode_issue'; libsim.a(irun.o):sim/v850/idecode.h:71: first defined here ld: libsim.a(support.o):sim/v850/idecode.h:71: multiple definition of `idecode_issue'; libsim.a(irun.o):sim/v850/idecode.h:71: first defined here ld: libsim.a(semantics.o):sim/v850/idecode.h:71: multiple definition of `idecode_issue'; libsim.a(irun.o):sim/v850/idecode.h:71: first defined here sim/igen PR sim/26194 * lf.h (lf_get_file_type): Declare. * lf.c (lf_get_file_type): Define. * gen-idecode.c (print_idecode_issue_function_header): Use lf_get_file_type() to issue an extern variable declaration in case of header files. --- sim/igen/gen-idecode.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sim/igen/gen-idecode.c') diff --git a/sim/igen/gen-idecode.c b/sim/igen/gen-idecode.c index b8f8ca1..741498a 100644 --- a/sim/igen/gen-idecode.c +++ b/sim/igen/gen-idecode.c @@ -930,6 +930,8 @@ print_idecode_issue_function_header (lf *file, "INLINE_IDECODE", "\n"); break; case is_function_variable: + if (lf_get_file_type (file) == lf_is_h) + lf_printf (file, "extern "); print_semantic_function_type (file); lf_printf (file, " (*"); break; -- cgit v1.1