2

I'm cross-compiling my Rust code for AWS Lambda using the muslrust Docker container because it is the most popular MUSL + Rust package I could find on Docker Hub.

To compile, I do:

alias rust-docker='docker run --workdir /home/src --rm -it --volume "$(pwd)":/home/src clux/muslrust'
rust-docker cargo build

This succeeds, but when I deploy to Lambda and test it, I get the error:

/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /var/task/bootstrap)

I was under the impression that compiling with MUSL would create a static library that wouldn't need glibc on the server, so I'm not sure what I'm doing wrong here.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Chris
  • 39,719
  • 45
  • 189
  • 235
  • 1
    It looks like your question might be answered by the answers of [How can I compile a Rust program so it doesn't use __cxa_thread_atexit_impl?](https://stackoverflow.com/q/39744926/155423). If not, please **[edit]** your question to explain the differences. Otherwise, we can mark this question as already answered. – Shepmaster Feb 17 '21 at 03:04
  • 1
    See also [Alternative solutions to missing shared libraries after cross compilation?](https://stackoverflow.com/q/57742368/155423); [Portable binaries with Rust](https://stackoverflow.com/a/39226613/155423) – Shepmaster Feb 17 '21 at 03:06
  • Thanks! Will have a look at those and see if they answer the question. – Chris Feb 17 '21 at 03:29
  • The first link "How can I compile a Rust program so it doesn't use __cxa_thread_atexit_impl?" doesn't answer my question sorry, it's about versioning issues with glibc however i want to avoid glibc and use musl in its place. – Chris Feb 17 '21 at 03:33
  • The second link's answer recommends cross-compiling using musl which is along the lines of what i'd like to do, however that generally doesn't work for complicated projects IME, which is why i'm trying to use Docker for compiling against musl inside a musl OS. So it's not super helpful either sorry (i've tried it). – Chris Feb 17 '21 at 03:36
  • 1
    [This is what I do](https://github.com/integer32llc/rust-playground/blob/a19bffb94c30dfa2080d29c8f5e0381ef7ff68e0/ci/workflows.yml#L274) – Shepmaster Feb 17 '21 at 03:40
  • That seems to work!!! The trick was to use `ekidd/rust-musl-builder:stable` and `rust-docker cargo build --target=x86_64-unknown-linux-musl ...` Thanks a million!!! – Chris Feb 17 '21 at 04:23
  • Another important thing: Using docker on an M1 apple silicon mac is also a cause of many of my problems. – Chris Feb 17 '21 at 21:43

0 Answers0