rust-cross / rust-musl-cross

Docker images for compiling static Rust binaries using musl-cross
MIT License
620 stars 68 forks source link

Fix C compiler environment variables #11

Closed jan-auer closed 6 years ago

jan-auer commented 6 years ago

Setting CC breaks build dependencies when cross compiling. cc-rs also supports reading TARGET_ variables, and falls back to the default compiler (and include paths) when compiling for the host.

Fixes #10

messense commented 6 years ago

Thanks for picking up this! Will merge as soon as Travis passes.

jan-auer commented 6 years ago

Didn't test it locally and looks like this breaks the openssl-build in the container.

messense commented 6 years ago

I guess we need to add CC=$TARGET_CC env to https://github.com/messense/rust-musl-cross/blob/f09d9b16924d8d82adcdf207d9ed82c6842b2150/Dockerfile#L67 and https://github.com/messense/rust-musl-cross/blob/f09d9b16924d8d82adcdf207d9ed82c6842b2150/Dockerfile#L74

maybe add C_INCLUDE_PATH=$TARGET_C_INCLUDE_PATH env to https://github.com/messense/rust-musl-cross/blob/f09d9b16924d8d82adcdf207d9ed82c6842b2150/Dockerfile#L75

jan-auer commented 6 years ago

I was thinking to just:

RUN CC=$TARGET_CC && \
    C_INCLUDE_PATH=$TARGET_C_INCLUDE_PATH && \
    echo "Building zlib" && \

But either way should work

messense commented 6 years ago

Yes, I think so.

jan-auer commented 6 years ago

Any preference?

messense commented 6 years ago

Let's go with

RUN CC=$TARGET_CC && \
    C_INCLUDE_PATH=$TARGET_C_INCLUDE_PATH && \
    echo "Building zlib" && \

It looks shorter and cleaner.

jan-auer commented 6 years ago

🤞

messense commented 6 years ago
Building OpenSSL
Configuring for linux-x86_64
    no-ec_nistp_64_gcc_128 [default]  OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
    no-gmp          [default]  OPENSSL_NO_GMP (skip dir)
    no-jpake        [experimental] OPENSSL_NO_JPAKE (skip dir)
    no-krb5         [krb5-flavor not specified] OPENSSL_NO_KRB5
    no-libunbound   [experimental] OPENSSL_NO_LIBUNBOUND (skip dir)
    no-md2          [default]  OPENSSL_NO_MD2 (skip dir)
    no-rc5          [default]  OPENSSL_NO_RC5 (skip dir)
    no-rfc3779      [default]  OPENSSL_NO_RFC3779 (skip dir)
    no-sctp         [default]  OPENSSL_NO_SCTP (skip dir)
    no-shared       [default] 
    no-ssl-trace    [default]  OPENSSL_NO_SSL_TRACE (skip dir)
    no-ssl2         [default]  OPENSSL_NO_SSL2 (skip dir)
    no-store        [experimental] OPENSSL_NO_STORE (skip dir)
    no-unit-test    [default]  OPENSSL_NO_UNIT_TEST (skip dir)
    no-weak-ssl-ciphers [default]  OPENSSL_NO_WEAK_SSL_CIPHERS (skip dir)
    no-zlib         [default] 
    no-zlib-dynamic [default] 
IsMK1MF=0
CC            =gcc

Looks like it's still using host gcc to compile OpenSSL.

jan-auer commented 6 years ago

Wondering what the difference is, at least it should be picking up the same value for $CC before and after the change...

jan-auer commented 6 years ago

Oh, it might be the sudo make install, maybe? Edit: nvm, I guess we'll have to configure like you said.

jan-auer commented 6 years ago

Silly me, that should do now...