<div dir="ltr"><div>Hey Cory,</div><div><br></div>Daniel and I talked a bit about this issue and we think it is best to drop the current implementation of the pkg-config parser and always shell out. In future, we would want to move towards a model where the pkg-config is also expressed as dependencies in llbuild (using the llbuild APIs). This would give us a lot of free things like caching, dependency management etc. Moving towards that model will be a lot of work so right now lets just implement the shelling out without any persistent cache. We can think about the temporary cache if it seriously impacts the build performance.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 30, 2017 at 3:42 AM, Cory Benfield via swift-build-dev <span dir="ltr"><<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Hey all,<div><br></div><div>Over the past few weeks I’ve encountered some subtle issues with SwiftPM and the system pkg-config tool disagreeing over what compiler and linker flags should be provided on a given Linux system, as shown in SR-6317 (<a href="https://bugs.swift.org/browse/SR-6317" target="_blank">https://bugs.swift.org/<wbr>browse/SR-6317</a>). After some investigation on my part, I’d like to propose that we should replace SwiftPM’s hand-rolled pkgconfig parsing logic (in PkgConfig.swift) with a tool that simply shells out to the system pkg-config binary, if available.</div><div><br></div><div>In general, on Linux, any system capable of compiling a SwiftPM project is going to have pkg-config installed. It’s an extremely common dependency in build toolchains, and the likelihood is that if your project wants to link against anything more esoteric than libc and the various Swift shared libraries pkg-config will have been installed anyway. If for some reason pkg-config is not present on the $PATH on such a system, that is likely a signal that pkg-config is not a good tool to use to populate the linker and compile flags *anyway*.</div><div><br></div><div>Given that pkg-config is so widely deployed in Linux, it seems senseless to carry a reimplementation of that tool in SwiftPM. This is doubly true given that the pkg-config binary has a number of compile-time configurations applied by the system builder that give it special knowledge of the system’s default linker and include search paths. SwiftPM’s lack of that knowledge is what led to SR-6317, and rather than attempt to add complexity to SwiftPM’s implementation we would probably be better served by simply deferring to the implementation on the system that knows what to do best.</div><div><br></div><div>My proposal is to replace the current implementation with one that shells out to pkg-config. If pkg-config cannot be found, then we simply fall back to the rest of the user configuration, exactly as if there were no pkg-config support at all.</div><div><br></div><div>What do people think?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Cory</div></font></span></div><br>______________________________<wbr>_________________<br>
swift-build-dev mailing list<br>
<a href="mailto:swift-build-dev@swift.org">swift-build-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-build-<wbr>dev</a><br>
<br></blockquote></div><br></div>