Repository: rust-cross/rust-musl-cross (language: rust)

Issue:
Unconditionally setting CC and C_INCLUDE_PATH breaks crosscompiling ring/rocket_codegen
Setting CC and C_INCLUDE_PATH unconditionally breaks compiling ring as dependency of rocket_codegen while cross compiling to another architecture (e.g. from x86_64 to arm). 
The ring build script will fail with error messages complaining that the `-m64` switch is unknown on the arm-unknown-linux-musleabi crosscompiler.
The underlying issue is that ring is build twice, once for usage in the codegen compilerplugin and once for usage in the final binary. This means ring must be build for the target and host. Ring tries to use the compiler provided by the environment, so setting unconditionally CC will cause ring to use that compiler everywhere. Building for the host-platform may not work while crosscompiling.

The solution is to set `TARGET_CC` to the compiler of the target platform and let CC unspecified.


Discussion / hints:
I am not sure what has changed in ring, but last time I used this to build [`kafka-view`](https://github.com/fede1024/kafka-view/blob/ff4453b2230a41002e770cd5862dff8cf802acc6/Dockerfile) it worked.

What version of Rocket are you using?
I've tried Rocket 0.3.6 and 0.3.8. Both are using ring 0.11.0.

Fix patch:
diff --git a/Dockerfile b/Dockerfile
index bdeaf16..73719fe 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -40,8 +40,8 @@ RUN mkdir -p /home/rust/libs /home/rust/src
 # Set up our path with all our binary directories, including those for the
 # musl-gcc toolchain and for our Rust toolchain.
 ENV PATH=/root/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-ENV CC=$TARGET-gcc
-ENV C_INCLUDE_PATH=/usr/local/musl/$TARGET/include/
+ENV TARGET_CC=$TARGET-gcc
+ENV TARGET_C_INCLUDE_PATH=/usr/local/musl/$TARGET/include/
 
 # Install our Rust toolchain and the `musl` target.  We patch the
 # command-line we pass to the installer so that it won't attempt to
@@ -59,7 +59,9 @@ WORKDIR /home/rust/libs
 
 # Build a static library version of OpenSSL using musl-libc.  This is
 # needed by the popular Rust `hyper` crate.
-RUN echo "Building zlib" && \
+RUN export CC=$TARGET_CC && \
+    export C_INCLUDE_PATH=$TARGET_C_INCLUDE_PATH && \
+    echo "Building zlib" && \
     VERS=1.2.11 && \
     cd /home/rust/libs && \
     curl -sqLO http://zlib.net/zlib-$VERS.tar.gz && \


Test patch: