Skip to content

Commit 2c1fd9f

Browse files
committed
handle file paths to libraries
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}"
1 parent 4246c5a commit 2c1fd9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,14 @@ impl Library {
669669
self.include_paths.push(PathBuf::from(inc));
670670
}
671671
}
672-
_ => (),
672+
_ => {
673+
let path = std::path::Path::new(part);
674+
if path.is_file() {
675+
// Pass file paths directly to the linker instead of going through
676+
// rustc adding platform-specific prefixes/suffixes with rustc-link-lib.
677+
config.print_metadata(&format!("rustc-link-arg={}", part));
678+
}
679+
},
673680
}
674681
}
675682

0 commit comments

Comments
 (0)