<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator>
  <link href="https://www.amyspark.me/blog/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="https://www.amyspark.me/" rel="alternate" type="text/html"/>
  <updated>2026-10-25T21:22:08+00:00</updated>
  <id>https://www.amyspark.me/blog/feed.xml</id>
  <title type="html">Amyspark</title>
  <subtitle>Musings of a fairy</subtitle>
  <author>
    <name>amyspark</name>
  </author>
  <entry>
    <title type="html">Linking and shrinking Rust static libraries: a tale of fire</title>
    <link href="https://www.amyspark.me/blog/posts/2025/11/07/dragonfire.html" rel="alternate" type="text/html" title="Linking and shrinking Rust static libraries: a tale of fire"/>
    <published>2025-11-07T12:00:00+00:00</published>
    <updated>2025-11-07T12:00:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2025/11/07/dragonfire</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2025/11/07/dragonfire.html">&lt;p&gt;At the GStreamer project, we produce SDKs for lots of platforms: Linux, Android, 
macOS, iOS, and Windows. However, as we port more and more plugins to Rust
&lt;span class="emoji" aria-label=":crab:" role="img"&gt;🦀&lt;/span&gt;, we are finding ourselves backed into a corner.&lt;/p&gt;

&lt;p&gt;Rust static libraries are simply too big.&lt;/p&gt;

&lt;p&gt;To give you an example, the AWS folks changed their SDK back in March to
switch their cryptographic toolkit over to their &lt;code&gt;aws-lc-rs&lt;/code&gt; crate &lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;.
However, that causes a 2-10x increase in code size (bug reports
&lt;a href="https://github.com/aws/aws-lc-rs/issues/745"&gt;here&lt;/a&gt; and &lt;a href="https://github.com/smithy-lang/smithy-rs/issues/4049"&gt;here&lt;/a&gt;),
which gets duplicated on every plugin that makes use of their ecosystem!&lt;/p&gt;

&lt;h2 id="what-are-rust-staticlibs-made-of"&gt;What are Rust staticlibs made of?&lt;/h2&gt;

&lt;p&gt;To summarise, each Rust plugin packs a copy of its dependencies, plus a copy of
the Rust standard library. This is not a problem on shared libraries and 
executables by their very nature, but on static libraries it causes several
issues:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="https://github.com/rust-lang/rust/issues/104707"&gt;Rust leaks unexported symbols from native staticlibs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;On some platform, &lt;a href="https://github.com/rust-lang/rust/issues/44322"&gt;linking against multiple Rust staticlibs is impossible&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="first-approach-single-object-prelinking"&gt;First approach: Single-Object Prelinking&lt;/h2&gt;

&lt;p&gt;I won’t bore you with the details as I’ve written
&lt;a href="/blog/posts/2024/01/10/stripping-rust-libraries.html"&gt;another blog post&lt;/a&gt;
on the subject; the gist is that you can unpack the library, and then
ask the linker to perform
&lt;a href="https://maskray.me/blog/2022-11-21-relocatable-linking"&gt;“partial linking” or “relocatable linking”&lt;/a&gt; (Linux term)
or &lt;a href="https://developer.apple.com/documentation/xcode/build-settings-reference#Perform-Single-Object-Prelink"&gt;“Single-Object Prelinking”&lt;/a&gt; (the Apple term, which I’ll use throughout the post)
over the object files. Setting which symbols you want to be visible
for downstream consumers lets dead-code elimination take place at the plugin
level, ensuring your libraries are now back to a reasonable size.&lt;/p&gt;

&lt;h2 id="why-is-it-not-enough"&gt;Why is it not enough?&lt;/h2&gt;

&lt;p&gt;Single-Object Prelinking has two drawbacks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Unoptimized code: the linker won’t be able to deduplicate functions between melded objects, as they’ve been hidden by the prelinking process.&lt;/li&gt;
  &lt;li&gt;Windows: there are no officially supported tools (read: Visual Studio, LLVM, GCC) to perform this at the compiler level. It is possible to do this with binutils, but the PE-COFF format doesn’t allow to change the visibility of unexported functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="melt-all-the-object-files-with-the-power-of-dragons-fire"&gt;Melt all the object files with the power of dragons’ fire!&lt;/h2&gt;

&lt;p&gt;As said earlier, &lt;a href="https://github.com/rust-lang/rust/issues/44322#issuecomment-3253730349"&gt;no tools on Windows support prelinking officially yet&lt;/a&gt;,
but there’s another thing we can do: library deduplication.&lt;/p&gt;

&lt;p&gt;Thanks to Rust’s comprehensive crate ecosystem, I wrote a new CLI tool which I
called &lt;code&gt;dragonfire&lt;/code&gt;. Given a complete Rust workspace or list of static
libraries, &lt;code&gt;dragonfire&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;reads all the static libraries in one pass&lt;/li&gt;
  &lt;li&gt;deduplicates the object files inside them based on their size and naming (Rust has its own, unique naming convention for object files – pretty useful!)&lt;/li&gt;
  &lt;li&gt;copies the duplicate objects into a new static library (usually called &lt;code&gt;gstrsworkspace&lt;/code&gt; as its primary use is for the GStreamer ecosystem)&lt;/li&gt;
  &lt;li&gt;removes the duplicates from the rest of the libraries&lt;/li&gt;
  &lt;li&gt;updates the symbol table in each of the libraries with the bundled LLVM tools&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks to the &lt;a href="https://docs.rs/ar/latest/ar/"&gt;ar&lt;/a&gt; crate, the unpacking and
writing only happens at stage 3, ensuring no wasteful I/O slowdowns takes place.
The &lt;a href="https://docs.rs/llvm-tools/0.1.1/llvm_tools/"&gt;llvm-tools-preview&lt;/a&gt; component
in turn takes care of locating and calling up &lt;code&gt;llvm-ar&lt;/code&gt; for updating the 
workspace’s symbol tables.&lt;/p&gt;

&lt;p&gt;A special mention is deserved to the object files’ naming convention. Assume a
Rust staticlib named &lt;code&gt;libfoo&lt;/code&gt;, its object files will be named as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;crate_name-hash1.crate_name.hash2-cgu.nnn.rcgu.o&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;On Windows only: &lt;code&gt;foo.crate_name-hash1.crate_name.hash2-cgu.nnn.rcgu.o&lt;/code&gt;
&lt;/li&gt;
  &lt;li&gt;On non-Windows platforms: same as above, but replacing &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;libfoo-hash&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In all cases, &lt;code&gt;crate_name&lt;/code&gt; means a dependency present somewhere in the
workspace tree, and&lt;code&gt; nnn&lt;/code&gt; is a number that will be bigger than zero whenever
&lt;code&gt;-C codegen-units&lt;/code&gt; was set to higher than 1.&lt;/p&gt;

&lt;p&gt;For &lt;code&gt;dragonfire&lt;/code&gt; purposes, dropping the library prefix is enough to be able to
deduplicate object files; however, on Windows we can also find import
library stubs, which LLVM can generate on its own by the use of the &lt;code&gt;#[raw-dylib]&lt;/code&gt; annotation &lt;sup id="fnref:4"&gt;&lt;a href="#fn:4" class="footnote" rel="footnote" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;. Import stubs can have any extension, e.g. &lt;code&gt;.dll&lt;/code&gt;,
&lt;code&gt;.exe&lt;/code&gt; and &lt;code&gt;.sys&lt;/code&gt; (the latter two coming from private Win32 APIs).
These stubs cannot be deduplicated as they are generated
individually per imported function, so &lt;code&gt;dragonfire&lt;/code&gt; must preserve them where
they are.&lt;/p&gt;

&lt;h2 id="drawbacks-of-object-file-deduplication"&gt;Drawbacks of object file deduplication&lt;/h2&gt;

&lt;p&gt;Again there are several disadvantages of this approach. On Apple platforms,
deduplicating libraries triggers a &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1935/diffs#d28b7f11a60bdebf2288eb9a6402c284c5434904_390_390"&gt;strange linker error&lt;/a&gt;, which I’ve not seen
before:&lt;/p&gt;

&lt;pre class="text-wrap"&gt;&lt;code&gt;ld: multiple errors: compact unwind must have at least 1 fixup in '&amp;lt;framework&amp;gt;/GStreamer[arm64][1021](libgstrsworkspace_a-3f2b47962471807d-lse_ldset4_acq.o)'; r_symbolnum=-19 out of range in '&amp;lt;framework&amp;gt;/GStreamer[arm64][1022](libgstrsworkspace_a-compiler_builtins-350c23344d78cfbc.compiler_builtins.5e126dca1f5284a9-cgu.162.rcgu.o)'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This also led me to find that &lt;a href="https://github.com/rust-lang/rust/issues/146145"&gt;Rust libraries were packing bitcode, which is forbidden by Apple&lt;/a&gt;. (This was thankfully &lt;a href="https://github.com/rust-lang/rust/pull/146133"&gt;already fixed&lt;/a&gt; before shipping time, but we’ve not yet updated our Rust minimum version to take advantage of it.)&lt;/p&gt;

&lt;p&gt;Another drawback is that Rust’s implementation of LTO causes dead-code
elimination at the crate level, as opposed to the workspace level. This makes
object file deduplication impossible, as each copy is different.&lt;/p&gt;

&lt;p&gt;For the Windows platform, there is an extra drawback which affects specifically
object files produced by LLVM: &lt;a href="https://github.com/rust-lang/rust/issues/143931"&gt;the COMDAT sections are set to &lt;code&gt;IMAGE_COMDAT_SELECT_NODUPLICATES&lt;/code&gt;&lt;/a&gt;.
This means that the linker will outright reject functions with multiple
definitions, rather than realise they’re all duplicates and discarding all but 
one of the copies. MSVC in particular &lt;a href="https://developercommunity.visualstudio.com/t/unresolved-external-symbol-referenced-in-function/1016851#TPIN-N1078418"&gt;performs symbol resolution
&lt;em&gt;before&lt;/em&gt; dead-code elimination&lt;/a&gt;.
This means that linking will fail because of unresolved symbols &lt;em&gt;before&lt;/em&gt; dead code elimination kicks in; to use deduplicated libraries, one must set the linker flags
&lt;code&gt;/OPT:REF /FORCE:UNRESOLVED&lt;/code&gt; to ensure the dead code can be successfully
eliminated.&lt;/p&gt;

&lt;h2 id="results"&gt;Results&lt;/h2&gt;

&lt;p&gt;With library deduplication, we can make static libraries up to 44x smaller
when building under MSVC &lt;sup id="fnref:3"&gt;&lt;a href="#fn:3" class="footnote" rel="footnote" role="doc-noteref"&gt;3&lt;/a&gt;&lt;/sup&gt; (you can expand the tables below for the full
comparison):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;gstaws.lib: from 173M to 71M (~2.5x)&lt;/li&gt;
  &lt;li&gt;gstrswebrtc.lib: from 193M to 66M (~2.9x)&lt;/li&gt;
  &lt;li&gt;gstwebrtchttp.lib: from 66M to 1,5M (~ 44x)&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class="figure d-block"&gt;

  &lt;table class="table table-striped table-sm table-hover"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;file&lt;/th&gt;
        &lt;th&gt;no prelinking&lt;/th&gt;
        &lt;th&gt;melded&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;gstaws.lib&lt;/td&gt;
        &lt;td&gt;173M&lt;/td&gt;
        &lt;td&gt;71M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstcdg.lib&lt;/td&gt;
        &lt;td&gt;36M&lt;/td&gt;
        &lt;td&gt;572K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstclaxon.lib&lt;/td&gt;
        &lt;td&gt;32M&lt;/td&gt;
        &lt;td&gt;568K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstdav1d.lib&lt;/td&gt;
        &lt;td&gt;34M&lt;/td&gt;
        &lt;td&gt;936K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstelevenlabs.lib&lt;/td&gt;
        &lt;td&gt;59M&lt;/td&gt;
        &lt;td&gt;1008K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstfallbackswitch.lib&lt;/td&gt;
        &lt;td&gt;37M&lt;/td&gt;
        &lt;td&gt;2,3M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstffv1.lib&lt;/td&gt;
        &lt;td&gt;34M&lt;/td&gt;
        &lt;td&gt;744K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstfmp4.lib&lt;/td&gt;
        &lt;td&gt;39M&lt;/td&gt;
        &lt;td&gt;3,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstgif.lib&lt;/td&gt;
        &lt;td&gt;34M&lt;/td&gt;
        &lt;td&gt;1,1M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstgopbuffer.lib&lt;/td&gt;
        &lt;td&gt;30M&lt;/td&gt;
        &lt;td&gt;456K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsthlsmultivariantsink.lib&lt;/td&gt;
        &lt;td&gt;46M&lt;/td&gt;
        &lt;td&gt;1,6M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsthlssink3.lib&lt;/td&gt;
        &lt;td&gt;41M&lt;/td&gt;
        &lt;td&gt;1,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsthsv.lib&lt;/td&gt;
        &lt;td&gt;34M&lt;/td&gt;
        &lt;td&gt;796K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstjson.lib&lt;/td&gt;
        &lt;td&gt;31M&lt;/td&gt;
        &lt;td&gt;704K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstlewton.lib&lt;/td&gt;
        &lt;td&gt;33M&lt;/td&gt;
        &lt;td&gt;1,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstlivesync.lib&lt;/td&gt;
        &lt;td&gt;33M&lt;/td&gt;
        &lt;td&gt;728K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstmp4.lib&lt;/td&gt;
        &lt;td&gt;38M&lt;/td&gt;
        &lt;td&gt;2,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstmpegtslive.lib&lt;/td&gt;
        &lt;td&gt;31M&lt;/td&gt;
        &lt;td&gt;704K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstndi.lib&lt;/td&gt;
        &lt;td&gt;38M&lt;/td&gt;
        &lt;td&gt;2,8M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstoriginalbuffer.lib&lt;/td&gt;
        &lt;td&gt;34M&lt;/td&gt;
        &lt;td&gt;376K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstquinn.lib&lt;/td&gt;
        &lt;td&gt;75M&lt;/td&gt;
        &lt;td&gt;23M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstraptorq.lib&lt;/td&gt;
        &lt;td&gt;33M&lt;/td&gt;
        &lt;td&gt;2,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrav1e.lib&lt;/td&gt;
        &lt;td&gt;46M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstregex.lib&lt;/td&gt;
        &lt;td&gt;38M&lt;/td&gt;
        &lt;td&gt;404K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstreqwest.lib&lt;/td&gt;
        &lt;td&gt;58M&lt;/td&gt;
        &lt;td&gt;1,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsanalytics.lib&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;1000K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsaudiofx.lib&lt;/td&gt;
        &lt;td&gt;54M&lt;/td&gt;
        &lt;td&gt;22M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsclosedcaption.lib&lt;/td&gt;
        &lt;td&gt;52M&lt;/td&gt;
        &lt;td&gt;8,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsinter.lib&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;604K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsonvif.lib&lt;/td&gt;
        &lt;td&gt;46M&lt;/td&gt;
        &lt;td&gt;2,0M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrspng.lib&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;1,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsrtp.lib&lt;/td&gt;
        &lt;td&gt;59M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsrtsp.lib&lt;/td&gt;
        &lt;td&gt;57M&lt;/td&gt;
        &lt;td&gt;4,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrstracers.lib&lt;/td&gt;
        &lt;td&gt;40M&lt;/td&gt;
        &lt;td&gt;2,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsvideofx.lib&lt;/td&gt;
        &lt;td&gt;48M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrswebrtc.lib&lt;/td&gt;
        &lt;td&gt;193M&lt;/td&gt;
        &lt;td&gt;66M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstrsworkspace.lib&lt;/td&gt;
        &lt;td&gt;N/A&lt;/td&gt;
        &lt;td&gt;137M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gststreamgrouper.lib&lt;/td&gt;
        &lt;td&gt;30M&lt;/td&gt;
        &lt;td&gt;376K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsttextahead.lib&lt;/td&gt;
        &lt;td&gt;30M&lt;/td&gt;
        &lt;td&gt;332K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsttextwrap.lib&lt;/td&gt;
        &lt;td&gt;32M&lt;/td&gt;
        &lt;td&gt;2,1M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstthreadshare.lib&lt;/td&gt;
        &lt;td&gt;52M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsttogglerecord.lib&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;808K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gsturiplaylistbin.lib&lt;/td&gt;
        &lt;td&gt;31M&lt;/td&gt;
        &lt;td&gt;648K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstvvdec.lib&lt;/td&gt;
        &lt;td&gt;34M&lt;/td&gt;
        &lt;td&gt;564K&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;gstwebrtchttp.lib&lt;/td&gt;
        &lt;td&gt;66M&lt;/td&gt;
        &lt;td&gt;1,5M&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

  &lt;figcaption class="figure-caption"&gt;Table: before and after melding under MSVC&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The results from the melding above can be compared with the file sizes obtained
