How to default to i686 target on both Linux and Windows?

My project is a 32-bit dynamic library: it injects into a 32-bit game process. Right now my build instructions boil down to:


  1. Install the i686-unknown-linux-gnu target
  2. cargo build --target=i686-unknown-linux-gnu


  1. Install the i686-pc-windows-msvc target
  2. cargo build --target=i686-pc-windows-msvc

And I have a .cargo/config with:

#target = "i686-unknown-linux-gnu"
#target = "i686-pc-windows-msvc"
#target = "i686-pc-windows-gnu"

for people to uncomment as they see fit.

However, it would be better if I could somehow tell cargo to use i686-unknown-linux-gnu on Linux and i686-pc-windows-msvc on Windows automatically, to simplify the build instructions to a cargo build. Is this possible? Something like [build."cfg(windows)"] and [build."cfg(not(windows))"] in .cargo/config seems like it would work.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.