sfackler / rust-openssl

OpenSSL bindings for Rust
1.4k stars 751 forks source link

Build failure on FreeBSD 12.2-RELEASE (12.1-RELEASE works just fine) #1369

Closed NuLL3rr0r closed 3 years ago

NuLL3rr0r commented 4 years ago

This is the build error:

error: failed to run custom build command for `openssl-sys v0.9.58`

Caused by:
  process didn't exit successfully: `/usr/home/mamadou/daily-stoic/target/release/build/openssl-sys-357c753b12970899/build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_FREEBSD_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_FREEBSD_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_FREEBSD_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_FREEBSD_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_FREEBSD_OPENSSL_DIR
  X86_64_UNKNOWN_FREEBSD_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rustc-link-search=native=/usr/local/lib
  cargo:rustc-link-lib=ssl
  cargo:rustc-link-lib=crypto
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-freebsd
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_freebsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-unknown-freebsd")
  HOST = Some("x86_64-unknown-freebsd")
  CC_x86_64-unknown-freebsd = None
  CC_x86_64_unknown_freebsd = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-freebsd = None
  CFLAGS_x86_64_unknown_freebsd = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/usr/local/include" "-Wall" "-Wextra" "-E" "build/expando.c"
  exit code: 0
  cargo:rustc-cfg=osslconf="OPENSSL_NO_BUF_FREELISTS"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_COMP"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_KRB5"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_PSK"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_RFC3779"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_SRP"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_SSL3_METHOD"
  cargo:conf=OPENSSL_NO_BUF_FREELISTS,OPENSSL_NO_COMP,OPENSSL_NO_KRB5,OPENSSL_NO_PSK,OPENSSL_NO_RFC3779,OPENSSL_NO_SRP,OPENSSL_NO_SSL3_METHOD
  cargo:rustc-cfg=libressl
  cargo:rustc-cfg=libressl251
  cargo:rustc-cfg=libressl261
  cargo:rustc-cfg=libressl270
  cargo:rustc-cfg=libressl271
  cargo:rustc-cfg=libressl273
  cargo:rustc-cfg=libressl280
  cargo:rustc-cfg=libressl281
  cargo:rustc-cfg=libressl291
  cargo:libressl_version_number=3020200f

  --- stderr
  thread 'main' panicked at '

  This crate is only compatible with OpenSSL 1.0.1 through 1.1.1, or LibreSSL 2.5
  through 3.2.0, but a different version of OpenSSL was found. The build is now aborting
  due to this version mismatch.

  ', /home/mamadou/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.58/build/main.rs:260:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

I modified this file and it works perfectly fine (commenting all calls to version_error() function):

/home/mamadou/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.58/build/main.rs

    if let Some(libressl_version) = libressl_version {
        println!("cargo:libressl_version_number={:x}", libressl_version);

        let major = (libressl_version >> 28) as u8;
        let minor = (libressl_version >> 20) as u8;
        let fix = (libressl_version >> 12) as u8;
        let (major, minor, fix) = match (major, minor, fix) {
            (2, 5, 0) => ('2', '5', '0'),
            (2, 5, 1) => ('2', '5', '1'),
            (2, 5, 2) => ('2', '5', '2'),
            (2, 5, _) => ('2', '5', 'x'),
            (2, 6, 0) => ('2', '6', '0'),
            (2, 6, 1) => ('2', '6', '1'),
            (2, 6, 2) => ('2', '6', '2'),
            (2, 6, _) => ('2', '6', 'x'),
            (2, 7, _) => ('2', '7', 'x'),
            (2, 8, 0) => ('2', '8', '0'),
            (2, 8, 1) => ('2', '8', '1'),
            (2, 8, _) => ('2', '8', 'x'),
            (2, 9, 0) => ('2', '9', '0'),
            (2, 9, _) => ('2', '9', 'x'),
            (3, 0, 0) => ('3', '0', '0'),
            (3, 0, 1) => ('3', '0', '1'),
            (3, 0, _) => ('3', '0', 'x'),
            (3, 1, 0) => ('3', '1', '0'),
            (3, 1, _) => ('3', '1', 'x'),
            (3, 2, 0) => ('3', '2', '0'),
            _ => ('3', '2', '2'),
            //_ => version_error(),
        };

        println!("cargo:libressl=true");
        println!("cargo:libressl_version={}{}{}", major, minor, fix);
        println!("cargo:version=101");
        Version::Libressl
    } else {
        let openssl_version = openssl_version.unwrap();
        println!("cargo:version_number={:x}", openssl_version);

        if openssl_version >= 0x1_01_02_00_0 {
            //version_error()
            println!("cargo:version=111");
            Version::Openssl11x
        } else if openssl_version >= 0x1_01_01_00_0 {
            println!("cargo:version=111");
            Version::Openssl11x
        } else if openssl_version >= 0x1_01_00_06_0 {
            println!("cargo:version=110");
            println!("cargo:patch=f");
            Version::Openssl11x
        } else if openssl_version >= 0x1_01_00_00_0 {
            println!("cargo:version=110");
            Version::Openssl11x
        } else if openssl_version >= 0x1_00_02_00_0 {
            println!("cargo:version=102");
            Version::Openssl10x
        } else if openssl_version >= 0x1_00_01_00_0 {
            println!("cargo:version=101");
            Version::Openssl10x
        } else {
            println!("cargo:version=111");
            Version::Openssl11x
            //version_error()
        }
    }
}

According to the official the FreeBSD 12.2-RELEASE Release Notes:

* OpenSSL has been updated to version 1.1.1h. [r366177]

And the LibreSSL version (installed from Ports):

$ pkg info | grep libressl
libressl-3.2.2                 Free version of the SSL/TLS protocol forked from OpenSSL
sfackler commented 4 years ago

https://github.com/sfackler/rust-openssl/pull/1333 adds support for 3.2.2, but tests are failing and those need to be figured out before it can land.