Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler bug when trying to use libuv #603

Closed
pavildon opened this issue Nov 9, 2017 · 4 comments
Closed

Compiler bug when trying to use libuv #603

pavildon opened this issue Nov 9, 2017 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@pavildon
Copy link
Contributor

pavildon commented Nov 9, 2017

When trying to compile this code with 4f8c26d , the following errors arise :

/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_connect_t'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_connect_t'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_shutdown_t'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_shutdown_t'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_pipe_t'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_pipe_t'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_read2_cb'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/c.zig:1:19: error: compiler bug: @cImport generated invalid zig code
pub const libuv = @cImport({
                  ^
?.c:1:1: note: redefinition of 'uv_read2_cb'
TODO: remember C source location to display here
^
?.c:1:1: note: previous definition is here
TODO: remember C source location to display here
^
/home/pvd/Devel/zigtests/src/main.zig:6:16: error: no member named 'uv_loop_init' in '(C import)'
    _ = c.libuv.uv_loop_init(loop);
               ^
/home/pvd/Devel/zigtests/src/main.zig:10:16: error: no member named 'uv_loop_close' in '(C import)'
    _ = c.libuv.uv_loop_close(loop);
               ^
The following command exited with error code 1:
zig build-exe /home/pvd/Devel/zigtests/src/main.zig --cache-dir /home/pvd/Devel/zigtests/zig-cache --output /home/pvd/Devel/zigtests/zig-cache/main --name main --library uv 

Build failed. Use the following command to reproduce the failure:
./zig-cache/build zig . ./zig-cache

Maybe it has something to do with the fact that libuv uses a lot of 'opaque' structs to hide private members with C macro magic.

@pavildon
Copy link
Contributor Author

pavildon commented Nov 9, 2017

$ cat la.h
#include <uv.h>
$ zig parsec la.h

gives me the following output:

https://gist.github.com/aindigo/60d47c904cdfea556bd00f39103b7940

@andrewrk andrewrk added this to the 0.2.0 milestone Nov 9, 2017
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Nov 9, 2017
@dimenus
Copy link
Contributor

dimenus commented Nov 14, 2017

This should be resolved as of 98e3c79.

Let me know if you're still having any issues.

@dimenus dimenus closed this as completed Nov 14, 2017
@pavildon
Copy link
Contributor Author

I'm still getting the error compiling that repo, can you check?

another example:

pvd@alphanine:~/Devel/llvm5/debug$ cat la.h 
#include <uv.h>

pvd@alphanine:~/Devel/zig/build$ ./zig version
0.1.1.5029322a
pvd@alphanine:~/Devel/llvm5/debug$ ../bin/zig parsec la.h | grep "uv_connect_t ="
pub const uv_connect_t = struct_uv_connect_s;
pub const uv_connect_t = struct_uv_connect_s;

uv.h has the following declarations, for typedef uv_connect_t:

typedef struct uv_connect_s uv_connect_t;
...
...
struct uv_connect_s {       
  UV_REQ_FIELDS             
  uv_connect_cb cb;         
  uv_stream_t* handle;      
  UV_CONNECT_PRIVATE_FIELDS 
};                          

@andrewrk andrewrk reopened this Nov 14, 2017
@andrewrk
Copy link
Member

talked on IRC, the former issue is fixed and what is remaining is #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants