Message ID | 20231209163831.5320-1-xry111@xry111.site |
---|---|
State | New |
Headers | show |
Series | LoongArch: Fix warnings building libgcc | expand |
在 2023/12/10 上午12:38, Xi Ruoyao 写道: > We are excluding loongarch-opts.h from target libraries, but now struct > loongarch_target and gcc_options are not declared in the target > libraries, causing: > > In file included from ../.././gcc/options.h:8, > from ../.././gcc/tm.h:49, > from ../../../gcc/libgcc/fixed-bit.c:48: > ../../../gcc/libgcc/../gcc/config/loongarch/loongarch-opts.h:57:41: > warning: 'struct gcc_options' declared inside parameter list will not > be visible outside of this definition or declaration > 57 | struct gcc_options *opts, > | ^~~~~~~~~~~ > > So exclude the declarations referring to the C++ structs as well. > > gcc/ChangeLog: > > * config/loongarch/loongarch-opts.h (la_target): Move into #if > for loongarch-def.h. > (loongarch_init_target): Likewise. > (loongarch_config_target): Likewise. > (loongarch_update_gcc_opt_status): Likewise. > --- > > Bootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk? > I don't understand. I tested it when I submitted the code, but I didn't find this problem. I think such a problem will cause compilation errors when --enable-bootstrap, right?
在 2023/12/12 上午9:58, chenglulu 写道: > > 在 2023/12/10 上午12:38, Xi Ruoyao 写道: >> We are excluding loongarch-opts.h from target libraries, but now struct >> loongarch_target and gcc_options are not declared in the target >> libraries, causing: >> >> In file included from ../.././gcc/options.h:8, >> from ../.././gcc/tm.h:49, >> from ../../../gcc/libgcc/fixed-bit.c:48: >> ../../../gcc/libgcc/../gcc/config/loongarch/loongarch-opts.h:57:41: >> warning: 'struct gcc_options' declared inside parameter list will not >> be visible outside of this definition or declaration >> 57 | struct gcc_options *opts, >> | ^~~~~~~~~~~ >> >> So exclude the declarations referring to the C++ structs as well. >> >> gcc/ChangeLog: >> >> * config/loongarch/loongarch-opts.h (la_target): Move into #if >> for loongarch-def.h. >> (loongarch_init_target): Likewise. >> (loongarch_config_target): Likewise. >> (loongarch_update_gcc_opt_status): Likewise. >> --- >> >> Bootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk? >> > I don't understand. I tested it when I submitted the code, but I > didn't find this problem. > > I think such a problem will cause compilation errors when > --enable-bootstrap, right? > > I've seen a warning message. Thanks!
diff --git a/gcc/config/loongarch/loongarch-opts.h b/gcc/config/loongarch/loongarch-opts.h index 651c1c18ca8..d091359300a 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -21,22 +21,15 @@ along with GCC; see the file COPYING3. If not see #ifndef LOONGARCH_OPTS_H #define LOONGARCH_OPTS_H -/* This is a C++ header and it shouldn't be used by target libraries. */ +/* The loongarch-def.h file is a C++ header and it shouldn't be used by + target libraries. Exclude it and everything using the C++ structs + (struct loongarch_target and gcc_options) from target libraries. */ #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS) #include "loongarch-def.h" -#endif /* Target configuration */ extern struct loongarch_target la_target; -/* Flag status */ -struct loongarch_flags { - int flt; const char* flt_str; -#define SX_FLAG_TYPE(x) ((x) < 0 ? -(x) : (x)) - int sx[2]; -}; - - /* Initialize loongarch_target from separate option variables. */ void loongarch_init_target (struct loongarch_target *target, @@ -56,7 +49,14 @@ void loongarch_update_gcc_opt_status (struct loongarch_target *target, struct gcc_options *opts, struct gcc_options *opts_set); +#endif +/* Flag status */ +struct loongarch_flags { + int flt; const char* flt_str; +#define SX_FLAG_TYPE(x) ((x) < 0 ? -(x) : (x)) + int sx[2]; +}; /* Macros for common conditional expressions used in loongarch.{c,h,md} */ #define TARGET_CMODEL_NORMAL (la_target.cmodel == CMODEL_NORMAL)