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

Cannot build due to libssl.so.1.1 link error #473

Closed
mikeplus64 opened this issue Jul 2, 2020 · 12 comments
Closed

Cannot build due to libssl.so.1.1 link error #473

mikeplus64 opened this issue Jul 2, 2020 · 12 comments

Comments

@mikeplus64
Copy link
Contributor

Writing an issue because I'm baffled.

Building master with cargo build --no-default-features --features 'runtime-tokio macros postgres' fails, but is ok with only one of postgres or macros -- it's the combination that is the immediate/superficial cause of the build fail.

Build output:

mike@mal ~/C/sqlx> cargo build --no-default-features --features 'runtime-tokio macros postgres' --verbose          101 master
       Fresh cfg-if v0.1.10
       Fresh autocfg v1.0.0
       Fresh unicode-xid v0.2.1
       Fresh version_check v0.9.2
       Fresh lazy_static v1.4.0
       Fresh cc v1.0.55
       Fresh pkg-config v0.3.17
       Fresh slab v0.4.2
       Fresh futures-core v0.3.5
       Fresh proc-macro-hack v0.5.16
       Fresh foreign-types-shared v0.1.1
       Fresh ppv-lite86 v0.2.8
       Fresh siphasher v0.3.3
       Fresh futures-sink v0.3.5
       Fresh matches v0.1.8
       Fresh tinyvec v0.3.3
       Fresh once_cell v1.4.0
       Fresh arc-swap v0.4.7
       Fresh futures-io v0.3.5
       Fresh pin-project-lite v0.1.7
       Fresh fnv v1.0.7
       Fresh pin-utils v0.1.0
       Fresh byte-tools v0.3.1
       Fresh openssl-probe v0.1.2
       Fresh bytes v0.5.5
       Fresh cpuid-bool v0.1.0
       Fresh instant v0.1.4
       Fresh scopeguard v1.1.0
       Fresh regex-syntax v0.6.18
       Fresh smallvec v1.4.0
       Fresh opaque-debug v0.3.0
       Fresh subtle v2.2.3
       Fresh opaque-debug v0.2.3
       Fresh maplit v1.0.2
       Fresh percent-encoding v2.1.0
       Fresh linked-hash-map v0.5.3
       Fresh ahash v0.3.8
       Fresh either v1.5.3
       Fresh unicode-segmentation v1.6.0
       Fresh itoa v0.4.6
       Fresh whoami v0.9.0
       Fresh hex v0.4.2
       Fresh base64 v0.12.3
       Fresh dotenv v0.15.0
       Fresh foreign-types v0.3.2
       Fresh thread_local v1.0.1
       Fresh unicode-normalization v0.1.13
       Fresh futures-task v0.3.5
       Fresh futures-channel v0.3.5
       Fresh phf_shared v0.8.0
       Fresh unicode-bidi v0.3.4
       Fresh block-padding v0.1.5
       Fresh lock_api v0.4.0
       Fresh libc v0.2.71
       Fresh proc-macro2 v1.0.18
       Fresh typenum v1.12.0
       Fresh memchr v2.3.3
       Fresh log v0.4.8
       Fresh bitflags v1.2.1
       Fresh lru-cache v0.1.2
       Fresh heck v0.3.1
       Fresh quote v1.0.7
       Fresh generic-array v0.14.2
       Fresh getrandom v0.1.14
       Fresh net2 v0.2.34
       Fresh iovec v0.1.4
       Fresh openssl-sys v0.9.58
       Fresh num_cpus v1.13.0
       Fresh signal-hook-registry v1.2.0
       Fresh proc-macro-nested v0.1.6
       Fresh byteorder v1.3.4
       Fresh aho-corasick v0.7.13
       Fresh maybe-uninit v2.0.0
       Fresh parking_lot_core v0.8.0
       Fresh idna v0.2.0
       Fresh stringprep v0.1.2
       Fresh syn v1.0.33
       Fresh rand_core v0.5.1
       Fresh digest v0.9.0
       Fresh mio v0.6.22
       Fresh openssl v0.10.30
       Fresh crossbeam-utils v0.7.2
       Fresh block-buffer v0.9.0
       Fresh num-traits v0.2.12
       Fresh crypto-mac v0.8.0
       Fresh regex v1.3.9
       Fresh block-buffer v0.8.0
       Fresh url v2.1.1
       Fresh hashbrown v0.8.0
       Fresh parking_lot v0.11.0
       Fresh rand_pcg v0.2.1
       Fresh rand_chacha v0.2.2
       Fresh pin-project-internal v0.4.22
       Fresh mio-uds v0.6.8
       Fresh tokio-macros v0.2.5
       Fresh futures-macro v0.3.5
       Fresh native-tls v0.2.4
       Fresh thiserror-impl v1.0.20
       Fresh atoi v0.3.2
       Fresh crossbeam-queue v0.2.3
       Fresh crossbeam-channel v0.4.2
       Fresh hmac v0.8.1
       Fresh sqlformat v0.1.0
       Fresh sha-1 v0.9.1
       Fresh md-5 v0.9.0
       Fresh sha2 v0.9.1
       Fresh rand v0.7.3
       Fresh pin-project v0.4.22
       Fresh tokio v0.2.21
       Fresh thiserror v1.0.20
       Fresh phf_generator v0.8.0
       Fresh futures-util v0.3.5
       Fresh tokio-native-tls v0.1.0
       Fresh phf_macros v0.8.0
       Fresh futures-executor v0.3.5
       Fresh phf v0.8.0
       Fresh sqlx-rt v0.1.0-pre (/home/mike/Code/sqlx/sqlx-rt)
       Fresh futures v0.3.5
       Fresh sqlx-core v0.4.0-pre (/home/mike/Code/sqlx/sqlx-core)
       Fresh sqlx-macros v0.4.0-pre (/home/mike/Code/sqlx/sqlx-macros)
   Compiling sqlx v0.4.0-pre (/home/mike/Code/sqlx)
     Running `rustc --crate-name sqlx --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="macros"' --cfg 'feature="postgres"' --cfg 'feature="runtime-tokio"' --cfg 'feature="sqlx-macros"' -C metadata=64bbc5b7c372bbb7 -C extra-filename=-64bbc5b7c372bbb7 --out-dir /home/mike/Code/sqlx/target/debug/deps -C incremental=/home/mike/Code/sqlx/target/debug/incremental -L dependency=/home/mike/Code/sqlx/target/debug/deps --extern sqlx_core=/home/mike/Code/sqlx/target/debug/deps/libsqlx_core-a1f1796390502ea8.rmeta --extern sqlx_macros=/home/mike/Code/sqlx/target/debug/deps/libsqlx_macros-f0786c7afdec1ae0.so`
error: libssl.so.1.1: cannot open shared object file: No such file or directory
  --> src/lib.rs:53:1
   |
53 | pub extern crate sqlx_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: could not compile `sqlx`.

Caused by:
  process didn't exit successfully: `rustc --crate-name sqlx --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="macros"' --cfg 'feature="postgres"' --cfg 'feature="runtime-tokio"' --cfg 'feature="sqlx-macros"' -C metadata=64bbc5b7c372bbb7 -C extra-filename=-64bbc5b7c372bbb7 --out-dir /home/mike/Code/sqlx/target/debug/deps -C incremental=/home/mike/Code/sqlx/target/debug/incremental -L dependency=/home/mike/Code/sqlx/target/debug/deps --extern sqlx_core=/home/mike/Code/sqlx/target/debug/deps/libsqlx_core-a1f1796390502ea8.rmeta --extern sqlx_macros=/home/mike/Code/sqlx/target/debug/deps/libsqlx_macros-f0786c7afdec1ae0.so` (exit code: 1)

My system definitely has libssl.so.1.1;

mike@mal ~/C/sqlx> strings /etc/ld.so.cache | grep libssl.so.1.1                                                   130 master
libssl.so.1.1
/usr/lib/libssl.so.1.1
libssl.so.1.1
/usr/lib32/libssl.so.1.1
mike@mal ~/C/sqlx> file /usr/lib/libssl.so.1.1                                                                         master
/usr/lib/libssl.so.1.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=bb85dfcea37aded72aff62b1da10b635154728d6, stripped

Any ideas?

@mikeplus64
Copy link
Contributor Author

mikeplus64 commented Jul 2, 2020

The last commit that I can build from is 1bdc3e9.

@mikeplus64
Copy link
Contributor Author

More info

mike@mal ~/C/sqlx> openssl version                                                                                     master
OpenSSL 1.1.1g  21 Apr 2020
mike@mal ~/C/sqlx> ldd $(which openssl)                                                                                master
	linux-vdso.so.1 (0x00007ffe10d33000)
	libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x00007f052e44b000)
	libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007f052e16e000)
	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f052e14c000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f052df85000)
	libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f052df7f000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f052e5e6000)

@mehcode
Copy link
Member

mehcode commented Jul 3, 2020

@mikeplus64 This doesn't look like an issue with SQLx but with the openssl crate. We pull in openssl on Linux from the native-tls crate. Can you try compiling an empty project with just the openssl and/or native-tls dependency?

sqlx/Cargo.lock

Line 1526 in 7270061

name = "openssl"

@mikeplus64
Copy link
Contributor Author

@mikeplus64 This doesn't look like an issue with SQLx but with the openssl crate. We pull in openssl on Linux from the native-tls crate. Can you try compiling an empty project with just the openssl and/or native-tls dependency?

sqlx/Cargo.lock

Line 1526 in 7270061

name = "openssl"

Using

[package]
name = "openssl_test"
version = "0.1.0"
edition = "2018"

[dependencies]
openssl = "0.10.30"
native-tls = "0.2.4"

Builds fine.

@mehcode
Copy link
Member

mehcode commented Jul 4, 2020

Can you try with nightly and enabling the new feature resolution from Cargo?

https://doc.rust-lang.org/cargo/reference/unstable.html#features

cargo +nightly -Zfeatures=itarget,dev_dep,host_dep build

If that doesn't work can you share your exact system name ( uname -a ) and I'll see about getting a virtual machine and trying to reproduce this.

@mikeplus64
Copy link
Contributor Author

mikeplus64 commented Jul 6, 2020

Sadly no effect.

mike@mal ~/C/sqlx> cargo --version                                                                                 101 master
cargo 1.46.0-nightly (79c769c3d 2020-06-11)
mike@mal ~/C/sqlx> rustc --version                                                                                     master
rustc 1.46.0-nightly (e55d3f9c5 2020-06-18)
mike@mal ~/C/sqlx> cargo -Zfeatures=itarget,dev_dep,host_dep build --no-default-features --features 'runtime-tokio macros postgres' --verbose
       Fresh cfg-if v0.1.10
       Fresh autocfg v1.0.0
       Fresh unicode-xid v0.2.1
       Fresh version_check v0.9.2
       Fresh lazy_static v1.4.0
       Fresh cc v1.0.55
       Fresh slab v0.4.2
       Fresh pkg-config v0.3.17
       Fresh proc-macro-hack v0.5.16
       Fresh ppv-lite86 v0.2.8
       Fresh once_cell v1.4.0
       Fresh foreign-types-shared v0.1.1
       Fresh futures-core v0.3.5
       Fresh pin-utils v0.1.0
       Fresh tinyvec v0.3.3
       Fresh siphasher v0.3.3
       Fresh matches v0.1.8
       Fresh pin-project-lite v0.1.7
       Fresh openssl-probe v0.1.2
       Fresh bytes v0.5.5
       Fresh byte-tools v0.3.1
       Fresh opaque-debug v0.3.0
       Fresh futures-io v0.3.5
       Fresh subtle v2.2.3
       Fresh smallvec v1.4.0
       Fresh regex-syntax v0.6.18
       Fresh instant v0.1.4
       Fresh futures-sink v0.3.5
       Fresh scopeguard v1.1.0
       Fresh cpuid-bool v0.1.0
       Fresh ahash v0.3.8
       Fresh maplit v1.0.2
       Fresh percent-encoding v2.1.0
       Fresh opaque-debug v0.2.3
       Fresh linked-hash-map v0.5.3
       Fresh whoami v0.9.0
       Fresh unicode-segmentation v1.6.0
       Fresh base64 v0.12.3
       Fresh hex v0.4.2
       Fresh either v1.5.3
       Fresh itoa v0.4.6
       Fresh dotenv v0.15.0
       Fresh thread_local v1.0.1
       Fresh foreign-types v0.3.2
       Fresh futures-task v0.3.5
       Fresh futures-channel v0.3.5
       Fresh phf_shared v0.8.0
       Fresh unicode-bidi v0.3.4
       Fresh unicode-normalization v0.1.13
       Fresh block-padding v0.1.5
       Fresh lock_api v0.4.0
       Fresh libc v0.2.71
       Fresh proc-macro2 v1.0.18
       Fresh memchr v2.3.3
       Fresh typenum v1.12.0
       Fresh log v0.4.8
       Fresh lru-cache v0.1.2
       Fresh heck v0.3.1
       Fresh quote v1.0.7
       Fresh getrandom v0.1.14
       Fresh generic-array v0.14.2
       Fresh net2 v0.2.34
       Fresh iovec v0.1.4
       Fresh openssl-sys v0.9.58
       Fresh bitflags v1.2.1
       Fresh proc-macro-nested v0.1.6
       Fresh num_cpus v1.13.0
       Fresh maybe-uninit v2.0.0
       Fresh aho-corasick v0.7.13
       Fresh byteorder v1.3.4
       Fresh idna v0.2.0
       Fresh parking_lot_core v0.8.0
       Fresh stringprep v0.1.2
       Fresh syn v1.0.33
       Fresh rand_core v0.5.1
       Fresh digest v0.9.0
       Fresh mio v0.6.22
       Fresh openssl v0.10.30
       Fresh crossbeam-utils v0.7.2
       Fresh block-buffer v0.9.0
       Fresh num-traits v0.2.12
       Fresh crypto-mac v0.8.0
       Fresh regex v1.3.9
       Fresh block-buffer v0.8.0
       Fresh hashbrown v0.8.0
       Fresh parking_lot v0.11.0
       Fresh url v2.1.1
       Fresh rand_chacha v0.2.2
       Fresh pin-project-internal v0.4.22
       Fresh futures-macro v0.3.5
       Fresh rand_pcg v0.2.1
       Fresh tokio-macros v0.2.5
       Fresh mio-uds v0.6.8
       Fresh native-tls v0.2.4
       Fresh thiserror-impl v1.0.20
       Fresh atoi v0.3.2
       Fresh sqlformat v0.1.0
       Fresh crossbeam-queue v0.2.3
       Fresh md-5 v0.9.0
       Fresh sha-1 v0.9.1
       Fresh sha2 v0.9.1
       Fresh crossbeam-channel v0.4.2
       Fresh hmac v0.8.1
       Fresh pin-project v0.4.22
       Fresh tokio v0.2.21
       Fresh rand v0.7.3
       Fresh thiserror v1.0.20
       Fresh phf_generator v0.8.0
       Fresh tokio-native-tls v0.1.0
       Fresh futures-util v0.3.5
       Fresh phf_macros v0.8.0
       Fresh sqlx-rt v0.1.0-pre (/home/mike/Code/sqlx/sqlx-rt)
       Fresh futures-executor v0.3.5
       Fresh phf v0.8.0
       Fresh futures v0.3.5
       Fresh sqlx-core v0.4.0-pre (/home/mike/Code/sqlx/sqlx-core)
       Fresh sqlx-macros v0.4.0-pre (/home/mike/Code/sqlx/sqlx-macros)
   Compiling sqlx v0.4.0-pre (/home/mike/Code/sqlx)
     Running `rustc --crate-name sqlx --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="macros"' --cfg 'feature="postgres"' --cfg 'feature="runtime-tokio"' --cfg 'feature="sqlx-macros"' -C metadata=a95e22e5f73dda28 -C extra-filename=-a95e22e5f73dda28 --out-dir /home/mike/Code/sqlx/target/debug/deps -C incremental=/home/mike/Code/sqlx/target/debug/incremental -L dependency=/home/mike/Code/sqlx/target/debug/deps --extern sqlx_core=/home/mike/Code/sqlx/target/debug/deps/libsqlx_core-9262a42b5f7083e9.rmeta --extern sqlx_macros=/home/mike/Code/sqlx/target/debug/deps/libsqlx_macros-16d41f0df44967ec.so`