using LTO on Windows &lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote" rel="footnote" role="doc-noteref"&gt;4&lt;/a&gt;&lt;/sup&gt; (remember it doesn’t actually fix
linking against plugins):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;gstaws.lib: from 71M (LTO) to 67M (melded) (-5.6%)&lt;/li&gt;
  &lt;li&gt;gstrswebrtc.lib: from 105M to 66M (-37.1%)&lt;/li&gt;
  &lt;li&gt;gstwebrtchttp.lib: from 28M to 1,5M (-94.6%)&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class="figure d-block"&gt;
  &lt;table class="table table-striped table-sm table-hover"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;file (codegen-units=1 in all cases)&lt;/th&gt;
        &lt;th&gt;no prelinking&lt;/th&gt;
        &lt;th&gt;lto=thin&lt;/th&gt;
        &lt;th&gt;opt-level=s + lto=thin&lt;/th&gt;
        &lt;th&gt;debug=1 + opt-level=s&lt;/th&gt;
        &lt;th&gt;debug=1  + lto=thin + opt-level=s&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstaws.lib&lt;/td&gt;
        &lt;td&gt;199M&lt;/td&gt;
        &lt;td&gt;199M&lt;/td&gt;
        &lt;td&gt;171M&lt;/td&gt;
        &lt;td&gt;78M&lt;/td&gt;
        &lt;td&gt;67M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstcdg.lib&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;7,5M&lt;/td&gt;
        &lt;td&gt;7,5M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstclaxon.lib&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;7,7M&lt;/td&gt;
        &lt;td&gt;7,7M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstdav1d.lib&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;7,9M&lt;/td&gt;
        &lt;td&gt;7,8M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstelevenlabs.lib&lt;/td&gt;
        &lt;td&gt;52M&lt;/td&gt;
        &lt;td&gt;52M&lt;/td&gt;
        &lt;td&gt;49M&lt;/td&gt;
        &lt;td&gt;24M&lt;/td&gt;
        &lt;td&gt;22M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstfallbackswitch.lib&lt;/td&gt;
        &lt;td&gt;18M&lt;/td&gt;
        &lt;td&gt;18M&lt;/td&gt;
        &lt;td&gt;17M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstffv1.lib&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;7,6M&lt;/td&gt;
        &lt;td&gt;7,6M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstfmp4.lib&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
        &lt;td&gt;19M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstgif.lib&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;7,9M&lt;/td&gt;
        &lt;td&gt;7,9M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstgopbuffer.lib&lt;/td&gt;
        &lt;td&gt;9,7M&lt;/td&gt;
        &lt;td&gt;9,7M&lt;/td&gt;
        &lt;td&gt;9,7M&lt;/td&gt;
        &lt;td&gt;7,5M&lt;/td&gt;
        &lt;td&gt;7,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsthlsmultivariantsink.lib&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsthlssink3.lib&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;8,9M&lt;/td&gt;
        &lt;td&gt;8,8M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsthsv.lib&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;7,8M&lt;/td&gt;
        &lt;td&gt;7,7M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstjson.lib&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;8,4M&lt;/td&gt;
        &lt;td&gt;8,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstlewton.lib&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;8,1M&lt;/td&gt;
        &lt;td&gt;8,1M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstlivesync.lib&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;8,3M&lt;/td&gt;
        &lt;td&gt;8,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstmp4.lib&lt;/td&gt;
        &lt;td&gt;17M&lt;/td&gt;
        &lt;td&gt;17M&lt;/td&gt;
        &lt;td&gt;17M&lt;/td&gt;
        &lt;td&gt;9,9M&lt;/td&gt;
        &lt;td&gt;9,7M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstmpegtslive.lib&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;8,0M&lt;/td&gt;
        &lt;td&gt;7,9M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstndi.lib&lt;/td&gt;
        &lt;td&gt;21M&lt;/td&gt;
        &lt;td&gt;21M&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
        &lt;td&gt;12M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstoriginalbuffer.lib&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,7M&lt;/td&gt;
        &lt;td&gt;7,4M&lt;/td&gt;
        &lt;td&gt;7,3M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstquinn.lib&lt;/td&gt;
        &lt;td&gt;94M&lt;/td&gt;
        &lt;td&gt;94M&lt;/td&gt;
        &lt;td&gt;86M&lt;/td&gt;
        &lt;td&gt;39M&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstraptorq.lib&lt;/td&gt;
        &lt;td&gt;18M&lt;/td&gt;
        &lt;td&gt;18M&lt;/td&gt;
        &lt;td&gt;17M&lt;/td&gt;
        &lt;td&gt;9,8M&lt;/td&gt;
        &lt;td&gt;9,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrav1e.lib&lt;/td&gt;
        &lt;td&gt;39M&lt;/td&gt;
        &lt;td&gt;39M&lt;/td&gt;
        &lt;td&gt;37M&lt;/td&gt;
        &lt;td&gt;19M&lt;/td&gt;
        &lt;td&gt;18M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstregex.lib&lt;/td&gt;
        &lt;td&gt;26M&lt;/td&gt;
        &lt;td&gt;26M&lt;/td&gt;
        &lt;td&gt;25M&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstreqwest.lib&lt;/td&gt;
        &lt;td&gt;53M&lt;/td&gt;
        &lt;td&gt;53M&lt;/td&gt;
        &lt;td&gt;49M&lt;/td&gt;
        &lt;td&gt;24M&lt;/td&gt;
        &lt;td&gt;22M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsanalytics.lib&lt;/td&gt;
        &lt;td&gt;15M&lt;/td&gt;
        &lt;td&gt;15M&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;9,2M&lt;/td&gt;
        &lt;td&gt;8,9M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsaudiofx.lib&lt;/td&gt;
        &lt;td&gt;57M&lt;/td&gt;
        &lt;td&gt;57M&lt;/td&gt;
        &lt;td&gt;56M&lt;/td&gt;
        &lt;td&gt;23M&lt;/td&gt;
        &lt;td&gt;22M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsclosedcaption.lib&lt;/td&gt;
        &lt;td&gt;40M&lt;/td&gt;
        &lt;td&gt;40M&lt;/td&gt;
        &lt;td&gt;36M&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
        &lt;td&gt;18M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsinter.lib&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;14M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;8,5M&lt;/td&gt;
        &lt;td&gt;8,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsonvif.lib&lt;/td&gt;
        &lt;td&gt;21M&lt;/td&gt;
        &lt;td&gt;21M&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrspng.lib&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;8,2M&lt;/td&gt;
        &lt;td&gt;8,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsrtp.lib&lt;/td&gt;
        &lt;td&gt;47M&lt;/td&gt;
        &lt;td&gt;47M&lt;/td&gt;
        &lt;td&gt;44M&lt;/td&gt;
        &lt;td&gt;22M&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsrtsp.lib&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;33M&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;15M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrstracers.lib&lt;/td&gt;
        &lt;td&gt;28M&lt;/td&gt;
        &lt;td&gt;28M&lt;/td&gt;
        &lt;td&gt;27M&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;15M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrsvideofx.lib&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;16M&lt;/td&gt;
        &lt;td&gt;35M&lt;/td&gt;
        &lt;td&gt;9,2M&lt;/td&gt;
        &lt;td&gt;15M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstrswebrtc.lib&lt;/td&gt;
        &lt;td&gt;329M&lt;/td&gt;
        &lt;td&gt;329M&lt;/td&gt;
        &lt;td&gt;284M&lt;/td&gt;
        &lt;td&gt;124M&lt;/td&gt;
        &lt;td&gt;105M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gststreamgrouper.lib&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,7M&lt;/td&gt;
        &lt;td&gt;7,2M&lt;/td&gt;
        &lt;td&gt;7,2M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsttextahead.lib&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,6M&lt;/td&gt;
        &lt;td&gt;9,5M&lt;/td&gt;
        &lt;td&gt;7,4M&lt;/td&gt;
        &lt;td&gt;7,3M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsttextwrap.lib&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;8,4M&lt;/td&gt;
        &lt;td&gt;8,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstthreadshare.lib&lt;/td&gt;
        &lt;td&gt;49M&lt;/td&gt;
        &lt;td&gt;49M&lt;/td&gt;
        &lt;td&gt;45M&lt;/td&gt;
        &lt;td&gt;23M&lt;/td&gt;
        &lt;td&gt;20M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsttogglerecord.lib&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;13M&lt;/td&gt;
        &lt;td&gt;8,5M&lt;/td&gt;
        &lt;td&gt;8,4M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gsturiplaylistbin.lib&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;7,9M&lt;/td&gt;
        &lt;td&gt;7,9M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstvvdec.lib&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;11M&lt;/td&gt;
        &lt;td&gt;7,5M&lt;/td&gt;
        &lt;td&gt;7,5M&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;old/gstwebrtchttp.lib&lt;/td&gt;
        &lt;td&gt;69M&lt;/td&gt;
        &lt;td&gt;69M&lt;/td&gt;
        &lt;td&gt;63M&lt;/td&gt;
        &lt;td&gt;30M&lt;/td&gt;
        &lt;td&gt;28M&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

  &lt;figcaption class="figure-caption"&gt;Table: before and after LTO under MSVC (no melding involved)&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This article presents several longstanding pain points in Rust, namely staticlib
binary sizes, symbol leaking, and incompatibilities between Rust and MSVC. I
demonstrate the tool &lt;code&gt;dragonfire&lt;/code&gt; that aims to address and work around, where
possible, these issues, along with remaining issues to be addressed.&lt;/p&gt;

&lt;p&gt;As explained earlier, &lt;code&gt;dragonfire&lt;/code&gt; treated libraries are live on all platforms
except Apple’s, if you use the development packages from mainline;
it’s on track hopefully for 
the 1.28 release of GStreamer. There’s already a &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1935"&gt;merge request pending to enable it for Apple platforms&lt;/a&gt;,
we’re only waiting to update the Rust mininum version.&lt;/p&gt;

&lt;p&gt;If you want to have a look, &lt;code&gt;dragonfire&lt;/code&gt;’s source code is available at
&lt;a href="https://gitlab.freedesktop.org/amyspark/dragonfire"&gt;Freedesktop’s GitLab instance&lt;/a&gt;.
Please note that at the moment I have no plans to submit this to crates.io.&lt;/p&gt;

&lt;p&gt;Feel free to contact me with any feedback, and thanks for reading!&lt;/p&gt;

&lt;div class="footnotes" role="doc-endnotes"&gt;
  &lt;ol&gt;
    &lt;li id="fn:1"&gt;
      &lt;p&gt;See its &lt;code&gt;default-https-client&lt;/code&gt; &lt;a href="https://lib.rs/crates/aws-smithy-runtime/versions"&gt;feature&lt;/a&gt; at lib.rs, you will find it throughout the AWS SDK ecosystem. &lt;a href="#fnref:1" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:4"&gt;
      &lt;p&gt;&lt;a href="https://doc.rust-lang.org/reference/items/external-blocks.html#dylib-versus-raw-dylib"&gt;https://doc.rust-lang.org/reference/items/external-blocks.html#dylib-versus-raw-dylib&lt;/a&gt; &lt;a href="#fnref:4" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:3"&gt;
      &lt;p&gt;In all cases the &lt;code&gt;-C&lt;/code&gt; flags are &lt;code&gt;debug=1&lt;/code&gt; + &lt;code&gt;codegen-units=1&lt;/code&gt; + &lt;code&gt;opt-level=s&lt;/code&gt;; see &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1916#note_3036669"&gt;this comment&lt;/a&gt; for the complete results across all platforms. &lt;a href="#fnref:3" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:2"&gt;
      &lt;p&gt;Source: &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1895"&gt;https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1895&lt;/a&gt; &lt;a href="#fnref:2" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="Development"/>
    <category term="GStreamer"/>
    <summary type="html"><![CDATA[At the GStreamer project, we produce SDKs for lots of platforms: Linux, Android, macOS, iOS, and Windows. However, as we port more and more plugins to Rust :crab:, we are finding ourselves backed into a corner.]]></summary>
  </entry>
  <entry>
    <title type="html">Wishlist for Windows installers tooling</title>
    <link href="https://www.amyspark.me/blog/posts/2025/05/29/installers.html" rel="alternate" type="text/html" title="Wishlist for Windows installers tooling"/>
    <published>2025-05-29T00:00:00+00:00</published>
    <updated>2025-05-29T00:00:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2025/05/29/installers</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2025/05/29/installers.html">&lt;p&gt;Hi all!&lt;/p&gt;

