Last active
          April 10, 2025 14:49 
        
      - 
      
 - 
        
Save mimoo/b92a7263e5316182e7aa8d8d056e3ddd to your computer and use it in GitHub Desktop.  
Revisions
- 
        
mimoo revised this gist
Apr 10, 2025 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ Need to test some Rust program in a 32-bit environment? You're on MacOS? Looks like you're going to have to use Docker. Not only that, but you'll have to use Docker with a 64-bit linux environment, that can support building and running 32-bit binaries. Create this Dockerfile: ``` FROM rust:latest  - 
        
mimoo renamed this gist
Apr 10, 2025 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
mimoo created this gist
Apr 10, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ create this Dockerfile: ``` FROM rust:latest # Ensure we don't use our local build folder ENV CARGO_TARGET_DIR=/tmp/target32 # Install 32-bit compilation support RUN dpkg --add-architecture i386 && \ apt-get update && \ apt-get install -y gcc-multilib libc6-dev:i386 # Install 32-bit Rust target RUN rustup target add i686-unknown-linux-gnu # Create app directory WORKDIR /usr/src/app # Set up local config for 32-bit default RUN mkdir -p .cargo && \ echo '[build]\ntarget = "i686-unknown-linux-gnu"' > .cargo/config.toml ``` then build it / run it: ``` docker build --platform=linux/amd64 -t rust-32 . docker run --platform=linux/amd64 -it --rm \ -v "$PWD":/usr/src/app \ -w /usr/src/app \ rust-32 \ bash ``` this will mount your local directory (which should contain your rust project) and any cargo command should automatically pick up on the 32-bit target that's set as default in `.cargo/config.toml`