error: libssl.so.1.1: cannot open shared object file: No such file or directory
  --> src/lib.rs:53:1
   |
53 | pub extern crate sqlx_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: could not compile `sqlx`.

Caused by:
  process didn't exit successfully: `rustc --crate-name sqlx --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="macros"' --cfg 'feature="postgres"' --cfg 'feature="runtime-tokio"' --cfg 'feature="sqlx-macros"' -C metadata=a95e22e5f73dda28 -C extra-filename=-a95e22e5f73dda28 --out-dir /home/mike/Code/sqlx/target/debug/deps -C incremental=/home/mike/Code/sqlx/target/debug/incremental -L dependency=/home/mike/Code/sqlx/target/debug/deps --extern sqlx_core=/home/mike/Code/sqlx/target/debug/deps/libsqlx_core-9262a42b5f7083e9.rmeta --extern sqlx_macros=/home/mike/Code/sqlx/target/debug/deps/libsqlx_macros-16d41f0df44967ec.so` (exit code: 1)
mike@mal ~/C/sqlx>            

System info:

mike@mal ~/C/sqlx> uname -a                                                                                        101 master
Linux mal 5.7.6-arch1-1 #1 SMP PREEMPT Thu, 25 Jun 2020 00:14:47 +0000 x86_64 GNU/Linux
mike@mal ~/C/sqlx> ldd $(which openssl)                                                                                master	
        linux-vdso.so.1 (0x00007ffdf3669000)
	libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x00007fc84a1c7000)
	libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007fc849eea000)
	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fc849ec8000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007fc849d01000)
	libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fc849cfb000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fc84a362000)

Installed cargo and nix from mozilla's nixpkgs overlay, as in

# nixpkgs.nix
let
  inherit (import <nixpkgs> {}) fetchFromGitHub;

  bootstrap = fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs-channels";
    rev = "b27a19d5bf799f581a8afc2b554f178e58c1f524";
    sha256 = "0xl67j7ns9kzk1arr64r4lfiq74nw0awqbv6hnh8njx07rspqhdb";
  };

  moz_overlay = import (fetchFromGitHub {
    owner = "mozilla";
    repo = "nixpkgs-mozilla";
    rev = "e912ed483e980dfb4666ae0ed17845c4220e5e7c";
    sha256 = "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3";
  });

in
import bootstrap {
  overlays = [ moz_overlay ];
  config = {
    packageOverrides = super: {
      rust = (super.pkgs.rustChannelOf {
        date = "2020-06-19";
        channel = "nightly";
      }).rust;
    };
  };
}

$ nix-env -f ./nixpkgs.nix iA rust

@dakom
Copy link

dakom commented Jul 8, 2020

I'm hitting an error that feels related... trying to build against the rust-musl-builder image. Maybe this issue is helpful? emk/rust-musl-builder#64

@mehcode
Copy link
Member

mehcode commented Jul 8, 2020

Try vendoring OpenSSL. Add this to your Cargo.toml :

[dependencies.openssl]
version = "0.10.29"
features = [
    "vendored"
]

@dakom
Copy link

dakom commented Jul 8, 2020

ooh nice, that did fix it for me - thanks!

@mikeplus64
Copy link
Contributor Author

Nice, seems to have fixed it for me as well.

@mehcode
Copy link
Member

mehcode commented Jul 19, 2020

As this works with vendored, I don't think this is an issue with SQLx directly.

@andoriyu
Copy link

Forgive for necropost, but for future reference: the issue is because procedural macro executed in slightly different environment. That means when you run inside your nix shell, it doesn't know where libssl.so is.

So technically this is sqlx issue, but it is mostly irrelevant outside nix derivation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants