Skip to content

Commit 3203271

Browse files
authored
update README to set RPATH appropriately (#217)
1 parent 5b7a0a6 commit 3203271

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

README.adoc

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,27 @@ See TODO.adoc for more info.
5151

5252
== Build and run
5353

54-
Both normal execution and the test suite expect the prescence of some existing binaries (described below) to be locatable within the `$PATH` environment variable.
55-
However, once these have been provided, the codebase should be buildable with `cargo build`, and testable with `cargo test`.
54+
You can **format the code** using `cargo fmt`. Make sure to run this before pushing changes. The CI checks that the code is correctly formatted.
5655

57-
**Prerequisites:**
56+
You can **run the https://github.com/rust-lang/rust-clippy[Clippy linter]** using `cargo clippy \-- -D warnings -A clippy::style`. Make sure to run this before pushing changes. The CI checks that the code is clippy-clean.
5857

59-
. Postgres
58+
**Prerequisites:**
6059

61-
Postgres is required to link against libpq for access to the database.
60+
Both normal execution and the test suite expect certain binaries (described below) on your PATH.
6261

63-
(See https://github.com/oxidecomputer/omicron/issues/213 ; we may be able to remove this dependency long-term)
62+
. libpq, the PostgreSQL client library
63+
+
64+
--
65+
We use Diesel's PostgreSQL support to connect to CockroachDB (which is wire-compatible with PostgreSQL). Diesel uses the native libpq to do this. You can get the client library with:
6466

65-
Linux: `sudo apt-get install libpq-dev`
66-
Mac: `brew install postgresql`
67-
Helios: `pkg install library/postgresql-13`
67+
* Helios: `pkg install library/postgresql-13`
68+
* Linux: `sudo apt-get install libpq-dev`
69+
* Mac: `brew install postgresql`
6870

69-
Additionally, to help all runtime commands find this library, we recommend the following:
70-
[source,text]
71-
----
72-
export LD_LIBRARY_PATH="$(pg_config --libdir)"
73-
----
71+
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.
7472

73+
See the note about setting RUSTFLAGS at build time below.
74+
--
7575
. CockroachDB v20.2.5.
7676
+
7777
The test suite expects to be able to start a single-node CockroachDB cluster using the `cockroach` executable on your PATH.
@@ -87,7 +87,7 @@ See <<_configuring_clickhouse>> for details on ClickHouse's setup and configurat
8787
+
8888
. Additional software requirements:
8989
+
90-
On an illumos based machine (Helios, OmniOS), make sure your packages are up to date, and you have the `brand/sparse` package:
90+
On an illumos-based machine (Helios, OmniOS), if you want to run the real (non-simulated) Sled Agent to run actual VMs with Propolis, make sure your packages are up to date, and you have the `brand/sparse` package:
9191
+
9292
[source,text]
9393
----
@@ -96,10 +96,6 @@ pkg install pkg:/package/pkg
9696
pkg update
9797
----
9898

99-
You can **format the code** using `cargo fmt`. Make sure to run this before pushing changes. The CI checks that the code is correctly formatted.
100-
101-
You can **run the https://github.com/rust-lang/rust-clippy[Clippy linter]** using `cargo clippy \-- -D warnings -A clippy::style`. Make sure to run this before pushing changes. The CI checks that the code is clippy-clean.
102-
10399
To **run Omicron** you need to run four programs:
104100

105101
* a CockroachDB cluster. For development, you can use the `omicron-dev` tool in this repository to start a single-node CockroachDB cluster **that will delete the database when you shut it down.**
@@ -108,11 +104,17 @@ the database files will be deleted when you stop the program.
108104
* `nexus`: the guts of the control plane
109105
* `sled-agent-sim`: a simulator for the component that manages a single sled
110106

111-
The easiest way to start the required databases is to use the built in `omicron-dev` tool.
112-
This tool assumes that the `cockroach` and `clickhouse` executables are on your PATH,
113-
and match the versions above.
107+
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.
114108

115-
1. Start CockroachDB using `omicron-dev db-run`:
109+
. Set `RUSTFLAGS` in your environment so that built binaries will be able to find your local copy of libpq. A typical example might look like this:
110+
+
111+
----
112+
$ export RUSTFLAGS="-Clink-args=-R$(pg_config --libdir)"
113+
----
114+
+ 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.
115+
+
116+
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.
117+
. Start CockroachDB using `omicron-dev db-run`:
116118
+
117119
[source,text]
118120
----
@@ -167,7 +169,7 @@ omicron-dev: populated database
167169
+
168170
Note that as the output indicates, this cluster will be available to anybody that can reach 127.0.0.1.
169171

170-
2. Start the ClickHouse database server:
172+
. Start the ClickHouse database server:
171173
+
172174
[source,text]
173175
----
@@ -178,7 +180,7 @@ omicron-dev: running ClickHouse (PID: 2463), full command is "clickhouse server
178180
omicron-dev: using /var/folders/67/2tlym22x1r3d2kwbh84j298w0000gn/T/.tmpJ5nhot for ClickHouse data storage
179181
----
180182

181-
3. `nexus` requires a configuration file to run. You can use `omicron-nexus/examples/config.toml` to start with. Build and run it like this:
183+
. `nexus` requires a configuration file to run. You can use `omicron-nexus/examples/config.toml` to start with. Build and run it like this:
182184
+
183185
[source,text]
184186
----
@@ -187,11 +189,11 @@ $ cargo run --bin=nexus -- omicron-nexus/examples/config.toml
187189
listening: http://127.0.0.1:12220
188190
----
189191

190-
4. `sled-agent` only accepts configuration on the command line. Run it with a uuid identifying itself (this would be a uuid for the sled it's managing), an IP:port for itself, and the IP:port of `nexus`'s _internal_ interface. Using default config, this might look like this:
192+
. `sled-agent-sim` only accepts configuration on the command line. Run it with a uuid identifying itself (this would be a uuid for the sled it's managing), an IP:port for itself, and the IP:port of `nexus`'s _internal_ interface. Using default config, this might look like this:
191193
+
192194
[source,text]
193195
----
194-
$ cargo run --bin=sled-agent -- run $(uuidgen) 127.0.0.1:12345 127.0.0.1:12221
196+
$ cargo run --bin=sled-agent-sim -- run $(uuidgen) 127.0.0.1:12345 127.0.0.1:12221
195197
...
196198
Jun 02 12:21:50.989 INFO listening, local_addr: 127.0.0.1:12345, component: dropshot
197199
----

0 commit comments

Comments
 (0)