&lt;p&gt;A few months ago, I researched whether GStreamer could migrate away from WiX
&lt;a href="http://wixtoolset.org/"&gt;(the FOSS toolkit for making MSI installer packages)&lt;/a&gt; 
to any of the well known EXE based alternatives. At the time, I decided to go 
with an upgrade from the &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1555"&gt;EOL’d WiX toolset v3 to v5&lt;/a&gt;, 
but forgot to make notes as to why.&lt;/p&gt;

&lt;p&gt;However, &lt;a href="https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2199#note_2870321"&gt;an update to aws-lc-rs&lt;/a&gt; caused us to go over the 2GB limitation of cabinet files,
&lt;a href="https://download.microsoft.com/download/4/d/a/4da14f27-b4ef-4170-a6e6-5b1ef85b1baa/[ms-cab].pdf"&gt;only vaguely documented in section 2.3 of the CAB file format specification&lt;/a&gt; (also see &lt;a href="https://support.microsoft.com/en-us/topic/cab-file-that-is-exported-by-using-the-wsusutil-exe-command-is-displayed-as-0-kb-on-a-windows-server-2012-based-wsus-server-b0e99e00-3a77-6ebe-7504-c89cafc72c86"&gt;this support thread&lt;/a&gt;, 
&lt;a href=""&gt;this merge request’s comments&lt;/a&gt;, and &lt;a href="https://github.com/wixtoolset/issues/issues/7169"&gt;this WiX issue&lt;/a&gt;).
And since all of the toolkits I had researched have a similar limitation, that
drove me to better document this wishlist of sorts.&lt;/p&gt;

&lt;p&gt;(Note that the bloat caused by aws-lc-rs was itself reported &lt;a href="https://github.com/smithy-lang/smithy-rs/issues/4049"&gt;to AWS in this issue&lt;/a&gt;.)&lt;/p&gt;

&lt;h2 id="gstreamers-needs"&gt;GStreamer’s needs&lt;/h2&gt;

&lt;p&gt;A prospective implementation must support:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Package/feature dependencies&lt;/li&gt;
  &lt;li&gt;Getting and setting Registry entries&lt;/li&gt;
  &lt;li&gt;Architecture-specific &lt;code&gt;ProgramFiles&lt;/code&gt; detection and usage&lt;/li&gt;
  &lt;li&gt;Cross compilation from Linux&lt;/li&gt;
  &lt;li&gt;Both GUI and “quiet” installs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These last three items are an immediate fit towards the well-known Inno Setup
and NSIS.&lt;/p&gt;

&lt;p&gt;Extras we can also make use of include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Visual Studio detection + template installing&lt;/li&gt;
  &lt;li&gt;High compression ratio&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are already supported by WiX, but it’s worth to review the latter as Wine
does not support other than &lt;a href="https://github.com/wixtoolset/issues/issues/4381"&gt;mszip compression&lt;/a&gt;, which causes a
substantial increase in binary size.&lt;/p&gt;

&lt;h2 id="nsis"&gt;NSIS&lt;/h2&gt;

&lt;p&gt;I believe this is one of the most well-known FOSS solutions for making
installers; it certainly is one of the most simple and usable ones out there.
However, I found the following issues that make it incompatible with my needs:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Features (“sections”) are standalone, there is no way to declare their dependencies&lt;/li&gt;
  &lt;li&gt;Compression is single threaded, the best algorithm available is LZMA&lt;/li&gt;
  &lt;li&gt;Many specific functions require custom headers&lt;/li&gt;
  &lt;li&gt;No built-in ability to check for and install the MSVC Redistributable (extra, closed source plugins seem to be needed)&lt;/li&gt;
  &lt;li&gt;No Visual Studio support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The big plus is that it does not seem to have a maximum file size limitation.
It also has an up-to-date look available, but I recall having some trouble
porting our headers and logo to it.&lt;/p&gt;

&lt;p&gt;## Inno Setup&lt;/p&gt;

&lt;p&gt;This one came quite close to being the replacement for WiX, but it had a big
incompatibility:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;it does support feature dependencies, it turns them on their head: the &lt;em&gt;file&lt;/em&gt; declares which feature(s) it belongs to.
    &lt;ul&gt;
      &lt;li&gt;This means that we’d have to parse the dependency tree, list all the files and their packages, and flatten that into a list of files tagged with all packages that can reach to it&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;No built-in ability to check for and install the MSVC Redistributable (extra, closed source plugins seem to be needed) (same as NSIS)&lt;/li&gt;
  &lt;li&gt;No Visual Studio support (same as NSIS)&lt;/li&gt;
  &lt;li&gt;No support for modern, multithreaded compression (LZMA2 is the maximum but it can consume a lot of memory)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compared to NSIS, the big plus of this toolkit is their excellent help file,
which documents nearly every configuration entry available.&lt;/p&gt;

&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Even though computing has progressed a lot since the 90s, there have been
no major changes in the installer toolkits; many are still stuck with
design decisions that point to their origin in the Windows 9x/XP era.
Even Windows Installer, possibly because of their backwards compatibility
needs, is stuck with limitations that are counter intuitive in a time
where assets can easily surpass 2GB.&lt;/p&gt;

&lt;p&gt;I would like to see this fixed but I have no idea where to start, so if you
know of anyone that’s working on this, let me know!&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="Development"/>
    <summary type="html"><![CDATA[Hi all!]]></summary>
  </entry>
  <entry>
    <title type="html">Stripping Rust static libraries: symbols begone!</title>
    <link href="https://www.amyspark.me/blog/posts/2024/01/10/stripping-rust-libraries.html" rel="alternate" type="text/html" title="Stripping Rust static libraries: symbols begone!"/>
    <published>2024-01-10T12:00:00+00:00</published>
    <updated>2024-01-10T12:00:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2024/01/10/stripping-rust-libraries</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2024/01/10/stripping-rust-libraries.html">&lt;p class="alert alert-primary"&gt;This blog post was last updated on July 7, 2024 to fix the Android section.&lt;/p&gt;

&lt;p&gt;One of my first tasks with the fine folks at Centricular was to sort out a
problem we had with the distribution of Rust libraries. GStreamer’s
&lt;a href="https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs"&gt;Rust-based plugins&lt;/a&gt;
are implemented as a C ABI library through
&lt;a href="https://github.com/lu-zero/cargo-c"&gt;the cargo-c tool&lt;/a&gt;.
When the binary distribution is put together, these plugins are compiled into
dynamic libraries by default, but there are two platforms that require static
libraries: iOS and Android.
For these two platforms, a dynamic library that would weigh around 10 MB gets
replaced by a static library of ~550MB.&lt;/p&gt;

&lt;p&gt;Yes, that’s a 50x increase. There has to be a way to skip that, right?&lt;/p&gt;

&lt;p&gt;First of all, we need to identify what’s ballooning the size of the libraries.
That is really easy to identify:
&lt;a href="https://dev.to/luzero/building-crates-so-they-look-like-c-abi-libraries-1ibn#static-libraries"&gt;the author of cargo-c says&lt;/a&gt;
that all static libraries are brought in through the &lt;code&gt;pkg-config&lt;/code&gt; output;
however, since the origin language is Rust, there is one library that must
be embedded before downstream consumption: Rust’s precompiled standard library,
or stdlib for short. &lt;code&gt;-link_whole&lt;/code&gt;ing this library means that all symbols we
don’t use are coming along for the ride, as well as their debugging information.
And that’s ignoring the
&lt;a href="https://alanwu.space/post/symbol-hygiene/"&gt;ABI hygiene issues&lt;/a&gt;
that will arise when linking more than one cargo-c generated library together.&lt;/p&gt;

&lt;p&gt;So, how can this be fixed for the platforms we support?&lt;/p&gt;

&lt;h2 id="darwin"&gt;Darwin&lt;/h2&gt;

&lt;p&gt;Darwin-based platforms, like iOS, are also conceptually really simple,
though it wasn’t easy to figure it out.
Since the MachO binary format mixes “flat” symbol exports (like ELF) and strong
link-time symbol resolution (like Windows),
&lt;a href="https://www.unix.com/man-page/osx/1/strip/"&gt;&lt;code&gt;ld64&lt;/code&gt; does not allow stripping libraries
except at link-time&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote class="amy-blockquote"&gt;
  &lt;p&gt;strip no longer removes relocation entries under any condition.  Instead,
it updates the external relocation entries (and indirect symbol table
entries) to reflect the resulting symbol table.  strip prints an error
message for those symbols not in the resulting symbol table that are
needed by an external relocation entry or an indirect symbol table.  The
link editor &lt;code&gt;ld(1)&lt;/code&gt; is the only program that can strip relocation entries
and know if it is safe to do so.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Attempting to do so will either result in &lt;code&gt;strip&lt;/code&gt;’s call to &lt;code&gt;ld&lt;/code&gt; complaining
about undefined symbols, or a completely stubbed library.&lt;/p&gt;

&lt;p&gt;Is there a workaround for this? A key insight here is that &lt;a href="https://github.com/rust-lang/rust/issues/33221"&gt;the Rust stdlib
exports all symbols as global&lt;/a&gt;.
So, if we want to strip symbols, we should inject the &lt;code&gt;-exported_symbols_list&lt;/code&gt;
flag into the library linking step, right?&lt;/p&gt;

&lt;p&gt;Unfortunately, Rust does not use the linker to create the static library at all;
it archives the object files &lt;a href="https://github.com/rust-lang/rust/blob/58b4ebcdd62d82789ac50378698280006178d5fd/compiler/rustc_codegen_ssa/src/back/link.rs#L506"&gt;using its own bespoke tools&lt;/a&gt;.
Researching alternatives online, I could only find &lt;a href="https://orangejuiceliberationfront.com/hiding-symbols-in-static-libraries-with-xcode-or-cmake/"&gt;another blog post&lt;/a&gt;
that demonstrates a way to achieve this with CMake; that led me to another
little documented, but fully Apple-supported alternative to achieve the same:
&lt;a href="https://developer.apple.com/documentation/xcode/build-settings-reference"&gt;&lt;em&gt;Single-Object Prelink&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From an implementation point of view, when one enables this option,
Xcode will instead:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;link world + dog into a new object file (&lt;code&gt;ld -r&lt;/code&gt;) with all the flags
necessary, just like a dynamic library&lt;/li&gt;
  &lt;li&gt;then archive the object file using &lt;code&gt;libtool -static&lt;/code&gt; (with extra,
Xcode-specific information)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The call to &lt;code&gt;ld&lt;/code&gt; is where we can inject the list of symbols to be kept.
And we can unpack the library to get the object files. So, what was my fix for this?&lt;/p&gt;

&lt;h3 id="stripping-rust-stdlib-symbols"&gt;Stripping Rust stdlib symbols&lt;/h3&gt;

&lt;p&gt;The first step is to put together a list of all the symbols to be exported.
&lt;strong&gt;Don’t try using wildcards, it must be exhaustive!&lt;/strong&gt;
If you don’t have one at hand, you can use &lt;code&gt;nm&lt;/code&gt; to
list all the symbols, filter them as needed, and then save the result to a file:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;nm -gjPUA path_to_the_library&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Xcode’s &lt;code&gt;nm&lt;/code&gt; cannot be used for this step because it does not understand symbols
generated with LLVM 16, like Rust’s. The toolchain &lt;a href="https://internals.rust-lang.org/t/llvm-tools-a-new-rustup-component-for-binary-inspection-objdump-nm-size-and-profiling-profdata/7830"&gt;supplies an optional
component&lt;/a&gt;,
&lt;code&gt;llvm-tools-preview&lt;/code&gt;, that supplies a matching version.
To invoke the supplied tool, you can&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;find the path to &lt;code&gt;llvm-nm&lt;/code&gt; in &lt;code&gt;rustc&lt;/code&gt;’s system root folder, for instance through &lt;code&gt;find $(rustc --print sysroot) -name 'llvm-nm'&lt;/code&gt;
&lt;/li&gt;
  &lt;li&gt;install the &lt;code&gt;cargo-binutils&lt;/code&gt; crate, then replace &lt;code&gt;nm&lt;/code&gt; with  &lt;code&gt;cargo nm&lt;/code&gt; in the command above&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Second step is to extract the object files from the library:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;ar xv path_to_the_library&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Third, call up &lt;code&gt;ld&lt;/code&gt; to link all the objects along with the module
definition file (if not in a shell, replace &lt;code&gt;*.o&lt;/code&gt; with the list of all
the &lt;code&gt;.o&lt;/code&gt; files extracted in the previous step):&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;ld -r -exported_symbols_list path_to_your_definition_file -o prelinked.o *.o&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And finally, reassemble the static library with Xcode’s &lt;code&gt;libtool&lt;/code&gt; utility:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;libtool -static -o path_to_the_library prelinked.o&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With this change, I shaved almost 90% of the biggest library we have (the WebRTC
plugin), without losing debugging information:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;debug: 504 MB -&amp;gt; 93 MB&lt;/li&gt;
  &lt;li&gt;release: 144 MB -&amp;gt; 18 MB&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="linux-based-platforms"&gt;Linux based platforms&lt;/h2&gt;

&lt;p&gt;In the previous inception of this post, I claimed that this could be achieved
with just the use of &lt;code&gt;strip&lt;/code&gt; plus export symbols selection. This is not correct.
To quote myself in the &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1433"&gt;merge request fixing this&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote class="blockquote text-muted fst-italic"&gt;
  &lt;p&gt;Using strip with &lt;code&gt;--keep-symbol&lt;/code&gt; looked sensible, but the utility did not truly parse
