Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile for platform x86_64-unknown-linux-musl #186

Closed
LMJW opened this issue Aug 13, 2021 · 6 comments
Closed

Doesn't compile for platform x86_64-unknown-linux-musl #186

LMJW opened this issue Aug 13, 2021 · 6 comments
Labels
guidance Question that needs advice or information.

Comments

@LMJW
Copy link

LMJW commented Aug 13, 2021

Bug Report

The package doesn't seem to compile for platform x86_64-unknown-linux-musl due to dependency ring v0.16.20. Is there anyway to mitigate this? Thinking to use the aws-sdk-s3 in lambda function, which needs to be compiled for x86_64-unknown-linux-musl platform

Thanks for the help.

Version

cargo tree | grep aws-sdk-
├── aws-sdk-s3 v0.0.15-alpha (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   ├── aws-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   ├── smithy-async v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   │   ├── smithy-eventstream v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   │   │   └── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── aws-endpoint v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   └── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── aws-http v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── aws-hyper v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   ├── aws-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── aws-endpoint v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── aws-http v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── aws-sig-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   │   ├── aws-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   │   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── smithy-client v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   │   ├── smithy-http-tower v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)
│   │   │   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── smithy-http-tower v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   │   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── aws-sig-auth v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── aws-types v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── smithy-http v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   ├── smithy-types v0.0.1 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45) (*)
│   └── smithy-xml v0.1.0 (https://github.com/awslabs/aws-sdk-rust?tag=v0.0.15-alpha#ce01df45)

Platform

MacOS cross compiling to x86_64-unknown-linux-musl (setup see https://github.com/awslabs/aws-lambda-rust-runtime)

Darwin Kernel Version 19.6.0

AWS Services

S3, maybe other services as well

Description

The cargo dependency is:

# Cargo.toml

[dependencies]
lambda_runtime = "0.4.0"
regex = "1"
s3 = {git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.15-alpha", package = "aws-sdk-s3"}
serde = {version = "1", features = ["derive"]}
serde_json = "^1"
tokio = {version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"]}
tracing = {version = "0.1", features = ["log"]}
tracing-subscriber = "0.2"

When run cargo build --release --target x86_64-unknown-linux-musl, the compilation failed with below error:

error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `xxxxx/target/release/build/ring-91461ad56b0833de/build-script-build` (exit code: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-unknown-linux-musl")
  HOST = Some("x86_64-apple-darwin")
  CC_x86_64-unknown-linux-musl = None
  CC_x86_64_unknown_linux_musl = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_x86_64-unknown-linux-musl = None
  CFLAGS_x86_64_unknown_linux_musl = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")

  --- stderr
  running "musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/xxxxx/target/x86_64-unknown-linux-musl/release/build/ring-6846f69c91be693b/out/aesni-x86_64-elf.o" "/Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-elf.S"
  
thread 'main' panicked at 'failed to execute ["musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-U_FORTIFY_SOURCE" "-DNDEBUG" "-c" "-o/xxxxx/target/x86_64-unknown-linux-musl/release/build/ring-6846f69c91be693b/out/aesni-x86_64-elf.o" "/Users/xxxxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesni-x86_64-elf.S"]: No such file or directory (os error 2)', /Users/xxxxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:653:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I think the compilation fails forring crate, but is there anyway to mitigate this? Thanks for the help.

@LMJW LMJW added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 13, 2021
@rcoh
Copy link
Contributor

rcoh commented Aug 13, 2021

hello! The issue here is actually that musl-gcc can't be found. I suspect (and let me know if I'm wrong!) that if you just run musl-gcc in a terminal you'll get an error.

This is because there appears to be a problem with the musl-cross brew package that's failing to create the right symlink.

ring is expecting a compiler named musl-gcc but the musl-cross package is creating a compiler named x86_64-linux-musl-gcc.

Two ways to fix this:

  1. Teach ring about this compiler:
    export CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc
  2. symlink your musl compiler to be named musl-gcc so that ring can find it:
    ln -s /usr/local/opt/musl-cross/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

I'm going to close this issue since it's not actually an SDK problem, feel free to open a discussion if you need more assistance.

@rcoh rcoh closed this as completed Aug 13, 2021
@rcoh rcoh added guidance Question that needs advice or information. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 13, 2021
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@LMJW
Copy link
Author

LMJW commented Aug 13, 2021

hello! The issue here is actually that musl-gcc can't be found. I suspect (and let me know if I'm wrong!) that if you just run musl-gcc in a terminal you'll get an error.

This is because there appears to be a problem with the musl-cross brew package that's failing to create the right symlink.

ring is expecting a compiler named musl-gcc but the musl-cross package is creating a compiler named x86_64-linux-musl-gcc.

Two ways to fix this:

  1. Teach ring about this compiler:
    export CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc
  2. symlink your musl compiler to be named musl-gcc so that ring can find it:
    ln -s /usr/local/opt/musl-cross/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

I'm going to close this issue since it's not actually an SDK problem, feel free to open a discussion if you need more assistance.

This is brilliant! Works perfectly now! Thanks!

@archwebio
Copy link

  1. symlink your musl compiler to be named musl-gcc so that ring can find it:
    ln -s /usr/local/opt/musl-cross/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

This works great , but for me the binary was saved on another path. In my case the command was:

sudo ln -s /opt/homebrew/Cellar/musl-cross/0.9.9_1/libexec/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

@wilhelmsen
Copy link

  1. symlink your musl compiler to be named musl-gcc so that ring can find it:
    ln -s /usr/local/opt/musl-cross/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

This works great , but for me the binary was saved on another path. In my case the command was:

sudo ln -s /opt/homebrew/Cellar/musl-cross/0.9.9_1/libexec/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

After upgrading my OS, this also worked for me, but I had to link an other path:

ln -s ~/.rvm/gems/ruby-2.7.6@gemset/gems/libv8-node-16.10.0.0-x86_64-linux-musl/vendor/v8/x86_64-linux-musl ~/.rvm/gems/ruby-2.7.6@gemset/gems/libv8-node-16.10.0.0-x86_64-linux-musl/vendor/v8/x86_64-linux

@aragalie
Copy link

For MacOS Ventura (13.1) you need

sudo ln -s /opt/homebrew/Cellar/musl-cross/0.9.9_1/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

5 participants