Commit Graph

188 Commits

Author SHA1 Message Date
Colin Walters
ffe72d28ec app: Rename livefs.cxx → apply-live.cxx
Continuing the renaming.
2021-02-19 09:08:22 -05:00
Colin Walters
35342dabca build-sys: Always run makecargo build
When working on a PR to add a sub-crate I hit the fact
that our `find` bit wasn't fully accurate and spent some
time debugging the fact that the code I got after `make`
wasn't up to date.

Since cargo is smart in general, let's stop trying to
second guess its dependencies and just run `cargo build`
every time `make` is run.

(I'm not sure why we didn't do this from the start)
2021-02-12 15:18:45 -05:00
Colin Walters
f065c0dd32 Add --enable-sanitizers (not on by default yet)
This way we at least get unit test coverage (which...
our unit test coverage doesn't do much because our
main code paths require privileges or virt).

One main blocker to this is that rustc doesn't expose
first-class support for this yet:
https://github.com/rust-lang/rust/issues/39699

At a practical level this works when building in release
mode but fails with `cargo test` for some reason; linker
arguments being pruned?  Not sure.

So I was able to use this when composing to find a bug,
but then for some other reason the client
side apparently infinite loops inside libsolv.

So we're not enabling this yet for those reasons, but
let's land the build infrastructure now.

```
(lldb) thread backtrace
* thread #4, name = 'pool-/usr/bin/r'
  * frame #0: 0x00007fd61b97200f libc.so.6`__memcpy_sse2_unaligned_erms + 623
    frame #1: 0x00007fd61cbc88e6 libasan.so.6`__asan::asan_realloc(void*, unsigned long, __sanitizer::BufferedStackTrace*) + 214
    frame #2: 0x00007fd61cc4b725 libasan.so.6`__interceptor_realloc + 245
    frame #3: 0x00007fd61baec43e libsolv.so.1`solv_realloc + 30
    frame #4: 0x00007fd61baf0414 libsolv.so.1`repodata_add_dirstr + 276
    frame #5: 0x00007fd61bb6f755 libsolvext.so.1`end_element + 53
    frame #6: 0x00007fd61b05855d libxml2.so.2`xmlParseEndTag1.constprop.0 + 317
    frame #7: 0x00007fd61b063548 libxml2.so.2`xmlParseTryOrFinish.isra.0 + 888
    frame #8: 0x00007fd61af7ed20 libxml2.so.2`xmlParseChunk + 560
    frame #9: 0x00007fd61bb727e7 libsolvext.so.1`solv_xmlparser_parse + 183
    frame #10: 0x00007fd61bb5ea0e libsolvext.so.1`repo_add_rpmmd + 254
    frame #11: 0x000055a4fce7a5f5 rpm-ostree`::load_filelists_cb(repo=<unavailable>, fp=<unavailable>) at dnf-sack.cpp:444:23
    frame #12: 0x000055a4fce7cad6 rpm-ostree`load_ext(_DnfSack*, libdnf::Repo*, _hy_repo_repodata, char const*, char const*, int (*)(s_Repo*, _IO_FILE*), _GError**) at dnf-sack.cpp:430:13
    frame #13: 0x000055a4fce7df60 rpm-ostree`dnf_sack_load_repo at dnf-sack.cpp:1789:26
    frame #14: 0x000055a4fce7eee9 rpm-ostree`dnf_sack_add_repo at dnf-sack.cpp:2217:28
    frame #15: 0x000055a4fce7f0fb rpm-ostree`dnf_sack_add_repos at dnf-sack.cpp:2271:32
    frame #16: 0x000055a4fce870ee rpm-ostree`dnf_context_setup_sack_with_flags at dnf-context.cpp:1796:29
    frame #17: 0x000055a4fcdf757f rpm-ostree`rpmostree_context_download_metadata at rpmostree-core.cxx:1206:44
    frame #18: 0x000055a4fcdf95c3 rpm-ostree`rpmostree_context_prepare at rpmostree-core.cxx:2001:48
    frame #19: 0x000055a4fce54ab7 rpm-ostree`rpmostree_sysroot_upgrader_prep_layering at rpmostree-sysroot-upgrader.cxx:1018:38
    frame #20: 0x000055a4fcdcb143 rpm-ostree`deploy_transaction_execute(_RpmostreedTransaction*, _GCancellable*, _GError**) at rpmostreed-transaction-types.cxx:1445:49
    frame #21: 0x000055a4fcdba4cd rpm-ostree`transaction_execute_thread(_GTask*, void*, void*, _GCancellable*) at rpmostreed-transaction.cxx:340:34
    frame #22: 0x00007fd61c58f7e2 libgio-2.0.so.0`g_task_thread_pool_thread + 114
    frame #23: 0x00007fd61c3d7e54 libglib-2.0.so.0`g_thread_pool_thread_proxy.lto_priv.0 + 116
    frame #24: 0x00007fd61c3d52b2 libglib-2.0.so.0`g_thread_proxy + 82
    frame #25: 0x00007fd61b8af3f9 libpthread.so.0`start_thread + 233
    frame #26: 0x00007fd61b9c9903 libc.so.6`__clone + 67
