-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Remove Windows pkg-config hack from -sys build.rs #631
Conversation
We can simply use pkg-config to list us all required shared libraries instead of only taking the library paths.
aeee423
to
ca08e61
Compare
The way how it fails on AppVeyour now is caused by a misconfigured environment. Those Windows libraries must be in the library path so that the linker can actually find them as needed. @EPashkin You run Windows, right? Can you check what's wrong there? https://ci.appveyor.com/project/GuillaumeGomez/gir/build/1.0.1182/job/l7ifw9e6l4fpsi9i |
@sdroege Have same error, investigating. |
for path in library.link_paths.iter() { | ||
println!("cargo:rustc-link-search=native={}", | ||
path.to_str().expect("library path doesn't exist")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me only this for can be removed even after upgrading pkg-config to 0.3.14, but not sure that it works globally as I have msys64/bin with gtk's dlls in path.
I tested on examples\cairo_threads.rs, do this change works fine for cairo-sys.
But on gtk it not works:
removing dylib caused many
D:\eap\rust\0\target\debug\deps\libgtk-d3ee1e1d9d9104f6.rlib(gtk-d3ee1e1d9d9104f6.1consvywiv34sg52.rcgu.o): In function `_$LT$gtk..border..MemoryManager$u20$as$u20$glib..boxed..BoxedMemoryManager$LT$gtk_sys..GtkBorder$GT$$GT$::free::h324bcaf1ec9c7496':
D:/eap/rust/0/gtk\src/border.rs:20: undefined reference to `gtk_border_free'
removing config.cargo_metadata(false);
caused
= note: ld: cannot find -limm32
ld: cannot find -ldwmapi
ld: cannot find -lcfgmgr32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why? Can you provide the corresponding (for each issue) cargo output (with -vv
) of a clean build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO at minimum no working gtk static lib on windows, about others I don't have any idea.
Output here: https://gist.github.com/EPashkin/a07f84a48f1b791e382e22716e2da144
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it try static libs to begin with?
The GTK undefined symbols happen because there's no -lgtk-3
in the linker commandline. The gtk-sys build.rs does not output this (or anything) for whatever reason. Can you check why? The other -sys crates output the correct things.
The missing Windows libraries, can you check where they are on your system and why those directories (the ones with the correspnding .lib files) are not in the linker search path?
Continue talk from #631 (comment) |
Ok, the cargo metadata is needed for proper functioning so let's ignore that case. So the only actual problem is that the imm32, etc libraries are not found, correct? Where are they (and their corresponding .lib files) on your system and are they part of the linker search path? |
All 3 of those libraries is 32bit (only on 64bit system) and lies in different lib folder. |
rustc should've added that path to the linker path already (when using the mingw toolchain) |
This path not from rust installation, but from separate msys2x64, so rustc can't add it. |
It's wrong that those libraries are in the .pc file actually... if they are not needed for linking they should not be there. |
Libraries not in .pc file, it also not in libgtk-3.dll.a as I can see (tried find strings),
|
But pkg-config get it from somewhere
|
Also strange for 32bit mode: |
grep for them in all pkg-config files you have. It's probably from GDK or PangoWin32 |
In any case, the problem here are a) broken pkg-config files (they should not include those libraries unless their API is used from any headers, they should only be in Libs.private here) and b) those libraries not in the correct places or environment variables not set correctly for GTK. It's not a problem of pkg-config |
Yes, all 3 dlls present in gdk-3.0.pc, gdk-broadway-3.0.pc, gdk-win32-3.0.pc,
|
Ok, so what I said above then :) GDK and environment setup bug |
@sdroege This seems can be closed too. |
Because of bugs elsewhere, yes. We should report those at least :) @nirbheek do you have any input here? |
This is strange, you should not need to specify the toolchain library path for linking. The compiler has those paths hard-coded. Run: I just checked, and MSYS2 MinGW64 does not need anything extra to find those base libraries |
Seems problem with rust version of gcc, there output for it (I added line endings for libs)
I have no subfolders in C:/Documents and Settings/eap/.rustup/toolchains/nightly-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/ so all of these path not exists |
Those paths seem to be completely broken. When configured correctly, gcc sets those paths relative to its current location, so you can move the toolchain directory and the dirs will still be correct. |
This sounds like it (also) needs a bug reports against the Rust MinGW toolchain then: for what @nirbheek said as well as for not including the MinGW .libs for the system libraries |
Note: despite warning near rust gcc.exe it not done its primary task: if I build program until I get link error and then rename this gcc.exe link (only step that last) will work fine with msys2x64 gcc
|
Happened in the meantime |
We can simply use pkg-config to list us all required shared libraries
instead of only taking the library paths.
pkg-config-rs works properly on MSVC and MinGW now