-
Notifications
You must be signed in to change notification settings - Fork 79
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
handle file paths to libraries #134
Conversation
I stumbled on this trying to statically link Qt built from vcpkg: KDAB/cxx-qt#174 |
5c47db0
to
0da3d3e
Compare
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.
Looks good to me otherwise, thanks!
ee07d94
to
164f47d
Compare
I'm not sure how to handle the build failure with Rust 1.30.0. Any suggestions how to keep this MSRV? Or raise the MSRV? |
I think we should just update the MSRV. It's not sustainable to stay at an older version if the whole ecosystem moved on already. |
164f47d
to
d072897
Compare
2f1ab93
to
a04c543
Compare
The file matching is incorrectly strict. On windows if you're using MSVC or MinGW or Clang, you can link to: If you are using Clang or GCC you can also link to Cygwin is a whole other beast, with different file naming. |
So maybe we should just search for |
I'm not sure it would be that simple. It depends if rustc-link-lib wants the |
I guess this then needs checking what |
I suspect the linker used by rustc (lld or link or whatever) will accept whatever library you want to link to, if you use a full path. |
The problem is that |
How should we proceed here? Are you planning to check what rustc is doing @Be-ing ? |
I'll dig into the rustc source code to get a clearer idea of how it works, unless someone beats me to that. |
Reading the rustc source code, I found that there is an undocumented |
2c1fd9f
to
5001232
Compare
A simpler solution: pass the file path to the linker with |
Ah that looks nicely simple, thanks! |
4dfa744
to
e208b2e
Compare
It depends on the case. Each |
73b6b76
to
d1d7272
Compare
d6422df
to
bcccda0
Compare
I think this is finally ready to merge. |
I'll try and do a more thorough review on Monday or Tuesday (presumably by then rust-lang/team#861 (comment) will be done and I'll be able to actually land it if it's good). Initial impressions are fairly positive. |
I'll go over this tomorrow but I'll wait then for @thomcc's review too early next week :) |
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.
Looks good to me. I have one trivial nit (which is mostly nice to have and it could land without it).
Thanks for the great comments too, that made it much more straightforward to review.
bcccda0
to
5e730f8
Compare
Typically pkgconfig files specify cflags for linking with -L and -l, however, pkgconfig files can also specify paths to library files. For example, building Qt5 statically on macOS generates the following pkgconfig file. Notice the absolute path to libqtpcre.a in Libs.private: prefix=/Users/be/qt5-installed exec_prefix=${prefix} libdir=${prefix}/lib includedir=${prefix}/include host_bins=${prefix}/bin qt_config=debug_and_release release debug build_all c++11 c++14 c++17 c++1z concurrent dbus no-pkg-config reduce_exports release_tools static stl Name: Qt5 Core Description: Qt Core module Version: 5.15.5 Libs: -L${libdir} -lQt5Core Libs.private: -framework DiskArbitration -framework IOKit -lm -framework AppKit -framework Security -framework ApplicationServices -framework CoreServices -framework CoreFoundation -framework Foundation -lz /Users/be/sw/qt-everywhere-src-5.15.5/qtbase/lib/libqtpcre2.a Cflags: -DQT_CORE_LIB -I${includedir}/QtCore -I${includedir} Building Qt5 statically on macOS with vcpkg generates this pkgconfig file which has a handful of file paths for libraries: prefix=${pcfiledir}/../.. exec_prefix=${prefix} libdir=${prefix}/lib includedir=${prefix}/include/qt5 host_bins=${prefix}/tools/qt5/bin qt_config=release c++11 c++14 c++17 c++1z concurrent dbus no-pkg-config reduce_exports static stl properties animation textcodec big_codecs codecs itemmodel proxymodel concatenatetablesproxymodel textdate datestring doubleconversion filesystemiterator filesystemwatcher gestures identityproxymodel library mimetype process statemachine regularexpression settings sharedmemory sortfilterproxymodel stringlistmodel systemsemaphore temporaryfile translation transposeproxymodel xmlstream xmlstreamreader xmlstreamwriter Name: Qt5 Core Description: Qt Core module Version: 5.15.3 Libs: -L"${libdir}" -lQt5Core -L"${prefix}/lib" -L"${prefix}/lib/manual-link" -framework DiskArbitration -framework IOKit -lm -framework AppKit -framework Security -framework ApplicationServices -framework CoreServices -framework CoreFoundation -framework Foundation ${prefix}/lib/libz.a -ldouble-conversion ${prefix}/lib/libicui18n.a ${prefix}/lib/libicutu.a ${prefix}/lib/libicuuc.a ${prefix}/lib/libicuio.a ${prefix}/lib/libicudata.a ${prefix}/lib/libpcre2-16.a -lzstd ${prefix}/lib/libbz2.a ${prefix}/lib/libpng16.a ${prefix}/lib/libicui18n.a ${prefix}/lib/libicutu.a ${prefix}/lib/libicuuc.a ${prefix}/lib/libicuio.a ${prefix}/lib/libicudata.a ${prefix}/lib/libzstd.a Cflags: -DQT_CORE_LIB -I"${includedir}/QtCore" -I"${includedir}"
No longer needed as of Rust 2018
5e730f8
to
a9d0132
Compare
Thanks for helping make this robust! |
Could you publish a new release? |
Sure, done :) |
Typically pkgconfig files specify cflags for linking with -L and -l,
however, pkgconfig files can also specify paths to library files. For
example, building Qt5 statically on macOS generates the following
pkgconfig file. Notice the absolute path to libqtpcre.a in Libs.private:
Building Qt5 statically on macOS with vcpkg generates this pkgconfig
file which has a handful of file paths for libraries: