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

can't find crate for std on mingw-w64-32bit #10329

Closed
klutzy opened this issue Nov 7, 2013 · 10 comments
Closed

can't find crate for std on mingw-w64-32bit #10329

klutzy opened this issue Nov 7, 2013 · 10 comments
Labels
O-windows Operating system: Windows

Comments

@klutzy
Copy link
Contributor

klutzy commented Nov 7, 2013

compile_and_link: i686-pc-mingw32/stage1/bin/rustc/i686-pc-mingw32/bin/std.dll
compile_and_link: i686-pc-mingw32/stage1/bin/rustc/i686-pc-mingw32/bin/extra.dll
C:\home\stone\rust-w32\src\libextra\lib.rs:1:0: 1:0 error: can't find crate for `std`
C:\home\stone\rust-w32\src\libextra\lib.rs:1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
                                             ^
task 'rustc' failed at 'explicit failure', C:\home\stone\rust-w32\src\libsyntax\diagnostic.rs:75
task '<main>' failed at 'explicit failure', C:\home\stone\rust-w32\src\librustc\lib.rs:397

Not sure what caused it. make clean didn't help.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 7, 2013

Found! It's mingw/libuv issue. libuv uses swprintf to listdir, but mingw-w64's swprintf is different from mingw's one.
mingw-w64 uses:

int swprintf(wchar_t *buffer, size_t count, const wchar_t *format, ...);

mingw uses:

int swprintf(wchar_t *buffer, const wchar_t *format, ...);

Yes, no count. It even differs from posix or current msvc.
It seems that mingw is following old msvc behaviour. msvc changed it from vc++2005.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 7, 2013

Quick fix (I'll make a pr for libuv soon):

- #if defined(_MSC_VER)
+ #if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
   swprintf(path2, len + 3, fmt, pathw);
 #else
   swprintf(path2, fmt, pathw);
 #endif

@klutzy
Copy link
Contributor Author

klutzy commented Nov 7, 2013

This seems fixed in upstream.

@huonw
Copy link
Member

huonw commented Nov 7, 2013

cc @alexcrichton (for the libuv upgrade).

@lucab
Copy link
Contributor

lucab commented Nov 7, 2013

Closing #10246 will fix this one too, but it's currently waiting for joyent/libuv#979 to land.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 7, 2013

Oh, this goes more complicated than I expected. Upstream libuv will make rustc crash if not built carefully.

msvc and mingw-w64 provide posix-conforming swprintf as default, and provide old one if #ifdef _CRT_NON_CONFORMING_SWPRINTFS is defined. This is what libuv upstream uses.
However, mingw doesn't understand it and always provides old one.
(I'm not sure what "Newer versions" in commit message is, since mingw master still not provide new api. Maybe it is not "newer" but mingw-w64?)

This means we must define the macro on building libuv. If not, libuv crashes on uv_fs_readdir because libuv expected new api but mingw provided old api.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 8, 2013

Currently the easiest fix is to pass -D_CRT_NON_CONFORMING_SWPRINTFS flag when building uv. This forces libuv to use old api.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 9, 2013

#10321 will fix this (mingw-w64 issue).
For mingw issue, I've reported it at upstream.

@klutzy
Copy link
Contributor Author

klutzy commented Nov 9, 2013

@alexcrichton libuv fixed it by avoiding swprintf. Upgrading libuv will fix both mingw- and mingw64-issues. (and you can also drop the CFLAGS hack).

@alexcrichton
Copy link
Member

I have upgraded and this'll close when my uv-rewrite branch merges (hopefully soon!)

alexcrichton added a commit that referenced this issue Nov 9, 2013
At this time, also point the libuv submodule to the official repo instead of my
own off to the side.

Closes #10246
Closes #10329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

4 participants