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

__imp___acrt_iob_func linking errors under msys2 #919

Closed
Jimmio92 opened this issue Aug 14, 2018 · 7 comments
Closed

__imp___acrt_iob_func linking errors under msys2 #919

Jimmio92 opened this issue Aug 14, 2018 · 7 comments

Comments

@Jimmio92
Copy link

Hello,

I am trying to build racer from master branch (pulled yesterday) and it seems to be linking both the GNU C library like it should as well as MSVCRT.. and I'm not sure if that's where the problem lies. Basically, it seems this error occurs when a library is built with MSVC tools prior to VS2015 and then used in VS2015.. It also seems to pop up only in a few curl functions. Any ideas?

@kngwyu
Copy link
Collaborator

kngwyu commented Aug 15, 2018

Hmm... It's upstream issue so I'm not sure I can handle it 😓
Now I updated cargo so could you please try to build once more?
But, in the long run, it seems to be better to use cargo metadata as subprocess 🙁

@Jimmio92
Copy link
Author

Full build log: buildlog.txt

Nightly Rust. Master branch here. Msys2 up to date. GCC 8.2.0. Windows 10 x64 in a unix-like bash environment, basically.

@crlf0710
Copy link

@Jimmio92 This has been the case for quite a while now. It's because MSYS2 ships GCC 8.x, and Rust itself ships GCC 7.x. I have some experience dealing with this.

So basically you have two ways to workaround this issue.

  1. Somehow get yourself an environment the same with those mingw-build files Rust ships, e.g. GCC 7.x etc.. (Hard)

  2. a. remove rust-mingw component. (edit multirust-channel-manifest.toml to change rust-mingw from component to extensions, then rustup component remove rust-mingw).
    b. replace crt2.o and crt2dll.o with the ones from MINGW64/MINGW32 of MSYS2.
    c. build your crate.

This works until you do a rustup update then rust-mingw will be back, and you'll have to start over.

@Jimmio92
Copy link
Author

crt2.o and crt2dll.o are no longer the name of the now multiple files named crtbegin and crtend, plus some mathematical section of the runtime. So.. I don't know what to do. I guess building Rust from source in this environment would alleviate this problem?

@crlf0710
Copy link

crlf0710 commented Aug 17, 2018

@Jimmio92 those files still exists. there was a typo however, it's called crt2dll.o dllcrt2.o . crtbegin and crtend files do exists, but they're unrelated.

They're located at(taking 64-bit example on my machine):

/mingw64/x86_64-w64-mingw32/lib/crt2.o
/mingw64/x86_64-w64-mingw32/lib/dllcrt2.o

And they come with mingw-w64-x86_64-crt-git 6.0.0.5193.a081b583-1 in MSYS2 package on my machine.

You should use them to replace (I'm using stable, but you might want to change the directory to nightly one):
<somewhere>\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o

<somewhere>\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\dllcrt2.o

Also, be careful that since the gcc.exe will be removed as part of rust-mingw, any Rust program's compilation will be using the gcc.exe that comes from MSYS2 mingw64. It will error if it can't find it.

@kngwyu
Copy link
Collaborator

kngwyu commented Aug 27, 2018

@Jimmio92
I think it's resolved in 2.1.5.
Could you try cargo +nightly install racer once more, please?

@mati865
Copy link
Contributor

mati865 commented Sep 16, 2018

@crlf0710 in fact this is because Rust's GCC was build with way older mingw-w64 than MSYS2 (GCC version doesn't matter).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants