Hi Alex, Alex Potapenko wrote,
Hi all,
I'm facing a compilation error while building GCC 7.2.0 libgo with uClibc-ng 1.0.26 with this error: runtime_sysinfo.go:418:17: error: use of undefined type ‘___uclibc_locale_struct’
Here is the relevant build output: https://pastebin.com/B7urxS2m
The problematic runtime_sysinfo.go is created using -fdump-go-spec: it's used to automatically generate Go declarations from C code (see https://golang.org/ doc/install/gccgo#Automatic_generation_of_Go_declarations_from_C_source_code). The generated gen-sysinfo.go is indeed missing ___uclibc_locale_struct declaration. Looks like -fdump-go-spec generates types only from typedef declarations, ignoring structs, like "struct __uclibc_locale_struct;" in uClibc_locale.h. This simple change allows to build libgo fine:
--- uClibc_locale.h.orig 2017-09-25 19:49:38.000000000 +0000 +++ uClibc_locale.h 2017-09-28 07:27:14.035517712 +0000 @@ -73,6 +73,7 @@ */
struct __uclibc_locale_struct; +typedef struct __uclibc_locale_struct __uclibc_locale_struct; typedef struct __uclibc_locale_struct *__locale_t;
#endif /* !defined(__LOCALE_C_ONLY) */
Does this change look sane? Or should I patch GCC libgo/sysinfo.c instead to add "typedef struct __uclibc_locale_struct __uclibc_locale_struct;" there?
Thanks for analyzing. I have seen the same issue on my side. But I would like to suggest to fix it in libgo/sysinfo.c instead, seems more correct. Can you send a patch to gcc-dev and Cc me to see what the gcc developers say?
best regards Waldemar