Skip to content
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

[Feature request] Support $TARGET-pkg-config for cross-compilation #53

Open
jan-hudec opened this issue Jan 5, 2018 · 1 comment
Open

Comments

@jan-hudec
Copy link

My Debian system has following scripts in /usr/bin:

i686-linux-gnu-pkg-config
i686-w64-mingw32-pkg-config
pkg-config
x86_64-linux-gnu-pkg-config
x86_64-linux-gnux32-pkg-config
x86_64-pc-linux-gnu-pkg-config
x86_64-w64-mingw32-pkg-config

The prefixed scripts are symlinks to a wrapper that sets PKG_CONFIG_LIBDIR to the appropriate multilib directory to point to the correct package architecture. Since that is how libraries for cross-compilation toolchains are normally installed, it should work out of the box with them.

So I'd like to suggest to:

  1. If $TARGET != $HOST, look for $TARGET-pkg-config and $GCC_TARGET-pkg-config script instead of pkg-config and
  2. If it exists, the target_supported() function should return true and the script would be called.

The mapping from llvm-style $TARGET and gcc-style $GCC_TARGET is unfortunately not uniform, but looking at the list of targets both Rust and Debian know, two replacement rules should be sufficient:

1.-unknown-- and
2. -pc-windows-gnu-w64-mingw32

The scripts seem to be created when multi-arch is enabled for given target (with mingw/windows being a special case) and I only have that for amd64 (native), i386 and x32, but I believe these days it should work for qemu-emulated architectures too, so somebody can conceivably have arm-linux-gnueabi-pkg-config or aarch64-linux-gnu-pkg-config and if they do, it is going to work with the corresponding prefixed gcc linker.

(The curious x86_64-pc-linux-gnu-pkg-config is strangely a plain hardlink to pkg-config though the default gcc target is as expected just x86_64-linux-gnu with no -pc-; I believe it can be safely ignored)

@alexcrichton
Copy link
Member

Sounds like a plausible idea to me!

lorcanmcdonald added a commit to lorcanmcdonald/rust-rdkafka that referenced this issue Oct 9, 2018
`pkg-config-rs` does not support dynamically linking against a non-host target (see rust-lang/pkg-config-rs#53).

If librdkafka isn't found we will continue regardless.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants