From e7f2a030a5fa1ec1def253cc2a232923ef035fc6 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Fri, 10 Sep 2021 15:35:21 -0700 Subject: [PATCH 1/4] statically link libpq --- .cargo/config | 7 +++++++ .github/workflows/rust.yml | 7 +++---- Cargo.lock | 9 ++++----- Cargo.toml | 8 ++++++++ README.adoc | 12 ------------ rust-toolchain.toml | 16 +++++++--------- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/.cargo/config b/.cargo/config index a721b8092b..f14d2780b6 100644 --- a/.cargo/config +++ b/.cargo/config @@ -6,3 +6,10 @@ # [build] rustdocflags = "--document-private-items" + +# +# Link libpq statically because there is no good way to specify RPATH for the +# dynamic version. See omicron#213 for details. +# +[env] +PQ_LIB_STATIC = "yes" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5d546cc8bf..69822cd64b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,10 +73,9 @@ jobs: fail-fast: false matrix: os: [ ubuntu-18.04, macos-10.15 ] - # NOTE: Although we'd like to use stable, we cannot with a newer version - # of Propolis as a dependency (which only builds with nightly). - # toolchain: [ nightly-2021-04-24, stable ] - toolchain: [ nightly-2021-04-24 ] + # See rust-toolchain.toml. If you update this, you MUST update + # rust-toolchain.toml as well! + toolchain: [ nightly-2021-09-03 ] steps: # actions/checkout@v2 - uses: actions/checkout@28c7f3d2b5162b5ddd3dfd9a45aa55eaf396478b diff --git a/Cargo.lock b/Cargo.lock index 2cab2ab5c3..bff0740c78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -990,13 +990,13 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.101" -source = "git+https://github.com/rust-lang/libc.git?rev=796459785#796459785e5190a02fdf7c223fc8aa91d04306f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" [[package]] name = "libc" version = "0.2.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" +source = "git+https://github.com/rust-lang/libc.git?rev=796459785#796459785e5190a02fdf7c223fc8aa91d04306f7" [[package]] name = "linked-hash-map" @@ -1661,8 +1661,7 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "pq-sys" version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda" +source = "git+https://github.com/oxidecomputer/pq-sys?branch=omicron#02011ea571cdc77ca2fcaabb2c6785d6ca917f54" dependencies = [ "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index 7f106ae73e..f7093a17bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,3 +32,11 @@ panic = "abort" #dropshot = { path = "../dropshot/dropshot" } #[patch."https://github.com/oxidecomputer/steno"] #steno = { path = "../steno" } + +# +# We maintain a fork of pq-sys to address upstream issues. See README.md.oxide +# in the branch for details. +# +[patch.crates-io.pq-sys] +git = 'https://github.com/oxidecomputer/pq-sys' +branch = "omicron" diff --git a/README.adoc b/README.adoc index 97f541d82a..643f48856b 100644 --- a/README.adoc +++ b/README.adoc @@ -69,8 +69,6 @@ We use Diesel's PostgreSQL support to connect to CockroachDB (which is wire-comp * Mac: `brew install postgresql` After doing this, you should have the `pg_config` command on your PATH. For example, on Helios, you'd want `/opt/ooce/bin` on your PATH. - -See the note about setting RUSTFLAGS and RUSTDOCFLAGS at build time below. -- . CockroachDB v20.2.5. + @@ -105,16 +103,6 @@ the database files will be deleted when you stop the program. * `sled-agent-sim`: a simulator for the component that manages a single sled The easiest way to start the required databases is to use the built-in `omicron-dev` tool. This tool assumes that the `cockroach` and `clickhouse` executables are on your PATH, and match the versions above. - -. Set `RUSTFLAGS` and `RUSTDOCFLAGS` in your environment so that built binaries will be able to find your local copy of libpq. A typical example might look like this: -+ ----- -$ export RUSTFLAGS="-Clink-args=-R$(pg_config --libdir)" -$ export RUSTDOCFLAGS="$RUSTFLAGS" ----- -+ Note that this might be wrong in some configurations or if you're using environment variables to control how the `pq-sys` crate finds libpq. See https://github.com/oxidecomputer/omicron/issues/213[#213] for details. -+ -NOTE: You may be able to skip this step if your libpq is in a directory that's already part of the runtime linker's default search path, which may be the case if you've installed libpq using the system package manager. This step is necessarily on Helios because the package manager does not put libpq on the default ld.so search path. . Start CockroachDB using `omicron-dev db-run`: + [source,text] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ce5ebcaeb7..2666e43b70 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,17 +1,15 @@ -# We use nightly to enable the "asm" feature for dtrace probes. # -# Additionally, we specify this specific verion of nightly to -# workaround known bugs for illumos on more recent versions. -# Context: https://github.com/rust-lang/rust/pull/85772 +# We use nightly for a few unstable features: # -# Short-term: Once that bug is fixed, we should feel free -# to update to migrate to a more recent nightly. +# - the "asm" feature for dtrace probes (within Propolis) +# - the "configurable_env" feature (stabilized in 1.56) +# +# We specify a specific, known-good nightly to avoid regular breakage. +# Once the above features stabilize, we should switch back to "stable". # -# Long-term: Once the ASM feature is stabilized, we should -# consider using stable instead of nightly. [toolchain] # NOTE: This toolchain is also specified within .github/workflows/rust.yml # If you update it here, update that file too. -channel = "nightly-2021-04-24" +channel = "nightly-2021-09-03" profile = "default" From 45b173cc74cdaf740148a71305b84619621b781d Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Fri, 10 Sep 2021 18:59:49 -0700 Subject: [PATCH 2/4] update for latest pq-sys --- Cargo.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index bff0740c78..3a9fde3bef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1661,8 +1661,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "pq-sys" version = "0.4.6" -source = "git+https://github.com/oxidecomputer/pq-sys?branch=omicron#02011ea571cdc77ca2fcaabb2c6785d6ca917f54" +source = "git+https://github.com/oxidecomputer/pq-sys?branch=omicron#fac0151ac7f85e486edb107b30dad9284ca29187" dependencies = [ + "openssl-sys", "vcpkg", ] From 3498daf7b5827ef33f58fa4021edcc9b5845a0a0 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Mon, 13 Sep 2021 15:21:25 -0700 Subject: [PATCH 3/4] WIP: try fix Dockerfile --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 3b6a167bba..390edbe75c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,15 @@ FROM rust:latest as cargo-build ENV DEBIAN_FRONTEND=noninteractive +# +# postgresql-server-dev-13 is needed for libpgport.a and libpgcommon.a. It puts +# these into /usr/lib/postgresql/13/lib, which would not otherwise be found. +# +RUN apt-get update && apt-get install -y \ + postgresql-server-dev-13 +ENV LIBRARY_PATH=/usr/lib/postgresql/13/lib + + WORKDIR /usr/src/omicron COPY . . From 1c6e6f2488dc05d4ef1f0bfaf8b6e9e7d974dfd0 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Tue, 14 Sep 2021 17:10:17 -0700 Subject: [PATCH 4/4] lock to a different branch of pq-sys --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a9fde3bef..ecb794877b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1661,7 +1661,7 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "pq-sys" version = "0.4.6" -source = "git+https://github.com/oxidecomputer/pq-sys?branch=omicron#fac0151ac7f85e486edb107b30dad9284ca29187" +source = "git+https://github.com/oxidecomputer/pq-sys?branch=omicron-234#fac0151ac7f85e486edb107b30dad9284ca29187" dependencies = [ "openssl-sys", "vcpkg", diff --git a/Cargo.toml b/Cargo.toml index f7093a17bf..772bd524ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,4 +39,4 @@ panic = "abort" # [patch.crates-io.pq-sys] git = 'https://github.com/oxidecomputer/pq-sys' -branch = "omicron" +branch = "omicron-234"