# Default build type for gst-plugins-rs

**URL:** <https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573>\
**Category:** General Discussion\
**Tags:** rust\
**Created:** [November 13, 2024, 4:52pm UTC](https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573 "2024-11-13T16:52:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobafr](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/j/e495f1/32.png) [@jobafr](https://discourse.gstreamer.org/u/jobafr)\
**Post date:** [November 13, 2024, 4:52pm UTC](https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573/1 "2024-11-13T16:52:24Z")

</div>

So, I’m compiling from source. If I understand meson correctly, the [default overall build type is `buildtype=debugoptimized`](https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/337fee838811f7ebc5bcb1645ea5c5a4249f7d69/meson.build#L4).

However, then compiling with `-Drs=enabled`, the rust parts end up in some `target/debug` directory and cargo seems to be running with the debug profile, and rustc has `-C opt-level=1`. If I explicitly say `--buildtype release`, then rustc gets `-C opt-level=3` and also lto and artifacts end up under `target/release`.

Looking at the [`gst-plugins-rs/Cargo.toml`](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/blob/1dcf0943db38d8eddd9cd8d572c5722167952ba4/Cargo.toml#L119-L127), we see that the release profile is basically “optimized for speed but with debug info”, which is what I would expect of “debugoptimized” anyway.

```toml
[profile.release]
lto = true
opt-level = 3
debug = true
panic = 'unwind'

[profile.dev]
opt-level = 1
lto = "off"

```

Am I missing something, or is this intentional for some reason for this inconsistency?

---

<div class="post-metadata">

**Author:** ![slomo](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/slomo/32/4_2.png) [@slomo](https://discourse.gstreamer.org/u/slomo)\
**Post date:** [November 14, 2024, 3:46pm UTC](https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573/2 "2024-11-14T15:46:22Z")

</div>

If you compile without any optimizations at all, various plugins (and their tests) are multiple orders of magnitude slower and basically unusable.

---

<div class="post-metadata">

**Author:** ![jobafr](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/j/e495f1/32.png) [@jobafr](https://discourse.gstreamer.org/u/jobafr)\
**Post date:** [November 14, 2024, 4:29pm UTC](https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573/3 "2024-11-14T16:29:17Z")

</div>

Yes, that’s why I was wondering why I seem to get a debug build with a low optimization level by default.

---

<div class="post-metadata">

**Author:** ![slomo](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/slomo/32/4_2.png) [@slomo](https://discourse.gstreamer.org/u/slomo)\
**Post date:** [November 15, 2024, 8:09am UTC](https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573/4 "2024-11-15T08:09:12Z")

</div>

Ah you mean why `debugoptimized` only has minor optimizations and is the same as `debug`? That seems like a limitation of the cargo/meson wrapper script, and can probably be solved. Please create an issue in gitlab if that’s a concern for you.

---

<div class="post-metadata">

**Author:** ![jobafr](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/j/e495f1/32.png) [@jobafr](https://discourse.gstreamer.org/u/jobafr)\
**Post date:** [November 15, 2024, 11:32am UTC](https://discourse.gstreamer.org/t/default-build-type-for-gst-plugins-rs/3573/5 "2024-11-15T11:32:14Z")

</div>

Thank you, it’s not really an issue — I just found it a bit confusing and wondered whether the default behavior was this way was intentionally. I guess `opt-level = 1` is not “without optimizations”, so it can reasonably be called “debugoptimized”.