all the symbols and constructed a dependency chain. Instead, placeholders
to the next address were generated in place of all the &lt;code&gt;.rodata&lt;/code&gt; symbols
referenced in the functions to be kept.
The result of this nightmare was crashes that looked completely
senseless, until one checked the disassembly of the functions – the
&lt;code&gt;gst_plugin_xxx_register&lt;/code&gt; function was there, but neither the call nor
the parameters referenced anywhere valid in the data sections.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Linux-based platforms, such as Android, can instead also make use of
Single-Object Prelink, which in this OS is called
&lt;a href="https://maskray.me/blog/2022-11-21-relocatable-linking"&gt;“partial linking” or “relocatable linking”&lt;/a&gt;.
The key difference with regards to macOS is that while the symbol stripping is
performed by &lt;code&gt;ld&lt;/code&gt;, symbol visibility (to hide the remains of the Rust stdlib)
can only be changed with a separate call to &lt;code&gt;objcopy&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;ar xv path_to_the_library
ld --relocatable --export-dynamic-symbol=gst_plugin_* -o prelinked.o *.o
objcopy --wildcard --keep-global-symbol=gst_plugin_* prelinked.o
ar rs path_to_the_library prelinked.o&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="windows"&gt;Windows&lt;/h2&gt;

&lt;p&gt;We also looked into enabling these improvements for Microsoft’s platforms.
However, neither MSVC nor MinGW-w64 provide tools that allow tinkering
with static libraries in the ways we need above.&lt;/p&gt;

&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;We managed to shave off between 50% and 90% off our static libraries by
stripping all unused bits of the Rust stdlib. This was possible on both
macOS and Linux with reasonably up-to-date tools, but to the best of my
knowledge, it’s not yet possible for the Windows ABI.&lt;/p&gt;

&lt;p&gt;For a future piece, we’d love to fully deduplicate the stdlib from the
individual plugins. Having a way to supply it externally would
remove the need for tinkering with the object files.
This was filed &lt;a href="https://github.com/rust-lang/rust/issues/111594"&gt;as issue #111594 in the Rust repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please head over to &lt;a href="https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1255"&gt;the GStreamer repo&lt;/a&gt;
to have a look at the gory details, and let me know if you have any questions!&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="Development"/>
    <category term="GStreamer"/>
    <summary type="html"><![CDATA[This blog post was last updated on July 7, 2024 to fix the Android section.]]></summary>
  </entry>
  <entry>
    <title type="html">Why Performance Improvements are Good</title>
    <link href="https://www.amyspark.me/blog/posts/2023/07/22/why-performance-improvements-are-good.html" rel="alternate" type="text/html" title="Why Performance Improvements are Good"/>
    <published>2023-07-22T13:15:00+00:00</published>
    <updated>2023-07-22T13:15:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2023/07/22/why-performance-improvements-are-good</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2023/07/22/why-performance-improvements-are-good.html">&lt;figure class="figure d-block text-center"&gt;
&lt;div class="ratio ratio-16x9 mb-3"&gt;
&lt;iframe sandbox="allow-same-origin allow-scripts allow-popups" src="https://www.youtube-nocookie.com/embed/x2EOOJg8FkA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;/figure&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="Development"/>
    <category term="Planet KDE"/>
    <summary type="html"><![CDATA[]]></summary>
  </entry>
  <entry>
    <title type="html">Notes on packaging Krita with G’MIC</title>
    <link href="https://www.amyspark.me/blog/posts/2022/01/18/notes-on-packaging-krita-with-gmic.html" rel="alternate" type="text/html" title="Notes on packaging Krita with G’MIC"/>
    <published>2022-01-18T13:15:00+00:00</published>
    <updated>2022-01-18T13:15:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2022/01/18/notes-on-packaging-krita-with-gmic</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2022/01/18/notes-on-packaging-krita-with-gmic.html">&lt;p&gt;Krita 3 and later are compatible with G’MIC, an open-source digital
image processing framework. This support is provided by G’MIC-Qt, a
Qt-based frontend for G’MIC. Since its inception, G’MIC-Qt was shipped
as a standalone, externally built executable that is an optional,
runtime dependency of Krita.&lt;/p&gt;

&lt;p&gt;Krita 5 changes the way G’MIC-Qt is consumed. In order to support CentOS
and macOS, G’MIC-Qt has been converted into a dynamically loadable
library that is a dependent of Krita.&lt;/p&gt;

&lt;p&gt;This file reviews these changes, and how to package Krita accordingly.&lt;/p&gt;

&lt;h2 id="rationale"&gt;Rationale&lt;/h2&gt;

&lt;p&gt;We have chosen to ship G’MIC-Qt as a library because of two longstanding
bugs.&lt;/p&gt;

&lt;p&gt;The Krita host for G’MIC-Qt relies on &lt;code&gt;QSharedMemory&lt;/code&gt;, i.e. a shared
memory segment, on wich a pipe is instantiated to pass messages to and
from the host app. Firstly, this approach made opening two simultaneous
G’MIC-Qt instances (each paired to its own Krita instance) impossible
&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;. Secondly, it also forbade using G’MIC-Qt with Krita on CentOS, as
well as macOS, because the former doesn’t support &lt;code&gt;QSharedMemory&lt;/code&gt; &lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote" rel="footnote" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;,
and the latter has a meager 4KB as the maximum shared segment size.
While there’s no workaround (to our knowledge) in CentOS, the only
workaround for macOS is to manipulate the maximum segment size via
&lt;code&gt;sysctl&lt;/code&gt; &lt;sup id="fnref:3"&gt;&lt;a href="#fn:3" class="footnote" rel="footnote" role="doc-noteref"&gt;3&lt;/a&gt;&lt;/sup&gt;, which was already difficult pre-Mojave &lt;sup id="fnref:4"&gt;&lt;a href="#fn:4" class="footnote" rel="footnote" role="doc-noteref"&gt;4&lt;/a&gt;&lt;/sup&gt; and now, due
to the significant security measures of recent macOS versions, is
nothing short of a sysadmin task &lt;sup id="fnref:5"&gt;&lt;a href="#fn:5" class="footnote" rel="footnote" role="doc-noteref"&gt;5&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;There were two approaches. One was to move to a &lt;code&gt;mmap&lt;/code&gt;-d file, which is
unpredictable to sync due to each canvas’s differing space requirements.
The easiest, and the one we chose, was to move to a tighter coupled
memory model– a dynamically loadable plugin, as shown in my proposal PR
&lt;sup id="fnref:6"&gt;&lt;a href="#fn:6" class="footnote" rel="footnote" role="doc-noteref"&gt;6&lt;/a&gt;&lt;/sup&gt;. This was rejected by the G’MIC developers because of the
possibility of crashing the host app due to a G’MIC internal bug
&lt;sup id="fnref:7"&gt;&lt;a href="#fn:7" class="footnote" rel="footnote" role="doc-noteref"&gt;7&lt;/a&gt;&lt;/sup&gt;&lt;sup id="fnref:8"&gt;&lt;a href="#fn:8" class="footnote" rel="footnote" role="doc-noteref"&gt;8&lt;/a&gt;&lt;/sup&gt;. This decision was later enacted as part of G’MIC contributing
policies &lt;sup id="fnref:9"&gt;&lt;a href="#fn:9" class="footnote" rel="footnote" role="doc-noteref"&gt;9&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h2 id="how-did-you-fix-it"&gt;How did you fix it?&lt;/h2&gt;

&lt;p&gt;Due to the above, the only path forward was to fork G’MIC, which we did
in Krita MR !581 &lt;sup id="fnref:10"&gt;&lt;a href="#fn:10" class="footnote" rel="footnote" role="doc-noteref"&gt;10&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;From a source code point of view, our fork is based on top of the latest
version’s tarball. Each tarball’s contents are committed to the &lt;code&gt;main&lt;/code&gt;
branch of the &lt;code&gt;amyspark/gmic&lt;/code&gt; GitHub repository &lt;sup id="fnref:11"&gt;&lt;a href="#fn:11" class="footnote" rel="footnote" role="doc-noteref"&gt;11&lt;/a&gt;&lt;/sup&gt;. For every covered
release, there is a branch that in turn overlays our own plugin
implementation, along with additional fixes that ensure that G’MIC-Qt
doesn’t attempt to overwrite the internal state of the host application;
namely, &lt;code&gt;QCoreApplication&lt;/code&gt; settings, widget styles, and the installed
translators.&lt;/p&gt;

&lt;p&gt;From a technical point of view, this library interfaces with Krita
through a new, purpose specific library, &lt;code&gt;kisqmicinterface&lt;/code&gt;. This
library contains nothing more than the previous iteration of the
communications system, but now exported through namesake APIs &lt;sup id="fnref:12"&gt;&lt;a href="#fn:12" class="footnote" rel="footnote" role="doc-noteref"&gt;12&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;In short, we have reversed the dependency flow; while in Krita v4 and
earlier G’MIC-Qt was a runtime dependency, in v5, it’s G’MIC-Qt that
depends on Krita as a build &lt;em&gt;and&lt;/em&gt; runtime dependency.&lt;/p&gt;

&lt;h2 id="getting-the-source-code"&gt;Getting the source code&lt;/h2&gt;

&lt;p&gt;The patched version’s tarballs are GPG signed and available at the
Releases section of the GitHub repository &lt;sup id="fnref:13"&gt;&lt;a href="#fn:13" class="footnote" rel="footnote" role="doc-noteref"&gt;13&lt;/a&gt;&lt;/sup&gt;. Alternatively, the
tarballs (though not the signatures) are also mirrored at our
dependencies stash at files.kde.org &lt;sup id="fnref:14"&gt;&lt;a href="#fn:14" class="footnote" rel="footnote" role="doc-noteref"&gt;14&lt;/a&gt;&lt;/sup&gt;. The tarballs are signed with
the GPG key which is available at my GitHub profile. Its fingerprint is
&lt;code&gt;4894424D2412FEE5176732A3FC00108CFD9DBF1E&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id="building-kritas-gmic-qt-library"&gt;Building Krita’s G’MIC-Qt library&lt;/h2&gt;

&lt;p&gt;After building Krita with your standard process, the CMake install
process should have put &lt;code&gt;kisqmicinterface.so&lt;/code&gt; in your &lt;code&gt;lib&lt;/code&gt; folder:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[2022-01-09T16:21:32.589Z] -- Installing: /home/appimage/appimage-workspace/krita.appdir/usr/lib/x86_64-linux-gnu/libkritaqmicinterface.so.18.0.0
[2022-01-09T16:21:32.589Z] -- Installing: /home/appimage/appimage-workspace/krita.appdir/usr/lib/x86_64-linux-gnu/libkritaqmicinterface.so.18
[2022-01-09T16:21:32.589Z] -- Set runtime path of "/home/appimage/appimage-workspace/krita.appdir/usr/lib/x86_64-linux-gnu/libkritaqmicinterface.so.18.0.0" to "/home/appimage/appimage-workspace/krita.appdir/usr/lib/x86_64-linux-gnu:/home/appimage/appimage-workspace/deps/usr/lib:/home/appimage/appimage-workspace/deps/usr/lib/x86_64-linux-gnu"
[2022-01-09T16:21:32.589Z] -- Installing: /home/appimage/appimage-workspace/krita.appdir/usr/lib/x86_64-linux-gnu/libkritaqmicinterface.so
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It should also install these headers, as illustrated below:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
&lt;code&gt;kis_qmic_plugin_interface.h&lt;/code&gt; exports a G’MIC-alike &lt;code&gt;launch&lt;/code&gt; entry
point that the plugin will implement&lt;/li&gt;
  &lt;li&gt;
&lt;code&gt;kis_qmic_interface.h&lt;/code&gt; implements the G’MIC request-response APIs&lt;/li&gt;
  &lt;li&gt;
&lt;code&gt;kritaqmicinterface_export.h&lt;/code&gt; is the CMake auto-generated export
decoration header&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- --&gt;

&lt;pre&gt;&lt;code&gt;[2022-01-09T16:21:32.589Z] -- Installing: /home/appimage/appimage-workspace/krita.appdir/usr/include/kis_qmic_interface.h
[2022-01-09T16:21:32.589Z] -- Installing: /home/appimage/appimage-workspace/krita.appdir/usr/include/kis_qmic_plugin_interface.h
[2022-01-09T16:21:32.589Z] -- Installing: /home/appimage/appimage-workspace/krita.appdir/usr/include/kritaqmicinterface_export.h
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The three headers, along with the &lt;code&gt;libkritaqmicinterface.a&lt;/code&gt; archive
library (if building for Windows under MinGW), comprise a
&lt;code&gt;krita-gmic-dev&lt;/code&gt; package that’ll be a build dependency of the new
G’MIC-Qt plugin. Please note that &lt;code&gt;libkritaqmicinterface.so&lt;/code&gt; is consumed
by Krita and MUST NOT be placed inside this dev package.&lt;/p&gt;

&lt;p&gt;Now, download the G’MIC-Qt tarball from one of the sources listed
previously, and unpack it to an isolated directory. Then, you can build
it with these lines (adjust them as described):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mkdir build
cmake -S ./gmic-$&amp;lt;the tarball's G'MIC version&amp;gt;-patched/gmic-qt \
      -B ./build \
      -DCMAKE_PREFIX_PATH=$&amp;lt;installation prefix of krita-gmic-dev&amp;gt; \
      -DCMAKE_INSTALL_PREFIX=$&amp;lt;installation prefix of krita itself&amp;gt; \ 
      -DENABLE_SYSTEM_GMIC=$&amp;lt;false if you don't want to use your system's G'MIC&amp;gt; \
      -DGMIC_QT_HOST=krita-plugin
cmake --build . --config $&amp;lt;your desired build type&amp;gt; --target install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The changes from a standard G’MIC build are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the new &lt;code&gt;GMIC_QT_HOST&lt;/code&gt; value, &lt;code&gt;krita-plugin&lt;/code&gt;
&lt;/li&gt;
  &lt;li&gt;the requirement for the &lt;code&gt;krita-gmic-dev&lt;/code&gt; package to be available in
&lt;code&gt;CMAKE_PREFIX_PATH&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This process is illustrated in any of our official build scripts for
Windows &lt;sup id="fnref:15"&gt;&lt;a href="#fn:15" class="footnote" rel="footnote" role="doc-noteref"&gt;15&lt;/a&gt;&lt;/sup&gt; and for macOS/Linux &lt;sup id="fnref:16"&gt;&lt;a href="#fn:16" class="footnote" rel="footnote" role="doc-noteref"&gt;16&lt;/a&gt;&lt;/sup&gt;. You can also check the
&lt;code&gt;3rdparty_plugins&lt;/code&gt; section of our source tree &lt;sup id="fnref:17"&gt;&lt;a href="#fn:17" class="footnote" rel="footnote" role="doc-noteref"&gt;17&lt;/a&gt;&lt;/sup&gt; to see what other
hardening we apply to the build.&lt;/p&gt;

&lt;hr&gt;

&lt;div class="footnotes" role="doc-endnotes"&gt;
  &lt;ol&gt;
    &lt;li id="fn:1"&gt;
      &lt;p&gt;Bug #44 on c-koi/gmic-qt: “CentOS7: Krita 4.0.4 + gmic_krita_qt
2.3.0/2.2.3 - QSharedMemory::attach”.
&lt;a href="https://github.com/c-koi/gmic-qt/issues/44"&gt;https://github.com/c-koi/gmic-qt/issues/44&lt;/a&gt; &lt;a href="#fnref:1" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:2"&gt;
      &lt;p&gt;Bug 424514 on krita: “Guaranteed crash when opening 2 G’MIC-qt”.
&lt;a href="https://bugs.kde.org/show_bug.cgi?id=424514"&gt;https://bugs.kde.org/show_bug.cgi?id=424514&lt;/a&gt; &lt;a href="#fnref:2" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:3"&gt;
      &lt;p&gt;&lt;a href="https://www.ssec.wisc.edu/mcidas/doc/users_guide/2017.1/SharedMemory.html"&gt;https://www.ssec.wisc.edu/mcidas/doc/users_guide/2017.1/SharedMemory.html&lt;/a&gt; &lt;a href="#fnref:3" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:4"&gt;
      &lt;p&gt;e.g. &lt;a href="https://stackoverflow.com/questions/2017004/setting-shmmax-etc-values-on-mac-os-x-10-6-for-postgresql"&gt;https://stackoverflow.com/questions/2017004/setting-shmmax-etc-values-on-mac-os-x-10-6-for-postgresql&lt;/a&gt; &lt;a href="#fnref:4" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:5"&gt;
      &lt;p&gt;See &lt;a href="https://developer.apple.com/forums/thread/669625"&gt;https://developer.apple.com/forums/thread/669625&lt;/a&gt; for an
approach applicable after &lt;code&gt;com.apple.rootless&lt;/code&gt; was fully enforced. &lt;a href="#fnref:5" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:6"&gt;
      &lt;p&gt;&lt;a href="https://github.com/c-koi/gmic-qt/pull/102"&gt;https://github.com/c-koi/gmic-qt/pull/102&lt;/a&gt; &lt;a href="#fnref:6" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:7"&gt;
      &lt;p&gt;&lt;a href="https://github.com/c-koi/gmic-qt/pull/102"&gt;https://github.com/c-koi/gmic-qt/pull/102&lt;/a&gt; &lt;a href="#fnref:7" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:8"&gt;
      &lt;p&gt;Note that this was already possible, simply by crashing G’MIC the
host app would deadlock, waiting forever for a response. &lt;a href="#fnref:8" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:9"&gt;
      &lt;p&gt;&lt;a href="https://github.com/c-koi/gmic-qt/blob/master/NEW_HOST_HOWTO.md"&gt;https://github.com/c-koi/gmic-qt/blob/master/NEW_HOST_HOWTO.md&lt;/a&gt; &lt;a href="#fnref:9" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:10"&gt;
      &lt;p&gt;&lt;a href="https://invent.kde.org/graphics/krita/-/merge_requests/581"&gt;https://invent.kde.org/graphics/krita/-/merge_requests/581&lt;/a&gt; &lt;a href="#fnref:10" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:11"&gt;
      &lt;p&gt;&lt;a href="https://github.com/amyspark/gmic"&gt;https://github.com/amyspark/gmic&lt;/a&gt; &lt;a href="#fnref:11" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:12"&gt;
      &lt;p&gt;An older version of what’s
&lt;a href="https://github.com/c-koi/gmic-qt/blob/master/src/Host/GmicQtHost.h"&gt;https://github.com/c-koi/gmic-qt/blob/master/src/Host/GmicQtHost.h&lt;/a&gt;
nowadays. &lt;a href="#fnref:12" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:13"&gt;
      &lt;p&gt;&lt;a href="https://github.com/amyspark/gmic/releases"&gt;https://github.com/amyspark/gmic/releases&lt;/a&gt; &lt;a href="#fnref:13" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:14"&gt;
      &lt;p&gt;&lt;a href="https://files.kde.org/krita/build/dependencies/"&gt;https://files.kde.org/krita/build/dependencies/&lt;/a&gt; &lt;a href="#fnref:14" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:15"&gt;
      &lt;p&gt;&lt;a href="https://invent.kde.org/graphics/krita/-/tree/master/build-tools/windows"&gt;https://invent.kde.org/graphics/krita/-/tree/master/build-tools/windows&lt;/a&gt; &lt;a href="#fnref:15" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:16"&gt;
      &lt;p&gt;&lt;a href="https://invent.kde.org/graphics/krita/-/blob/master/packaging"&gt;https://invent.kde.org/graphics/krita/-/blob/master/packaging&lt;/a&gt; &lt;a href="#fnref:16" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id="fn:17"&gt;
      &lt;p&gt;&lt;a href="https://invent.kde.org/graphics/krita/-/tree/master/3rdparty_plugins"&gt;https://invent.kde.org/graphics/krita/-/tree/master/3rdparty_plugins&lt;/a&gt; &lt;a href="#fnref:17" class="reversefootnote" role="doc-backlink"&gt;↩&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="Development"/>
    <category term="Planet KDE"/>
    <summary type="html"><![CDATA[Krita 3 and later are compatible with G’MIC, an open-source digital image processing framework. This support is provided by G’MIC-Qt, a Qt-based frontend for G’MIC. Since its inception, G’MIC-Qt was shipped as a standalone, externally built executable that is an optional, runtime dependency of Krita.]]></summary>
  </entry>
  <entry>
    <title type="html">Reading and writing a Photoshop TIFF</title>
    <link href="https://www.amyspark.me/blog/posts/2021/11/14/reading-and-writing-tiff-psds.html" rel="alternate" type="text/html" title="Reading and writing a Photoshop TIFF"/>
    <published>2021-11-14T12:00:00+00:00</published>
    <updated>2021-11-14T12:00:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2021/11/14/reading-and-writing-tiff-psds</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2021/11/14/reading-and-writing-tiff-psds.html">&lt;p&gt;This blog post draws on my experience adding reading and writing support for
our app, and is intended to clarify the ambiguities in the official standard.&lt;/p&gt;

&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Adobe Photoshop provides two ways to save layers: its proprietary PSD/PSB
format, widely supported in imaging applications, and inside TIFF containers.
The latter is not well supported; as detailed &lt;a href="http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/2020-August/002182.html"&gt;in an email to the OpenColorIO mailing list&lt;/a&gt;,
the PSD standard is too vague and imprecise to be an useful reference in writing
support for these files.
Indeed, as of the writing of this post, only ImageMagick (&lt;a href="https://github.com/ImageMagick/ImageMagick/commit/14c08dcd1910ecd8360f51d13885b2c9c39b655d#diff-0a5eef63b187504ff513056aa8fd6a7f5c1f57b6d2577a75cff428c0c7530978R947"&gt;commit&lt;/a&gt;, &lt;a href="https://github.com/ImageMagick/ImageMagick/commit/87038d5d4cc04fb99d6560ae95f3f07a87563323#diff-0a5eef63b187504ff513056aa8fd6a7f5c1f57b6d2577a75cff428c0c7530978"&gt;commit&lt;/a&gt;) provides any
sort of support for this variant.&lt;/p&gt;

&lt;p&gt;As of today, the official documentation on Photoshop TIFFs is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;page 11 of the “Adobe Photoshop® TIFF Technical Notes”
available &lt;a href="https://www.adobe.io/open/standards/TIFF.html"&gt;on the Adobe Open Standards page&lt;/a&gt;
&lt;/li&gt;
  &lt;li&gt;section “Photoshop-specific TIFF Tags” in the “Adobe Photoshop File Formats Specification” of November 2019, available &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1039502"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, Photoshop layers are stored in tag or field &lt;code&gt;37724&lt;/code&gt;, identified as
&lt;code&gt;TIFFTAG_IMAGESOURCEDATA&lt;/code&gt; in the latest libtiff. The type of this tag shall be
&lt;code&gt;UNDEFINED&lt;/code&gt;, or &lt;code&gt;TIFF_UNDEFINED&lt;/code&gt; in libtiff. The data blob shall be an array of
&lt;code&gt;uint8_t&lt;/code&gt;, and shall be headed by a magic signature that is one of the following
null terminated ASCII strings:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;for standard Photoshop files, &lt;code&gt;Adobe Photoshop Document Data Block&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;for Large Document Format (8BPB/PSB) files, &lt;code&gt;Adobe Photoshop Document Data V0002&lt;/code&gt; (the last five characters differ).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the magic signature, the remainder of the blob is comprised of a series of
&lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_pgfId-1049436"&gt;Additional Layer Information blocks&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;signature: &lt;code&gt;8BIM&lt;/code&gt; (4 bytes)&lt;/li&gt;
  &lt;li&gt;block type (4 bytes)&lt;/li&gt;
  &lt;li&gt;length of the block (4 bytes, variable, padded to a 4-byte offset)&lt;/li&gt;
  &lt;li&gt;data of the block (length as above)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Technical Notes say that these are the available block types:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
&lt;code&gt;Layr&lt;/code&gt; (layer block)&lt;/li&gt;
  &lt;li&gt;
&lt;code&gt;LMsk&lt;/code&gt; (global mask info block)&lt;/li&gt;
  &lt;li&gt;
&lt;code&gt;Patt&lt;/code&gt; (pattern definition block)&lt;/li&gt;
  &lt;li&gt;
&lt;code&gt;Anno&lt;/code&gt; (annotations)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a second useful tag, &lt;code&gt;34377&lt;/code&gt;, also known as &lt;code&gt;TIFFTAG_PHOTOSHOP&lt;/code&gt;.
The type of this tag shall be &lt;code&gt;BYTE&lt;/code&gt; (&lt;code&gt;TIFF_BYTE&lt;/code&gt;).
This is the TIFF equivalent of &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_69883"&gt;Photoshop’s image resource section&lt;/a&gt;;
its contents must not be prepended by the length field, as it is
already provided for by the TIFF container.&lt;/p&gt;

&lt;h2 id="supporting-photoshop-tiffs"&gt;Supporting Photoshop TIFFs&lt;/h2&gt;

&lt;p class="alert alert-warning"&gt;&lt;strong&gt;Warning&lt;/strong&gt;: The author has not seen a TIFF PSB (Photoshop Large Document 
Format) in the wild. A prospective developer should read the Standard and apply 
the PSB remarks accordingly in each paragraph.&lt;/p&gt;

&lt;p&gt;The Photoshop standard says of its native file format:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;All data is stored in big endian byte order. On the Windows platform, you must byte swap short and long integers when reading or writing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The situation is more complex in Photoshop TIFF files. &lt;code&gt;TIFFTAG_PHOTOSHOP&lt;/code&gt;
data must be stored in big endian order. On the other hand,
&lt;code&gt;TIFFTAG_IMAGESOURCEDATA&lt;/code&gt; data must be stored in the endianness of its
container. In practice, this means that existing PSD I/O routines can be reused,
provided the developer byte-swaps integer and block type reading routines when 
interacting with a little-endian data source.&lt;/p&gt;

&lt;p&gt;As an example, suppose a little-endian TIFF file, whose &lt;code&gt;TIFFTAG_IMAGESOURCEDATA&lt;/code&gt;
data blob starts at address &lt;code&gt;000371e8&lt;/code&gt;. Its format is PSD, and the first block is
a &lt;code&gt;Layr&lt;/code&gt; block of size 11463. Thus, the first 48 bytes of the data blob shall
match the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-console" data-lang="console"&gt;$ xxd -s +225768 -l 48 1.tif
000371e8: 4164 6f62 6520 5068 6f74 6f73 686f 7020  Adobe Photoshop
000371f8: 446f 6375 6d65 6e74 2044 6174 6120 426c  Document Data Bl
00037208: 6f63 6b00 4d49 4238 7279 614c c72c 0000  ock.MIB8ryaL.,..&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Do notice:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the null terminated magic signature &lt;code&gt;Adobe Photoshop Document Data block&lt;/code&gt;
&lt;/li&gt;
  &lt;li&gt;the &lt;code&gt;MIB8&lt;/code&gt; magic block signature, signaling both little endian and the start of a new info block&lt;/li&gt;
  &lt;li&gt;the &lt;code&gt;ryaL&lt;/code&gt; block type, which is &lt;code&gt;Layr&lt;/code&gt; in big endian and thus means a layer info block&lt;/li&gt;
  &lt;li&gt;the &lt;code&gt;c72c0000&lt;/code&gt;, &lt;code&gt;00002cc7&lt;/code&gt; in big endian, and thus 11463.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A valid Photoshop TIFF file must have a layer info block as a minimum.
Its contents are described in &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_16000"&gt;Layer info&lt;/a&gt;.
The type of this block shall be &lt;code&gt;Layr&lt;/code&gt;, or one of the following (see &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_21849"&gt;Layer and mask information section&lt;/a&gt;):&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
&lt;code&gt;Layr&lt;/code&gt; or &lt;code&gt;Lr16&lt;/code&gt; interchangeably, for 8-bit and 16-bit depth;&lt;/li&gt;
  &lt;li&gt;
&lt;code&gt;Lr32&lt;/code&gt; for 32-bit layers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Irrespective of the compression type, the raw &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_26431"&gt;channel image data&lt;/a&gt; in
Photoshop TIFF files must be in big endian order. Prospective applications shall
byteswap the channel values prior to compression and after decompression, where
applicable.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Lyid&lt;/code&gt; block is optional; if it is present, its value should be the position 
of the layer in a depth-first, left-right traversal of the layer tree.&lt;/p&gt;

&lt;h2 id="additional-info-blocks"&gt;Additional info blocks&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;LMsk&lt;/code&gt; info block is described in &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_17115"&gt;Global layer mask info&lt;/a&gt;.
It is optional; however, if it is present, its length shall not be 0. The overlay color space ID shall be one of the values described in &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577411_22664"&gt;Color space IDs&lt;/a&gt;, and the color components shall be the corresponding Pure color value. The opacity value shall be 50 and the kind 128.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Patt&lt;/code&gt; block is optional; if it is present, the image data in the &lt;a href="https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#VirtualMemoryArrayList"&gt;virtual memory array list&lt;/a&gt;
must be in big endian order. Prospective applications shall
byteswap the channel values prior to compression and after decompression, where
applicable.&lt;/p&gt;

&lt;p&gt;Adobe Photoshop, as of CC 2021, also outputs additional blocks. All of them are 
optional:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;FMsk&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;cinf&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Unlike its native and more widespread sibling, Photoshop TIFFs are a relatively obscure way yet portable way of exporting
Photoshop layers. These are stored in the byte order of its container, except for the channel data in both layer and pattern 
blocks, which are stored in big endian order.
A prospective developer should, given an existing suite of I/O primitives for the PSD format, be able to add support for
TIFF containers with relative ease by: byteswapping all integers and block types; and ensuring channel data is always compressed 
and/or stored in big endian.&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="Development"/>
    <summary type="html"><![CDATA[This blog post draws on my experience adding reading and writing support for our app, and is intended to clarify the ambiguities in the official standard.]]></summary>
  </entry>
  <entry>
    <title type="html">SeExpr status update!</title>
    <link href="https://www.amyspark.me/blog/posts/2020/08/11/status-report-seexpr.html" rel="alternate" type="text/html" title="SeExpr status update!"/>
    <published>2020-08-11T14:10:00+00:00</published>
    <updated>2020-08-11T14:10:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2020/08/11/status-report-seexpr</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2020/08/11/status-report-seexpr.html">&lt;p&gt;Hey all!&lt;/p&gt;

&lt;p&gt;It’s been quite a while since my last post. Exams for my teaching certification 
have not gone as expected – had to pull out after being flattened in quite a critical one…&lt;/p&gt;

&lt;p&gt;Buuuut! I am glad to announce that the SeExpr documentation is &lt;a href="https://docs.krita.org/en/tutorials/seexpr.html"&gt;now available&lt;/a&gt; in the Krita manual!&lt;/p&gt;

&lt;hr&gt;

&lt;figure class="figure d-block text-center"&gt;
    &lt;img class="figure-img img-fluid round w-75" src="/assets/posts/2020/08/docs-krita-org.jpg"&gt;
    &lt;figcaption class="figure-caption"&gt;
        The SeExpr tutorial, available now.
    &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Along with this tutorial, you will find:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href="https://docs.krita.org/en/reference_manual/seexpr.html#seexpr"&gt;Disney’s Quick Reference, fully ported and adapted to our application&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="https://docs.krita.org/en/reference_manual/layers_and_masks/fill_layer_generators/seexpr.html#seexpr-fill-layer"&gt;How to manage SeExpr-based Fill Layers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="https://docs.krita.org/en/reference_manual/resource_management/seexpr_scripts.html#resource-seexpr-scripts"&gt;A guide to create, bundle, and share script presets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, the most important, &lt;a href="https://krita-artists.org/t/procedural-texture-generator-example-and-wishes/7638/"&gt;a great set of examples&lt;/a&gt;
is now packed along with every Krita build for you to test and play with.&lt;/p&gt;

&lt;p&gt;I am planning additional code-wise goals, but none fits within the two weeks 
remaining for the program… so, I’ll use the remaining two weeks for something 
project-related. I’m glad to announce that I’ll be taking part in this year’s 
Akademy– not only as part of the Student Showcase, but with &lt;a href="https://conf.kde.org/en/akademy2020/public/events/226"&gt;a talk of my own&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;The talk is entitled “Integrating Hollywood Open Source with KDE Applications”,
and in it I’ll tell you about the itty-gritty bits of this journey. More formally,&lt;/p&gt;

&lt;blockquote class="blockquote text-muted fst-italic"&gt;
  &lt;p&gt;In this presentation, I will guide the audience through the pitfalls and challenges of integrating this library with the Krita codebase. Developers in the audience will be interested in learning how SeExpr’s build system, platform support, and dependencies were harmonized with Krita’s. The creation of its layer generator, and formal specification of its storage requirements, will also be addressed. Artists will be interested in how SeExpr’s UI and UX was adapted to suit their current workflow, as well as KDE’s accessibility and internationalization requirements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The talk is scheduled for September 5 at 19:30 GMT.&lt;/p&gt;

&lt;p&gt;Thank you all for supporting me, and see you at Akademy!&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;

&lt;p&gt;~amyspark &lt;span class="emoji" aria-label=":sparkles_nonconforming:" role="img"&gt;&lt;img aria-hidden="true" alt=":sparkles_nonconforming:" title=":sparkles_nonconforming:" style="width: 1em; height: 1em;" src="/assets/static/emoji/sparkles/sparkles_nonconforming.png"&gt;&lt;/span&gt;&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="[&quot;Planet KDE&quot;, &quot;GSoC&quot;]"/>
    <summary type="html"><![CDATA[Hey all! It’s been quite a while since my last post. Exams for my teaching certification have not gone as expected – had to pull out after being flattened in quite a critical one… Buuuut! I am glad to announce that the SeExpr documentation is now available in the Krita manual!]]></summary>
  </entry>
  <entry>
    <title type="html">Status update: merged!</title>
    <link href="https://www.amyspark.me/blog/posts/2020/07/27/status-update-merged.html" rel="alternate" type="text/html" title="Status update: merged!"/>
    <published>2020-07-27T15:00:00+00:00</published>
    <updated>2020-07-27T15:00:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2020/07/27/status-update-merged</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2020/07/27/status-update-merged.html">&lt;p&gt;Hey all!&lt;/p&gt;

&lt;p&gt;I’m glad to announce that &lt;a href="https://krita.org/en/item/presenting-our-google-summer-of-code-students/"&gt;my GSoC 2020 project&lt;/a&gt; has been &lt;a href="https://invent.kde.org/graphics/krita/-/commit/510f039cc676dfe69d44a5bc2d8144cf9a0874a4"&gt;mer&lt;/a&gt;&lt;a href="https://invent.kde.org/graphics/krita/-/commit/24f5bf41b2e575ca82d323665acd94fcbe558466"&gt;ged&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;You should be able to use &lt;a href="/blog/posts/2020/05/19/what-is-seexpr-about.html"&gt;Disney’s SeExpr&lt;/a&gt; for fun and profit as soon as the next nightly.&lt;/p&gt;

&lt;p&gt;The next objective is getting the docs in shape – see &lt;a href="https://invent.kde.org/documentation/docs-krita-org/-/merge_requests/145"&gt;this merge request&lt;/a&gt; for more information; and, of course, we still need your help for &lt;a href="https://krita-artists.org/t/procedural-texture-generator-example-and-wishes/7638/"&gt;a good batch of scripts&lt;/a&gt; to bundle with!&lt;/p&gt;

&lt;p&gt;Thank you all for helping out!&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="[&quot;Planet KDE&quot;, &quot;GSoC&quot;]"/>
    <summary type="html"><![CDATA[Hey all! I’m glad to announce that my GSoC 2020 project has been merged! You should be able to use Disney’s SeExpr for fun and profit as soon as the next nightly. The next objective is getting the docs in shape – see this merge request for more information; and, of course, we still need your help for a good batch of scripts to bundle with! Thank you all for helping out!]]></summary>
  </entry>
  <entry>
    <title type="html">Compiling Krita for ARM: an AppImage tale</title>
    <link href="https://www.amyspark.me/blog/posts/2020/07/15/compiling-krita-for-arm.html" rel="alternate" type="text/html" title="Compiling Krita for ARM: an AppImage tale"/>
    <published>2020-07-15T14:15:00+00:00</published>
    <updated>2020-07-15T14:15:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2020/07/15/compiling-krita-for-arm</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2020/07/15/compiling-krita-for-arm.html">&lt;figure class="text-center figure"&gt;
  &lt;img class="figure-img img-fluid" src="/assets/posts/2020/07/2020-07-14-102922_1920x1080_scrot.jpg"&gt;
  &lt;figcaption class="figure-caption"&gt;
    The AppImage running on a Raspberry Pi 3B+. It's slow, but it works &lt;span class="emoji" aria-label=":smile:" role="img"&gt;😄&lt;/span&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Someone on &lt;code&gt;#krita&lt;/code&gt;, can’t remember their exact nick, asked if it was possible 
to run Krita on ARM-based computers, specifically the Raspberry Pi 3B+.
AFAIK, no one has tried to do so, so I will tell you: yes, it &lt;strong&gt;is&lt;/strong&gt; possible! 
(Although it will run as slow as a turtle!) This work took me the whole 
weekend, but it was an excellent experience as well as a wonderful way to test 
our infrastructure.&lt;/p&gt;

&lt;p&gt;A key warning before moving on: DO NOT TRY THIS ON YOUR PI. It will be 
unbearably slow &lt;span class="emoji" aria-label=":smile:" role="img"&gt;😄&lt;/span&gt; I built mine with a Ryzen 7 with 12 threads and it
still took me two 12-hour shifts!&lt;/p&gt;

&lt;p&gt;This post covers three steps: setting up the build environment, compiling the 
dependencies and Krita itself, and finally packaging the AppImages themselves.
As per &lt;a href="https://github.com/probonopd/linuxdeployqt#a-note-on-binary-compatibility"&gt;the official instructions&lt;/a&gt;, we’ll target Ubuntu 16.04 ARM.
I chose the &lt;code&gt;armhf&lt;/code&gt; port to match the Raspberry Pi’s default distro, Raspbian.
I also tested &lt;code&gt;aarch64&lt;/code&gt; – see the last section for the necessary changes.&lt;/p&gt;

&lt;hr&gt;

&lt;h2 id="setting-up-the-build-environment"&gt;Setting up the build environment&lt;/h2&gt;

&lt;p&gt;KDE’s official way to build AppImages is through &lt;a href="https://invent.kde.org/sysadmin/ci-tooling/-/blob/master/system-images/appimage-1604/Dockerfile"&gt;a Docker image&lt;/a&gt;. This image is based off 16.04 x64. We’ll port this image to ARM 
and run it under the QEMU emulator.
This is done by changing the base image to &lt;code&gt;multiarch/ubuntu-debootstrap:armhf-xenial&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We also need to build four tools that do not have official, up-to-date binaries 
available:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;CMake&lt;/li&gt;
  &lt;li&gt;AppImageTool&lt;/li&gt;
  &lt;li&gt;patchelf&lt;/li&gt;
  &lt;li&gt;linuxdeployqt&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To make this easy, I’ll just show you the finished &lt;code&gt;Dockerfile&lt;/code&gt;. I build a 
&lt;code&gt;base&lt;/code&gt; layer which matches almost perfectly the original image, then build the 
four tools off it, and finally copy it back to the final layer. The key 
difference is that I changed the &lt;code&gt;USER&lt;/code&gt; to an unprivileged one, and the 
&lt;code&gt;ENTRYPOINT&lt;/code&gt; to &lt;code&gt;bash&lt;/code&gt; (through QEMU).&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-dockerfile" data-lang="dockerfile"&gt;FROM multiarch/ubuntu-debootstrap:armhf-xenial as base

# Start off as root
USER root

# Setup the various repositories we are going to need for our dependencies
# Some software demands a newer GCC because they're using C++14 stuff, which is just insane
# AMY: CMake must be compiled manually, Kitware does not provide ARM packages
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y apt-transport-https ca-certificates gnupg software-properties-common wget
RUN add-apt-repository -y ppa:openjdk-r/ppa

# Update the system and bring in our core operating requirements
RUN apt-get update &amp;amp;&amp;amp; apt-get upgrade -y &amp;amp;&amp;amp; apt-get install -y openssh-server openjdk-8-jre-headless

# Some software demands a newer GCC because they're using C++14 stuff, which is just insane
# We do this after the general system update to ensure it doesn't bring in any unnecessary updates
# AMY: Add universe repo at this time, debootstrap does not include it; we'll need it for gstreamer
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test &amp;amp;&amp;amp; add-apt-repository universe &amp;amp;&amp;amp; apt-get update

# Now install the general dependencies we need for builds
RUN apt-get install -y \
    # General requirements for building KDE software
    build-essential git-core locales \
    # General requirements for building other software
    automake gcc-6 g++-6 libxml-parser-perl libpq-dev libaio-dev \
    # Needed for some frameworks
    bison gettext \
    # Qt and KDE Build Dependencies
    gperf libasound2-dev libatkmm-1.6-dev libbz2-dev libcairo-perl libcap-dev libcups2-dev libdbus-1-dev \
    libdrm-dev libegl1-mesa-dev libfontconfig1-dev libfreetype6-dev libgcrypt11-dev libgl1-mesa-dev \
    libglib-perl libgsl0-dev libgsl0-dev gstreamer1.0-alsa libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
    libgtk2-perl libjpeg-dev libnss3-dev libpci-dev libpng12-dev libpulse-dev libssl-dev \
    libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \
    gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly libtiff5-dev libudev-dev libwebp-dev flex libmysqlclient-dev \
    # Mesa libraries for everything to use
    libx11-dev libxkbcommon-x11-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-util0-dev libxcb-res0-dev libxcb1-dev libxcomposite-dev libxcursor-dev \
    libxdamage-dev libxext-dev libxfixes-dev libxi-dev libxrandr-dev libxrender-dev libxss-dev libxtst-dev mesa-common-dev \
    # Kdenlive AppImage extra dependencies
    liblist-moreutils-perl libtool libpixman-1-dev subversion

# Setup a user account for everything else to be done under
RUN useradd -d /home/appimage/ -u 1000 --user-group --create-home -G video appimage

# Get locales in order
RUN locale-gen en_US en_US.UTF-8 en_NZ.UTF-8

###
### Prepare cmake
###

FROM base as cmake

# TODO test if pip install cmake works
RUN cd /tmp &amp;amp;&amp;amp; \
    wget -c https://cmake.org/files/v3.17/cmake-3.17.0.tar.gz &amp;amp;&amp;amp; \
    tar xf cmake-3.17.0.tar.gz &amp;amp;&amp;amp; \
    cd cmake-3.17.0 &amp;amp;&amp;amp; \
    ./bootstrap --prefix=/tmp/cmake --parallel=$(nproc) &amp;amp;&amp;amp; \
    make -j $(nproc) &amp;amp;&amp;amp; \
    make -j $(nproc) install

###
### Prepare appimagetool
###

FROM base as appimagetool

# Install appimagetool
RUN cd /tmp &amp;amp;&amp;amp; \
    wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-armhf.AppImage" &amp;amp;&amp;amp; \
    chmod +x appimagetool*AppImage &amp;amp;&amp;amp; \
    mkdir appimagetool &amp;amp;&amp;amp; \
    cd appimagetool &amp;amp;&amp;amp; \
    qemu-arm-static /tmp/appimagetool*AppImage --appimage-extract &amp;amp;&amp;amp; \
    chmod +rx squashfs-root/usr/lib/appimagekit

###
### Prepare patchelf
###

FROM base AS patchelf

RUN cd /tmp &amp;amp;&amp;amp; \
    wget -c https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2 &amp;amp;&amp;amp; \ 
    tar xf patchelf-0.9.tar.bz2 &amp;amp;&amp;amp; \
    cd patchelf-0.9/ &amp;amp;&amp;amp; \
    ./configure --prefix=/tmp/patchelf &amp;amp;&amp;amp; \
    make -j$(nproc) &amp;amp;&amp;amp; \
    make -j$(nproc) install

###
### Prepare linuxdeployqt
###

FROM base as linuxdeployqt

COPY --from=patchelf /tmp/patchelf /

COPY --from=appimagetool  /tmp/appimagetool/squashfs-root/usr/ /usr/local

RUN apt-get install -y \
    qt5-default qtbase5-dev qttools5-dev-tools

RUN cd /tmp &amp;amp;&amp;amp; \
    git clone https://github.com/probonopd/linuxdeployqt.git src &amp;amp;&amp;amp; \
    cd src &amp;amp;&amp;amp; \
    qmake CONFIG+=release CONFIG+=force_debug_info linuxdeployqt.pro &amp;amp;&amp;amp; \
    make -j$(nproc) &amp;amp;&amp;amp; \
    mkdir -p linuxdeployqt.AppDir/usr/bin &amp;amp;&amp;amp; \
    mkdir -p linuxdeployqt.AppDir/usr/lib &amp;amp;&amp;amp; \
    cp ./bin/linuxdeployqt linuxdeployqt.AppDir/usr/bin/ &amp;amp;&amp;amp; \
    chmod +x linuxdeployqt.AppDir/AppRun &amp;amp;&amp;amp; \
    ./bin/linuxdeployqt linuxdeployqt.AppDir/linuxdeployqt.desktop -verbose=3 -appimage -executable=linuxdeployqt.AppDir/usr/bin/linuxdeployqt &amp;amp;&amp;amp; \
    cd /tmp &amp;amp;&amp;amp; \
    mkdir linuxdeployqt &amp;amp;&amp;amp; \
    cd linuxdeployqt &amp;amp;&amp;amp; \
    qemu-arm-static /tmp/src/linuxdeployqt*AppImage --appimage-extract

###
# Merge all tools (into /usr/local, that folder is ignored by Krita scripts)
###

FROM base

LABEL Description="KDE Appimage Base (armhf)"
LABEL vendor="amyspark.me"
LABEL me.amyspark.release-date="2020-07-13"

# Install cmake

COPY --from=cmake /tmp/cmake /usr/local

# Install patchelf
COPY --from=patchelf /tmp/patchelf /usr/local

# Install linuxdeployqt
COPY --from=linuxdeployqt /tmp/linuxdeployqt/squashfs-root/usr/ /usr/local

# Install appimagetool
COPY --from=appimagetool  /tmp/appimagetool/squashfs-root/usr/ /usr/local

USER appimage

ENTRYPOINT [ "/usr/bin/qemu-arm-static", "/bin/bash" ]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I build this image with:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;docker build . --tag krita:latest&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After a good half day, I got a freshly built base for my AppImage needs.&lt;/p&gt;

&lt;h3 id="building-dependencies-and-krita"&gt;Building dependencies and Krita&lt;/h3&gt;

&lt;p&gt;To build our dependencies, KDE uses a script available at Krita’s repo under &lt;a href="https://invent.kde.org/graphics/krita/-/blob/krita/4.3/packaging/linux/appimage/build-deps.sh"&gt;&lt;code&gt;packaging/linux/appimage/build-deps.sh&lt;/code&gt;&lt;/a&gt;.
In ARM, this script will fail out of the box. It needs the following changes 
(replace X with the number of threads):&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Add &lt;code&gt;-DSUBMAKE_JOBS=X&lt;/code&gt; to the &lt;code&gt;cmake&lt;/code&gt; line. This enables multithreading the Qt build.&lt;/li&gt;
  &lt;li&gt;Append &lt;code&gt;-- -jX&lt;/code&gt; to the end of each dependency line below it, &lt;strong&gt;except the following&lt;/strong&gt; (these use &lt;code&gt;make&lt;/code&gt; directly):
    &lt;ul&gt;
      &lt;li&gt;expat&lt;/li&gt;
      &lt;li&gt;python&lt;/li&gt;
      &lt;li&gt;sip&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following dependencies will not build, comment them out:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;OpenColorIO (&lt;code&gt;ext_ocio&lt;/code&gt;)
    &lt;ul&gt;
      &lt;li&gt;it needs &lt;a href="https://github.com/AcademySoftwareFoundation/OpenColorIO/pull/970.patch"&gt;this patch&lt;/a&gt; applied&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;libx265 (inside &lt;code&gt;ext_heif&lt;/code&gt;)
    &lt;ul&gt;
      &lt;li&gt;append &lt;code&gt;-DENABLE_ASSEMBLY=FALSE&lt;/code&gt; to the end of the &lt;code&gt;CMAKE_ARGS&lt;/code&gt; line in the &lt;code&gt;ext_x265&lt;/code&gt; block of &lt;code&gt;3rdparty/ext_heif/CMakeLists.txt&lt;/code&gt;
&lt;/li&gt;
      &lt;li&gt;this was reported to MultiCoreWare as &lt;a href="https://bitbucket.org/multicoreware/x265/issues/486"&gt;#486&lt;/a&gt;
&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;python (&lt;code&gt;ext_python&lt;/code&gt;)
    &lt;ul&gt;
      &lt;li&gt;it will randomly hang when building the tests&lt;/li&gt;
      &lt;li&gt;I just &lt;code&gt;kill -HUP&lt;/code&gt; the offending processes, or edit the &lt;code&gt;BUILD_COMMAND&lt;/code&gt; and change the make target to &lt;code&gt;build_all&lt;/code&gt;
&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;GSL (&lt;code&gt;ext_gsl&lt;/code&gt;)
    &lt;ul&gt;
      &lt;li&gt;Linux needs the shared version, replace &lt;code&gt;if (ANDROID)&lt;/code&gt; with &lt;code&gt;if (UNIX)&lt;/code&gt; in &lt;code&gt;3rdparty/ext_gsl/CMakeLists.txt&lt;/code&gt;
&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Vc (&lt;code&gt;ext_vc&lt;/code&gt;)
    &lt;ul&gt;
      &lt;li&gt;there is no fix available for this&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Assuming your working directory is where you cloned Krita’s repository (it should have a &lt;code&gt;src&lt;/code&gt; folder), run:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;docker run --rm -v $(pwd):/krita -ti krita:latest -- /krita/src/packaging/linux/appimage/build-deps.sh /krita/appimage_build_armhf /krita/src&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After some 6 or 7 hours, you should have a fully working set of libraries.&lt;/p&gt;

&lt;h2 id="building-krita"&gt;Building Krita&lt;/h2&gt;

&lt;p&gt;This does not need any changes. Run:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;docker run --rm -v $(pwd):/krita -ti krita:latest -- /krita/src/packaging/linux/appimage/build-krita.sh /krita/appimage_build_armhf /krita/src&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="packing-the-appimages"&gt;Packing the AppImages&lt;/h2&gt;

&lt;p&gt;The AppImage packaging process is run through two scripts, &lt;a href="https://invent.kde.org/graphics/krita/-/blob/krita/4.3/packaging/linux/appimage/build-gmic-qt.sh"&gt;&lt;code&gt;build-gmic-qt.sh&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://invent.kde.org/graphics/krita/-/blob/krita/4.3/packaging/linux/appimage/build-image.sh"&gt;&lt;code&gt;build-image.sh&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;These scripts hardcode two assumptions:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;that the platform is &lt;code&gt;x86_64&lt;/code&gt;
&lt;/li&gt;
  &lt;li&gt;that the ABI (i.e. the platform triplet) is &lt;code&gt;x86_64-linux-gnu&lt;/code&gt;
We’ll fix both.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In &lt;code&gt;build-gmic-qt.sh&lt;/code&gt; add before the final &lt;code&gt;mv&lt;/code&gt; command these lines:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;ARCH=`dpkg --print-architecture`
TRIPLET=`gcc -dumpmachine`&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and replace the &lt;code&gt;mv&lt;/code&gt; with:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;mv gmic_krita_qt*$ARCH.AppImage gmic_krita_qt-$ARCH.appimage&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In &lt;code&gt;build-image.sh&lt;/code&gt;, the process is a bit more convoluted, so apply this diff:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-diff" data-lang="diff"&gt;diff --git a/packaging/linux/appimage/build-image.sh b/packaging/linux/appimage/build-image.sh
index 1e3660b1dd..41579edc1d 100755
--- a/packaging/linux/appimage/build-image.sh
+++ b/packaging/linux/appimage/build-image.sh
@@ -22,7 +22,9 @@ export DEPS_INSTALL_PREFIX=$BUILD_PREFIX/deps/usr/
 export DOWNLOADS_DIR=$BUILD_PREFIX/downloads/
 
 # Setup variables needed to help everything find what we built
-export LD_LIBRARY_PATH=$DEPS_INSTALL_PREFIX/lib/:$DEPS_INSTALL_PREFIX/lib/x86_64-linux-gnu/:$APPDIR/usr/lib/:$LD_LIBRARY_PATH
+ARCH=`dpkg --print-architecture`
+TRIPLET=`gcc -dumpmachine`
+export LD_LIBRARY_PATH=$DEPS_INSTALL_PREFIX/lib/:$DEPS_INSTALL_PREFIX/lib/$TRIPLET/:$APPDIR/usr/lib/:$LD_LIBRARY_PATH
 export PATH=$DEPS_INSTALL_PREFIX/bin/:$PATH
 export PKG_CONFIG_PATH=$DEPS_INSTALL_PREFIX/share/pkgconfig/:$DEPS_INSTALL_PREFIX/lib/pkgconfig/:/usr/lib/pkgconfig/:$PKG_CONFIG_PATH
 export CMAKE_PREFIX_PATH=$DEPS_INSTALL_PREFIX:$CMAKE_PREFIX_PATH
@@ -50,8 +52,10 @@ cp -r $DEPS_INSTALL_PREFIX/share/sip $APPDIR/usr/share
 cp -r $DEPS_INSTALL_PREFIX/translations $APPDIR/usr/
 
 # Step 2: Relocate x64 binaries from the architecture specific directory as required for Appimages
-mv $APPDIR/usr/lib/x86_64-linux-gnu/*  $APPDIR/usr/lib
-rm -rf $APPDIR/usr/lib/x86_64-linux-gnu/
+if [ -d $APPDIR/usr/lib/$TRIPLET ] ; then
+  mv $APPDIR/usr/lib/$TRIPLET/*  $APPDIR/usr/lib
+  rm -rf $APPDIR/usr/lib/$TRIPLET/
+fi
 
 # Step 3: Update the rpath in the various plugins we have to make sure they'll be loadable in an Appimage context
 for lib in $PLUGINS/*.so*; do
@@ -126,7 +130,7 @@ linuxdeployqt $APPDIR/usr/share/applications/org.kde.krita.desktop \
   -appimage 
   
 # Generate a new name for the Appimage file and rename it accordingly
-APPIMAGE=krita-"$VERSION"-x86_64.appimage
+APPIMAGE=krita-"$VERSION"-$ARCH.appimage
 
-mv Krita*x86_64.AppImage $APPIMAGE
+mv Krita*$ARCH.AppImage $APPIMAGE&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you should be able to run:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash" data-lang="bash"&gt;docker run --rm -v $(pwd):/krita -ti krita:latest -- /krita/src/packaging/linux/appimage/build-image.sh /krita/appimage_build_armhf /krita/src
docker run --rm -v $(pwd):/krita -ti krita:latest -- /krita/src/packaging/linux/appimage/build-gmic-qt.sh /krita/appimage_build_armhf /krita/src&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and get your own set of AppImages, fresh from the oven!&lt;/p&gt;

&lt;h2 id="release"&gt;Release!&lt;/h2&gt;

&lt;p&gt;The AppImage is at my &lt;a href="https://s3.amyspark.me/krita/krita-4.3.1-alpha-79267b7-armhf.appimage"&gt;S3 dumping ground&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Integrity check:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-plaintext" data-lang="plaintext"&gt;d1b982ddbe8cc0e3fbd6032a9db7067f7de30ad034aa5c8f1d5f291e350296ac  krita-4.3.1-alpha-79267b7-armhf.appimage&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="and-what-about-aarch64"&gt;And what about aarch64?&lt;/h2&gt;

&lt;p&gt;This one took me another whole day (well, 12 hour shift – plus 4 more hours, 
thanks to a bug in KDE’s Dockerfile).&lt;/p&gt;

&lt;p&gt;There are two big bugs in &lt;code&gt;aarch64&lt;/code&gt;. First, to build Qt’s X11Extras module, the 
key dependency is &lt;code&gt;xkbcommon-dev&lt;/code&gt;. However, in all platforms it is brought in 
by &lt;code&gt;libegl1-mesa-dev&lt;/code&gt;– &lt;a href="https://packages.ubuntu.com/xenial/libegl1-mesa-dev"&gt;except on aarch64, courtesy of libmirclient-dev&lt;/a&gt;. You need to add it 
manually to the Dockerfile.&lt;/p&gt;

&lt;p&gt;Then, AppImageKit has a weird naming convention for this platform. While Debian 
names 32-bit ARM (hard floating point) &lt;code&gt;armhf&lt;/code&gt;, and 64-bit &lt;code&gt;arm64&lt;/code&gt;, AppImageKit 
calls the latter &lt;code&gt;aarch64&lt;/code&gt;. This will need extra tinkering in the build scripts 
(which I did not care to do at this point, seeing how much it takes to compile).&lt;/p&gt;

&lt;p&gt;Also, libx265 will not work on &lt;code&gt;aarch64&lt;/code&gt; because we run 3.2.1, which does not 
support this platform at all.&lt;/p&gt;

&lt;p&gt;This is the Dockerfile for &lt;code&gt;aarch64&lt;/code&gt;. You can use it with the commands above 
(just change the &lt;code&gt;armhf&lt;/code&gt; suffix for &lt;code&gt;arm64&lt;/code&gt; where necessary):&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-dockerfile" data-lang="dockerfile"&gt;FROM multiarch/ubuntu-debootstrap:arm64-xenial as base

# Start off as root
USER root

# Setup the various repositories we are going to need for our dependencies
# Some software demands a newer GCC because they're using C++14 stuff, which is just insane
# AMY: CMake must be compiled manually, Kitware does not provide ARM packages
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y apt-transport-https ca-certificates gnupg software-properties-common wget
RUN add-apt-repository -y ppa:openjdk-r/ppa

# Update the system and bring in our core operating requirements
RUN apt-get update &amp;amp;&amp;amp; apt-get upgrade -y &amp;amp;&amp;amp; apt-get install -y openssh-server openjdk-8-jre-headless

# Some software demands a newer GCC because they're using C++14 stuff, which is just insane
# We do this after the general system update to ensure it doesn't bring in any unnecessary updates
# AMY: Add universe repo at this time, debootstrap does not include it
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test &amp;amp;&amp;amp; add-apt-repository universe &amp;amp;&amp;amp; apt-get update

# Now install the general dependencies we need for builds
RUN apt-get install -y \
    # General requirements for building KDE software
    build-essential git-core locales \
    # General requirements for building other software
    automake gcc-6 g++-6 libxml-parser-perl libpq-dev libaio-dev \
    # Needed for some frameworks
    bison gettext \
    # Qt and KDE Build Dependencies
    gperf libasound2-dev libatkmm-1.6-dev libbz2-dev libcairo-perl libcap-dev libcups2-dev libdbus-1-dev \
    libdrm-dev libegl1-mesa-dev libfontconfig1-dev libfreetype6-dev libgcrypt11-dev libgl1-mesa-dev \
    # AMY: on arm64, libegl1-mesa-dev does not bring in libxkbcommon-dev
    libxkbcommon-dev \
    libglib-perl libgsl0-dev libgsl0-dev gstreamer1.0-alsa libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
    libgtk2-perl libjpeg-dev libnss3-dev libpci-dev libpng12-dev libpulse-dev libssl-dev \
    libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \
    gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly libtiff5-dev libudev-dev libwebp-dev flex libmysqlclient-dev \
    # Mesa libraries for everything to use
    libx11-dev libxkbcommon-x11-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-util0-dev libxcb-res0-dev libxcb1-dev libxcomposite-dev libxcursor-dev \
    libxdamage-dev libxext-dev libxfixes-dev libxi-dev libxrandr-dev libxrender-dev libxss-dev libxtst-dev mesa-common-dev \
    # Kdenlive AppImage extra dependencies
    liblist-moreutils-perl libtool libpixman-1-dev subversion

# Setup a user account for everything else to be done under
RUN useradd -d /home/appimage/ -u 1000 --user-group --create-home -G video appimage

# Get locales in order
RUN locale-gen en_US en_US.UTF-8 en_NZ.UTF-8

###
### Prepare cmake
###

FROM base as cmake

# TODO test if pip install cmake works
RUN cd /tmp &amp;amp;&amp;amp; \
    wget -c https://cmake.org/files/v3.17/cmake-3.17.0.tar.gz &amp;amp;&amp;amp; \
    tar xf cmake-3.17.0.tar.gz &amp;amp;&amp;amp; \
    cd cmake-3.17.0 &amp;amp;&amp;amp; \
    ./bootstrap --prefix=/tmp/cmake --parallel=$(nproc) &amp;amp;&amp;amp; \
    make -j $(nproc) &amp;amp;&amp;amp; \
    make -j $(nproc) install

###
### Prepare appimagetool
###

FROM base as appimagetool

# Install appimagetool
RUN cd /tmp &amp;amp;&amp;amp; \
    wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage" &amp;amp;&amp;amp; \
    chmod +x appimagetool*AppImage &amp;amp;&amp;amp; \
    mkdir appimagetool &amp;amp;&amp;amp; \
    cd appimagetool &amp;amp;&amp;amp; \
    qemu-aarch64-static /tmp/appimagetool*AppImage --appimage-extract &amp;amp;&amp;amp; \
    chmod +rx squashfs-root/usr/lib/appimagekit

###
### Prepare patchelf
###

FROM base AS patchelf

RUN cd /tmp &amp;amp;&amp;amp; \
    wget -c https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2 &amp;amp;&amp;amp; \ 
    tar xf patchelf-0.9.tar.bz2 &amp;amp;&amp;amp; \
    cd patchelf-0.9/ &amp;amp;&amp;amp; \
    ./configure --prefix=/tmp/patchelf &amp;amp;&amp;amp; \
    make -j$(nproc) &amp;amp;&amp;amp; \
    make -j$(nproc) install

###
### Prepare linuxdeployqt
###

FROM base as linuxdeployqt

COPY --from=patchelf /tmp/patchelf /

COPY --from=appimagetool  /tmp/appimagetool/squashfs-root/usr/ /usr/local

RUN apt-get install -y \
    qt5-default qtbase5-dev qttools5-dev-tools

RUN cd /tmp &amp;amp;&amp;amp; \
    git clone https://github.com/probonopd/linuxdeployqt.git src &amp;amp;&amp;amp; \
    cd src &amp;amp;&amp;amp; \
    qmake CONFIG+=release CONFIG+=force_debug_info linuxdeployqt.pro &amp;amp;&amp;amp; \
    make -j$(nproc) &amp;amp;&amp;amp; \
    mkdir -p linuxdeployqt.AppDir/usr/bin &amp;amp;&amp;amp; \
    mkdir -p linuxdeployqt.AppDir/usr/lib &amp;amp;&amp;amp; \
    cp ./bin/linuxdeployqt linuxdeployqt.AppDir/usr/bin/ &amp;amp;&amp;amp; \
    chmod +x linuxdeployqt.AppDir/AppRun &amp;amp;&amp;amp; \
    ./bin/linuxdeployqt linuxdeployqt.AppDir/linuxdeployqt.desktop -verbose=3 -appimage -executable=linuxdeployqt.AppDir/usr/bin/linuxdeployqt &amp;amp;&amp;amp; \
    cd /tmp &amp;amp;&amp;amp; \
    mkdir linuxdeployqt &amp;amp;&amp;amp; \
    cd linuxdeployqt &amp;amp;&amp;amp; \
    qemu-aarch64-static /tmp/src/linuxdeployqt*AppImage --appimage-extract

###
# Merge all tools (into /usr/local, that folder is ignored by Krita scripts)
###

FROM base

LABEL Description="KDE Appimage Base (arm64)"
LABEL vendor="amyspark.me"
LABEL me.amyspark.release-date="2020-07-14"

# Install cmake

COPY --from=cmake /tmp/cmake /usr/local

# Install patchelf
COPY --from=patchelf /tmp/patchelf /usr/local

# Install linuxdeployqt
COPY --from=linuxdeployqt /tmp/linuxdeployqt/squashfs-root/usr/ /usr/local

# Install appimagetool
COPY --from=appimagetool  /tmp/appimagetool/squashfs-root/usr/ /usr/local

USER appimage

ENTRYPOINT [ "/usr/bin/qemu-aarch64-static", "/bin/bash" ]&lt;/code&gt;&lt;/pre&gt;

&lt;figure class="text-center figure"&gt;
  &lt;img class="figure-img img-fluid" src="/assets/posts/2020/07/2020-07-15-010612_1920x1080_scrot.jpg"&gt;
  &lt;figcaption class="figure-caption"&gt;
    The AppImage running on Libre Computer's 2GB Le Potato. It is way faster UI-wise, but the canvas slows down when hovering...
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The AppImage is at my &lt;a href="https://s3.amyspark.me/krita/krita-4.3.1-alpha-aba6da1-aarch64.AppImage"&gt;S3 dumping ground&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Integrity check:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-plaintext" data-lang="plaintext"&gt;1c388f527c23783d58ab23d5e07d186c1a914ded7e9d1d3b7df7a7153dd6dd5f  krita-4.3.1-alpha-aba6da1-aarch64.AppImage&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And this is all from me today! Please chime in &lt;a href="https://krita-artists.org/t/first-alpha-of-my-gsoc-project-procedural-texture-generator/8127"&gt;on the Krita Artists thread&lt;/a&gt;
if you have any feedback.&lt;/p&gt;

&lt;p&gt;Cheers,
~amyspark&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="[&quot;Planet KDE&quot;, &quot;GSoC&quot;]"/>
    <summary type="html"><![CDATA[The AppImage running on a Raspberry Pi 3B+. It's slow, but it works :smile: Someone on #krita, can’t remember their exact nick, asked if it was possible to run Krita on ARM-based computers, specifically the Raspberry Pi 3B+. AFAIK, no one has tried to do so, so I will tell you: yes, it is possible! (Although it will run as slow as a turtle!) This work took me the whole weekend, but it was an excellent experience as well as a wonderful way to test our infrastructure. A key warning before moving on: DO NOT TRY THIS ON YOUR PI. It will be unbearably slow :smile: I built mine with a Ryzen 7 with 12 threads and it still took me two 12-hour shifts! This post covers three steps: setting up the build environment, compiling the dependencies and Krita itself, and finally packaging the AppImages themselves. As per the official instructions, we’ll target Ubuntu 16.04 ARM. I chose the armhf port to match the Raspberry Pi’s default distro, Raspbian. I also tested aarch64 – see the last section for the necessary changes.]]></summary>
  </entry>
  <entry>
    <title type="html">Third alpha release of my project</title>
    <link href="https://www.amyspark.me/blog/posts/2020/07/03/third-alpha-release.html" rel="alternate" type="text/html" title="Third alpha release of my project"/>
    <published>2020-07-03T14:45:00+00:00</published>
    <updated>2020-07-03T14:45:00+00:00</updated>
    <id>https://www.amyspark.me/blog/posts/2020/07/03/third-alpha-release</id>
    <content type="html" xml:base="https://www.amyspark.me/blog/posts/2020/07/03/third-alpha-release.html">&lt;p&gt;I’m glad to announce the third alpha of &lt;a href="https://krita.org/en/item/presenting-our-google-summer-of-code-students/"&gt;my GSoC 2020 project&lt;/a&gt;. For anyone not in the loop, I’m working on integrating &lt;a href="/blog/posts/2020/05/19/what-is-seexpr-about.html"&gt;Disney’s SeExpr expression language as a new type of Fill Layer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this release, I fixed the following issues:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;SeExpr textures use the scRGB color space, which is not supported by Qt’s &lt;code&gt;QColor&lt;/code&gt; until 5.12. This makes the conversion to Krita space unbearably slow (thanks Wolthera van Hövell)&lt;/li&gt;
  &lt;li&gt;Refactored SeExpr error reporting to make messages Qt-translatable.
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;This adds KDE’s ECM to the list of (optional) dependencies of SeExpr.&lt;/strong&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Error reporting is now available, including highlighting! (thanks Wolthera too for noticing)&lt;/li&gt;
  &lt;li&gt;Configuration is saved and restored when changing between Fill layer types (&lt;a href="https://bugs.kde.org/show_bug.cgi?id=422885"&gt;bug 422885&lt;/a&gt;, thanks Boudewijn Rempt)&lt;/li&gt;
  &lt;li&gt;Cleaned up SeExpr headers
    &lt;ul&gt;
      &lt;li&gt;They are now installed only if used in the UI library itself.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;UI labels have extra spacing (thanks Wolthera van Hövell)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another outstanding issue is SeExpr’s vulnerability to the current &lt;code&gt;LC_NUMERIC&lt;/code&gt; 
locale, due to its use of &lt;code&gt;sscanf&lt;/code&gt; and &lt;code&gt;atof&lt;/code&gt;. I am sad to announce I won’t be 
able to change this; the library I wanted to use, &lt;a href="https://github.com/eliaskosunen/scnlib"&gt;scn&lt;/a&gt; is &lt;a href="https://github.com/eliaskosunen/scnlib/issues/24"&gt;itself vulnerable&lt;/a&gt; to locale changes.&lt;/p&gt;

&lt;p&gt;But the most important feature, and final contribution, are &lt;strong&gt;bundleable presets&lt;/strong&gt;!&lt;/p&gt;

&lt;figure class="text-center d-block figure"&gt;
&lt;div class="row figure-img"&gt;
    &lt;div class="col-12 col-md-6"&gt;
        &lt;img class="img-fluid" src="/assets/posts/2020/07/seexpr-bundle-1.png"&gt;
    &lt;/div&gt;
    &lt;div class="col-12 col-md-6"&gt;
        &lt;img class="img-fluid" src="/assets/posts/2020/07/seexpr-bundle-2.png"&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;

&lt;p&gt;This enables SeExpr scripts to be bundled just like any other resource in Krita.
Below you can find a bundle containing all of &lt;a href="https://krita-artists.org/t/procedural-texture-generator-example-and-wishes/7638/8"&gt;the example scripts&lt;/a&gt; 
posted by Wolthera on the Krita Artists thread.&lt;/p&gt;

&lt;figure class="text-center figure"&gt;
  &lt;img class="figure-img img-fluid" src="/assets/posts/2020/07/seexpr-bundle-3.png"&gt;
&lt;/figure&gt;

&lt;p&gt;Looking forward to your comments!&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;

&lt;p&gt;~amyspark &lt;span class="emoji" aria-label=":sparkles_nonconforming:" role="img"&gt;&lt;img aria-hidden="true" alt=":sparkles_nonconforming:" title=":sparkles_nonconforming:" style="width: 1em; height: 1em;" src="/assets/static/emoji/sparkles/sparkles_nonconforming.png"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;PS: The Git hash in the files point &lt;a href="https://invent.kde.org/lsegovia/krita/-/commits/amyspark/rebase-T13097-gsoc2020-seexpr/"&gt;to a cleaned up branch at my own fork of Krita&lt;/a&gt;. I am reviewing options to sync this work back to the main &lt;code&gt;krita/4.3&lt;/code&gt; branch.&lt;/p&gt;</content>
    <author>
      <name>amyspark</name>
    </author>
    <category term="[&quot;Planet KDE&quot;, &quot;GSoC&quot;]"/>
    <summary type="html"><![CDATA[I’m glad to announce the third alpha of my GSoC 2020 project. For anyone not in the loop, I’m working on integrating Disney’s SeExpr expression language as a new type of Fill Layer.]]></summary>
  </entry>
</feed>
