Skip to content

Doesn't compile for x86_64-fortanix-unknown-sgx on newer distros #398

Open
@DragonDev1906

Description

@DragonDev1906

When building mbedtls for the x86_64-fortanix-unknown-sgx target on newer linux distros (e.g. Arch or debian testing) you get the following error:

Note that the compilation does not fail because of the cmake version but somewhere related to /usr/include/bits/floatn.h. Compilation worked on previous arch versions when setting the CMAKE_POLICY_VERSION_MINIMUM=3.5 environment variable.

cargo build --target x86_64-fortanix-unknown-sgx
  --- stderr
  CMake Deprecation Warning at CMakeLists.txt:23 (cmake_minimum_required):
    Compatibility with CMake < 3.10 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
    to tell CMake that the project requires at least <min> but has been updated
    to work with policies introduced by <max> or earlier.


  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  CMake Warning:
    Manually-specified variables were not used by the project:

      CMAKE_ASM_COMPILER
      CMAKE_ASM_FLAGS
      CMAKE_CXX_COMPILER
      CMAKE_CXX_FLAGS
      GEN_FILES


  error: version 'sgx' in target triple 'x86_64-fortanix-unknown-sgx' is invalid
  /usr/include/bits/floatn.h:83:52: error: unsupported machine mode '__TC__'
  /usr/include/bits/floatn.h:97:9: error: __float128 is not supported on this target

  thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/mbedtls-sys-auto-2.28.11/build/bindgen.rs:151:14:
  bindgen error: ClangDiagnostic("error: version 'sgx' in target triple 'x86_64-fortanix-unknown-sgx' is invalid\n/usr/include/bits/floatn.h:83:52: error: unsupported machine mode '__TC__'\n/usr/include/bits/floatn.h:97:9: error: __float128 is not supported on this target\n")

SGX (probably) isn't (officially) supported on these distros, but it is still useful to be able to run cargo build or cargo check on them.

How to reproduce

For reproducibility (at least to some extend) I've tested compilation in docker, using the commands shown below.

Compilation fails with the error above

# docker run -it archlinux
CMAKE_POLICY_VERSION_MINIMUM=3.10 pacman -Sy rustup make cmake clang && rustup default stable && rustup target add x86_64-fortanix-unknown-sgx && cargo new app && cd app && cargo add mbedtls && cargo build --target x86_64-fortanix-unknown-sgx

# docker run -it debian:testing
apt update && apt install curl cmake clang gcc-multilib && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && . "$HOME/.cargo/env" && rustup default stable && rustup target add x86_64-fortanix-unknown-sgx && cargo new app && cd app && cargo add mbedtls && cargo build --target x86_64-fortanix-unknown-sgx

Note that CMAKE_POLICY_VERSION_MINIMUM=3.10 seems to be required on archlinux because cmake isn't old enough.

Compiling in these distros/images works

# docker run -it rust
apt update && apt install cmake clang gcc-multilib && rustup target add x86_64-fortanix-unknown-sgx  && cargo new app && cd app && cargo add mbedtls && cargo build --target x86_64-fortanix-unknown-sgx

# docker run -it debian
apt update && apt install curl cmake clang gcc-multilib && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && . "$HOME/.cargo/env" && rustup default stable && rustup target add x86_64-fortanix-unknown-sgx && cargo new app && cd app && cargo add mbedtls && cargo build --target x86_64-fortanix-unknown-sgx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions