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

statically link libpq (fixes #213) #234

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 3 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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-234"
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 . .
Expand Down
12 changes: 0 additions & 12 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
+
Expand Down Expand Up @@ -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]
Expand Down
16 changes: 7 additions & 9 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -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"