[MacPorts] #66894: pkgconfig @0.29.2: consider a better plan for cross-compiling

MacPorts noreply at macports.org
Sat Feb 11 20:25:56 UTC 2023


#66894: pkgconfig @0.29.2: consider a better plan for cross-compiling
-------------------------+------------------------
 Reporter:  kencu        |      Owner:  ryandesign
     Type:  enhancement  |     Status:  assigned
 Priority:  Normal       |  Milestone:
Component:  ports        |    Version:
 Keywords:               |       Port:  pkgconfig
-------------------------+------------------------
 MacPorts supports cross-compiling, but pkgconfig files don't directly
 support cross-compiling well. At present there is no built-in capacity to
 branch on a host/target/arch to deliver up different flags for different
 builds.

 At times, especially when cross-compiling across architectures, the
 muniversal PortGroup builds deliver up conflicting pkg-config *.pc files
 for each arch that are difficult to unify. Sometimes all that can be done
 is strip out all the more advanced features like SIMD enhancements that
 are best enabled.

 see #66888 for one of no doubt many similar issues over the years.

 One example of what other distributions have done is to generate pkgconfig
 subdirectories for each supported arch, and put the individual pkgconfig
 files in those subdirectories. There can be a common subdir as a final
 search path.

 eg:
 {{{
 ${prefix}/lib/pkgconfig/arm64/
 ${prefix}/lib/pkgconfig/x86_64/
 ${prefix}/lib/pkgconfig/
 }}}

 Then, during the build, the arm build looks first in
 {{{${prefix}/lib/pkgconfig/arm64/}}} and after that in
 {{{${prefix}/lib/pkgconfig/}}}. These search paths can be manipulated with
 environment variables, but they can also be set during the build of
 pkgconfig.

 For example, {{{pkgconfig +universal}}} could generate three binaries:

 {{{
 arm64-apple-darwin-pkg-config
 x86_64-apple-darwin-pkg-config
 pkg-config -> system_default_arch-pkg-config
 }}}

 and the arch-specific binary could be set to search it's own arch subdir
 first.

 To use these, they can be set in the meson cross-files directly, or set up
 in the muniversal PG.

 Another, older way to use pkg-config in this fashion is with a wrapper
 script, but it seems the arch-specific-named-pkg-config plan has taken
 over as the recommended way forward.

 References:

 https://autotools.info/pkgconfig/cross-compiling.html

 https://www.freedesktop.org/wiki/Software/pkg-config/CrossCompileProposal/

-- 
Ticket URL: <https://trac.macports.org/ticket/66894>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list