diff mbox series

[uclibc-ng-devel] GCC libgo compilation error

Message ID CAF5aO=+q0SJ-+BQWPLmh+eonJW+tBmHqCoSzQah6G4dYXm0vPQ@mail.gmail.com
State Rejected
Headers show
Series [uclibc-ng-devel] GCC libgo compilation error | expand

Commit Message

Alex Potapenko Sept. 28, 2017, 7:38 a.m. UTC
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:



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,
Alex

Comments

Waldemar Brodkorb Sept. 28, 2017, 4:21 p.m. UTC | #1
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
Alex Potapenko Sept. 29, 2017, 2:43 p.m. UTC | #2
Hi Waldemar,

On Thu, Sep 28, 2017 at 7:21 PM, Waldemar Brodkorb <wbx@uclibc-ng.org>
wrote:
>
> 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?
>

Done. The issue is now fixed in GCC mainline:
https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01956.html

Though you should be aware of it, since I've Cc'ed you to the thread.

Thanks,
Alex
<div dir="ltr">Hi Waldemar,<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 28, 2017 at 7:21 PM, Waldemar Brodkorb <span dir="ltr">&lt;<a href="mailto:wbx@uclibc-ng.org" target="_blank">wbx@uclibc-ng.org</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks for analyzing. I have seen the same issue on my side.<br>
But I would like to suggest to fix it in libgo/sysinfo.c instead,<br>
seems more correct. Can you send a patch to gcc-dev and Cc me to see<br>
what the gcc developers say?<span class="gmail-HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><div class="gmail_extra"><br></div>Done. The issue is now fixed in GCC mainline:</div><div class="gmail_extra"><a href="https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01956.html">https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01956.html</a></div><div class="gmail_extra"><br></div><div class="gmail_extra">Though you should be aware of it, since I&#39;ve Cc&#39;ed you to the thread.<br clear="all"><div><br></div>Thanks,
</div><div class="gmail_extra">Alex</div></div>
diff mbox series

Patch

--- 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) */