(lldb)
```
2021-02-10 14:30:37 -05:00
Colin Walters
8f71dcfafe build-sys: Statically link binary against shlib code
Having our binary depend on the shared library, which in
turn depends on the binary (at runtime) is messy.
Instead, statically compile the shlib code into our binary.
This duplicates the text a bit, but it's not a lot of code.

The goal is to more easily in the future to e.g. move the
shared library out into a separate git repository entirely
that runs on a separate lifecycle - that would still build
using Automake for example while the main git repository
switches to purely cargo.

Another motivation is avoiding linker issues I had with other
patches due to this semi-cyclical dependency.
2021-02-09 03:37:31 -05:00
Jonathan Lebon
df7adbb5f0 Makefile-rpm-ostree: Fix setting of cargo_target_dir
We don't want tabs here otherwise it doesn't work.
2021-02-04 17:00:33 -05:00
Jonathan Lebon
dd6b805fce Makefile-rpm-ostree: Drop hardcoded release path
And actually, we can just use `rpm-ostree` here, which symlinks to the
correct one (and `install` follows links).
2021-02-04 17:00:33 -05:00
Luca BRUNO
1932979059 make/rust-test: fix linking and loading
This fixes link dependencies and build-libraries path, in order to
make Rust tests work.
It also introduces an additional wildcard target to allow specifying
a test filter to cargo.
2021-02-04 13:55:00 -05:00
Colin Walters
ae3392ffaf build-sys: Cleanly split up deps of public shlib vs internals
First, the public shared library only depends on a few
things (not the libdnf dependencies) so let's ensure we
only link it to those libraries.

And then, I realized we don't actually need the libdnf
dependencies here - I think I only added those back here
when trying vainly to keep the C unit tests working.  But
we don't have those anymore!  So we can delete the duplication
and fully rely on Cargo taking care of libdnf.

Conceptually for a static library we don't "link" it against
anything in Automake, that happens at the final stage with
the Rust linker.
2021-02-04 10:59:20 -05:00
Colin Walters
19c7fbb7c9 build-sys: Delete duplicate Rust pkg-config dependencies
We didn't need this after switching to a Rust main.
2021-02-04 10:59:20 -05:00
Colin Walters
588541c60d Move libdnf build over to Cargo
This is now further migration towards Cargo/Rust possible
because we switched our main binary.  We've had an internal
`libdnf-sys` crate for a while, but now it can take over
the build of the underlying library too (like many `-sys`
crates support).

This itself is just an incremental step towards migrating
the main rpm-ostree build system to e.g. cmake too (or
perhaps directly with the `cc` crate, not sure yet) and
driving it via `cargo` too.
2021-02-04 10:59:20 -05:00
Colin Walters
ded61a472f build-sys: Move some linkage purely to Rust
Now that we are generating solely a Rust binary, we can
have the canonical list of things to link on the Rust side.
2021-02-02 04:13:14 -05:00
Colin Walters
d218f27188 Change main entrypoint to be Rust
We now have bidirectional calling between Rust and C++,
but we are generating two static libraries that we then
link together with a tiny C++ `main.cxx`.
Let's make another huge leap towards oxdiation by
having Rust be the entrypoint.  This way cargo natively
takes care of linking the internal Rust library, and
our C++ internals become the library.

In other words, we've now fully inverted from
"C app with internal Rust library"
to "Rust binary with internal C++ library".

In order to make this work though we have to finally
kill the C unit tests.  But mostly everything covered
there is either being converted to Rust, or covered
elsewhere anyways.

Now as the doc comments in `main.rs` say...this is
a bit awkward because all the CLI code is still in C++.
Porting stuff to use e.g. `structopt` natively would
be a bit of a slog.  For now, we basically rely on
the fact that the Rust-native CLIs are all hidden
commands.

Update submodule: libdnf
2021-02-01 08:17:52 -05:00
Colin Walters
1cef69cf8a lib: Don't link to libdnf
Prep for "Rust-as-main", where I want to build libdnf statically.
And this really completes the "library thinout" story because
now we avoid dragging our *private* `libdnf.so` into the caller's
address space, which can cause potential conflicts if they're
also linking the system one. (Which could easily occur with
something like gnome-software)

All we were using libdnf for (indirectly via libsolv) is comparing
version strings but librpm can already do that for us.
2021-01-28 11:15:44 -05:00
Colin Walters
0f325b3490 Makefile.bindings: Also generate pure rust/cxx.h
This is necessary in order to use `rust::` in our header files
that are also used by bindings.
2021-01-27 19:36:34 -05:00
Colin Walters
4ce5f42d12 rust: Link to our C/C++ dependencies and internal library
This allows us to fully use cxx-rs with `extern "C++"`.  Now
we do call back into the C/C++ today, but it only works outside
of cargo/Rust's knowledge.  Most notably, it means we can't
use our C code in `cargo test`.  And that's a problem
for moving some C/C++ code to Rust, because we want to port
the unit tests too.

For now, re-declare our dependencies and part of the build
system inside the Cargo build.  However, this is also
an important step towards using Cargo as our *sole* build
system.

We don't add build dependencies too often, so the short
term duplication should be OK.

However, a major unfortunate side effect of this is that
we now need to serialize the build process; almost all the
C/C++ comes first (`librpmostreeinternals.la`) and then
the Rust build, then we finally generate the executable
with both.

The only way out of this really is to move more of the
C/C++ build into Cargo, and we probably want to refactor
into internal crates.
2021-01-26 13:47:56 +01:00
Colin Walters
632cecdca6 cxxrs: Work around failure with -Werror=missing-declarations
See https://github.com/dtolnay/cxx/issues/590
2021-01-26 13:47:56 +01:00
Jonathan Lebon
027f501f4a Makefile-rpm-ostree: Link to librt
For some reason, when building with `-g -Og`, I get a linker error for
a missing `lio_listio`. Adding `-lrt` fixes it. (We already link against
this transitively, so it's not actually a net new `DT_NEEDED`.)
2021-01-15 19:03:42 -05:00
Timothée Ravier
6cfdb1f585 countme: Add DNF Count Me support
Add support for the DNF Count Me feature [1,2,3] as a standalone
rpm-ostree subcommand called weekly via a systemd timer.

[1] https://fedoraproject.org/wiki/Changes/DNF_Better_Counting
[2] https://dnf.readthedocs.io/en/latest/conf_ref.html?highlight=countme#options-for-both-main-and-repo
[3] https://github.com/rpm-software-management/ci-dnf-stack/blob/master/dnf-behave-tests/features/countme.feature
2021-01-13 14:53:50 -05:00
Colin Walters
5b19195fe8 With vendored source, use cargo build --offline
This way we're sure it will build in e.g. Koji.  Right now
it's annoying to test that locally; one needs to explicitly
create a no-network container to do so strictly.  But
cargo has a convenient `--offline` flag, and nothing else
in our build stack should touch the network.
2021-01-11 15:10:07 -05:00
Colin Walters
08c414f897 Rework bindgen/cxx.rs usage and CI build
cxx.rs (aka cxxbridge) and cbindgen are
both generating source code.  Since the last release
we've introduced the former, and we need to ensure
that the generated cxx.rs source ends up in release tarballs
the same way as the cbindgen code.

Rationalize and clean up the binding infrastructure.
Drop support for the vendored cbindgen which we
weren't actually using:
Closes: https://github.com/coreos/rpm-ostree/issues/2392

Move the cxx-rs and cbindgen bits into the same place,
and update our CoreOS CI build to use a separate `Makefile.bindings`
that just generates the code, so our CI still "works like"
a main Koji RPM build.
2021-01-04 13:17:35 +01:00
Colin Walters
9b13ce3906 buildsys: Make one big rpmostreeinternals.la, enable unit tests again
In the previous buildsytem rework we disabled the unit tests because
of linking problems.  Now I realized that a simple solution is
to continue to build one big object, just make it an internal
static library and have a tiny "stub main" that delegates to an entrypoint.

That's basically what the C unit tests are - an alternative `main()`
with some extra code.
2020-12-23 17:45:29 +01:00
Colin Walters
d8263d2c38 Port rpmostree-builtin-compose to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
642c8b1453 Port rpmostree-builtin-kargs to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
9a91eecbb0 Port rpmostree-polkit-agent to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
665bb07994 Port rpmostree-override-builtins to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
2ada9808ec Port rpmostree-db-builtin-version to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
604145e1f9 Port rpmostree-db-builtin-list to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
63b5ccb1b1 Port rpmostree-db-builtin-dif to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
e58316ec94 Port rpmostree-builtin-finalize-deployment to C++
Prep for using https://cxx.rs/
2020-12-22 16:36:13 -05:00
Colin Walters
8ca0eddabf Port rpmostree-builtin-start-daemon to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
79488a76de Port rpmostree-builtin-db to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
761e92ab93 Port rpmostree-builtin-shlib-backend to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
4462f16fa4 Port rpmostree-builtin-testutils to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
5259323161 Port rpmostree-builtin-ex to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
c3cff4f8f4 Port rpmostree-builtin-status to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
ff5cc68879 Port rpmostree-builtin-initramfs-etc to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
6052c92f75 Port rpmostree-builtin-initramfs to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
b9cfbfae0f Port rpmostree-builtin-cleanup to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
e9fc5a95e8 Port rpmostree-builtin-cliwrap to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
b7050d61c2 Port rpmostree-builtin-cancel to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
ccf2a1ea97 Port rpmostree-builtin-rebase to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
e8bc9dbd00 Port rpmostree-builtin-reload to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
7f65818d53 Port rpmostree-builtin-deploy to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
5820fd2136 Port rpmostree-builtin-rollback to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
7c1b6df951 Port rpmostree-builtin-upgrade to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
8f3c50aacf Port rpmostree-builtin-livefs to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
86efc2035a Port rpmostree-builtin-refresh-md to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
8560e0ba3e Port rpmostree-builtin-usroverlay to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
626e82fb3a Port rpmostree-builtin-override to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00
Colin Walters
6c47792bd0 Port rpmostree-builtin-reset to C++
Prep for using https://cxx.rs/
2020-12-22 09:24:34 -05:00