{"article":{"slug":"paths-in-pieces","title":"Paths in pieces","subtitle":null,"summary":"Linux distributions and package managers audit built binaries for non-relocatable absolute paths with grep or strings, but with GCC on x86-64 string constants are often split into immediate-value pieces, so those checks miss embedded build paths.","content_type":"blog_post","language":"en","canonical_url":"https://stoppels.ch/2026/11/12/paths-in-pieces.html","author":{"name":"Harmen Stoppels","url":"https://stoppels.ch/","person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"stoppels.ch","url":"https://stoppels.ch/","listing_slug":null,"listing":null},"topics":[{"name":"compilers","slug":"compilers","url":"https://listedarticles.com/topics/compilers"},{"name":"linux","slug":"linux","url":"https://listedarticles.com/topics/linux"},{"name":"build-systems","slug":"build-systems","url":"https://listedarticles.com/topics/build-systems"},{"name":"c","slug":"c","url":"https://listedarticles.com/topics/c"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":1483,"reading_minutes":6,"published_at":"2026-11-12T00:00:00.000Z","added_at":"2026-11-12T20:11:53.048Z","updated_at":"2026-11-12T20:11:53.048Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/paths-in-pieces","markdown_url":"https://listedarticles.com/articles/paths-in-pieces.md","example":false,"citation":"Harmen Stoppels, stoppels.ch. \"Paths in pieces.\" 12 Nov 2026. https://stoppels.ch/2026/11/12/paths-in-pieces.html (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://stoppels.ch/2026/11/12/paths-in-pieces.html"},"body_markdown":"# Paths in pieces\n\n*Nov 12th, 2026*\n\nMany[[1]](#fn1)[[2]](#fn2)[[3]](#fn3)[[4]](#fn4)[[5]](#fn5)[[6]](#fn6)[[7]](#fn7)[[8]](#fn8)[[9]](#fn9) Linux distributions and package managers audit just-built binaries for non-relocatable absolute paths. If a binary contains a path `/path/from/build/machine`, it might not run on the end-user's machine.\n\nNow, a basic `grep` on the binary, or a slightly more sophisticated\n\n```\n$ strings bin/app | grep /path/from/build/machine\n```\n\nusing GNU binutils's `strings` will detect these paths, right?\n\nThe answer is *no*, at least when using GCC and targeting `x86-64`: you should *not* assume that string constants end up literally in the binary.\n\n## Basic example\n\nIn this C++ source we create a `std::string` from a string constant:\n\n```\n#include <iostream>\n#include <string>\n\n#define PREFIX \"/home/linuxbrew/.linuxbrew\"\n\nint main() {\n  std::string prefix{PREFIX};\n  std::cout << prefix << '\\n';\n}\n```\n\nCompile with GCC 12 or later and run, which prints the path:\n\n```\n$ g++ -O2 main.cpp -o main\n$ ./main\n/home/linuxbrew/.linuxbrew\n```\n\nBut the path occurs precisely 0 times in the binary itself:\n\n```\n$ grep -acF /home/linuxbrew/.linuxbrew main\n0\n$ strings ./main | grep -cF /home/linuxbrew/.linuxbrew\n0\n```\n\nSurely these bytes must be part of the binary *somewhere*? Let's run `strings` on it and grep just for the `/home` prefix:\n\n```\n$ strings ./main | grep /home\n/home/linuxbrew/xbrew/.linuxbrew\n```\n\nWait, did GCC just turn\n\n```\n/home/linuxbrew/.linuxbrew\n```\n\ninto an entirely *different* path\n\n```\n/home/linuxbrew/xbrew/.linuxbrew\n```\n\nwith a made-up subdirectory `xbrew`? How?\n\n## Store by pieces\n\nThe answer is that GCC optimizes our `std::string{PREFIX}`. The fact that we see something that looks like the prefix is merely a coincidence.\n\nGCC splits our string up into two (overlapping) pieces of 16 bytes, like so\n\n```\n/home/linuxbrew/.linuxbrew\n|--------------|..........  - constant 1\n..........|--------------|  - constant 2\n```\n\nwhich fit exactly in `xmm` registers, so that it can copy our string to the `std::string` buffer using vectorized move instructions.\n\nFiltering the relevant bits from `g++ -O2 -S -masm=intel`, we get\n\n```\nmovdqa  xmm0, XMMWORD PTR .LC0[rip]\nmovups  XMMWORD PTR [rax], xmm0\nmovdqa  xmm0, XMMWORD PTR .LC1[rip]\nmovups  XMMWORD PTR 10[rax], xmm0\n```\n\nand our string is stored at `.LC0` and `.LC1` as constants, which just happen to be next to each other in the binary:\n\n```\n.LC0:\n.quad 7596498784141404207\n.quad 3420313983963919726\n.LC1:\n.quad 7795220194874516088\n.quad 8603408430414524009\n```\n\nIn general, this happens when a string constant is copied into a buffer, as with `std::string`, `strcpy` or `memcpy`; strings that are only passed around as pointers, like in `fopen(PREFIX \"/x\", \"r\")`, stay intact.\n\n## Deduplication\n\nSome package managers like Conda and Spack install packages into a padded prefix during their builds, with the idea that they can be “relocated” to a shorter prefix of the user's choice: the binaries are patched in-place. Conda uses a repeated string `_placehold` in a directory name to make the prefix long enough.\n\nNow, even if we pick a 256-byte path (a convenient multiple of all x86-64 register widths) by padding the path Conda-style\n\n```\n#define PREFIX \"/home/conda/feedstock_root/build_artifacts/\" \\\n               \"foo_1699999999999/_h_env\" \\\n               \"_placehold_placehold_placehold_placehold_placehold\" \\\n               \"_placehold_placehold_placehold_placehold_placehold\" \\\n               \"_placehold_placehold_placehold_placehold_placehold\" \\\n               \"_placehold_placehold_placehold_placeho/\"\n```\n\nand keep our fingers crossed that GCC puts the pieces of the path contiguously in the binary, we do *not* see our prefix back in the binary. What we get instead is a much shorter string of only 176 bytes (that is 11 times 16):\n\n```\n$ strings main | grep /home\n/home/conda/feedstock_root/build_artifacts/foo_1699999999999/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/\n```\n\nThis is thanks to a further optimization: since the string `_placehold` repeats every 10 bytes, the 16-byte pieces repeat every `lcm(10, 16) = 80` bytes, and GCC needs to store only 5 distinct 16-byte constants for the padding:\n\n```\n/home/conda/feed\nstock_root/build\n_artifacts/foo_1\n699999999999/_h_\nenv_placehold_pl\nacehold_placehol  # note\nd_placehold_plac  # that\nehold_placehold_  # this\nplacehold_placeh  # is\nold_placehold_pl  # cyclic\nacehold_placeho/\n```\n\n## Is this optimization helpful?\n\nFor string literals, I don't think so. Clang does not split strings into constants, yet it generates essentially the same instructions. For example, take a longer path, and target AVX2 with `-march=x86-64-v3`:\n\n```\n#define PREFIX \"/home/linuxbrew/.linuxbrew/Cellar/foo/1.2.3/share/foo\"\n```\n\nClang simply puts the string in a section dedicated to strings, `.rodata.str1.1`:\n\n```\n.L.str:\n.asciz \"/home/linuxbrew/.linuxbrew/Cellar/foo/1.2.3/share/foo\"\n```\n\nand copies its 53 bytes with two overlapping 32-byte `ymm` loads and stores, at offsets 21 and 0:\n\n```\nvmovups ymm0, ymmword ptr [rip + .L.str+21]\nvmovups ymmword ptr [rax + 21], ymm0\nvmovups ymm0, ymmword ptr [rip + .L.str]\nvmovups ymmword ptr [rax], ymm0\n```\n\nThat isn't particularly different from GCC's version, which loads the same two pieces from constants in `.rodata.cst32` instead:\n\n```\nvmovdqa ymm0, YMMWORD PTR .LC0[rip]\nvmovdqu YMMWORD PTR [rax], ymm0\nvmovdqa ymm0, YMMWORD PTR .LC1[rip]\nvmovdqu YMMWORD PTR 21[rax], ymm0\n```\n\nSo what does GCC gain? In terms of performance, probably nothing measurable: both do the same loads and stores. With repeated pieces, GCC might have a slight edge, because a repeated piece is loaded once and stored multiple times (11 loads for 16 stores in the earlier example). It also uses aligned reads, but that matters only for ancient CPUs.\n\nIn terms of size, GCC's pieces can take more space than the string itself: overlapping bytes are stored twice, and the pieces are aligned to 16, 32 or 64 bytes. The 53-byte path above takes 64 bytes as two pieces, against 54 bytes as a string. It only pays off if it results in deduplication, for example when many strings share a prefix of at least 16 bytes for SSE2, 32 bytes for AVX2, and 64 bytes for AVX-512. Presumably deduplication does not save much in practice, especially now that some distributions use AVX2 as their baseline.\n\n## Can I disable this optimization?\n\nOther than compiling with `-Os`, not really. From GCC 10 onwards (maybe older versions too?) the split-into-pieces optimization triggers for strings up to 256 bytes even without specifying `-march`. From GCC 12 it is relative to the target's vector width, so longer strings get split too: up to 512 bytes for AVX2 and 1024 bytes for AVX-512.\n\nI believe the only control you have over this is setting the maximum vector width to 128 bits (forcing `xmm` operations), by passing `-mstore-max=128`. But this merely restores old defaults, and means strings of up to 256 bytes are still stored in pieces.\n\n## Maybe post-hoc scanning is bad practice?\n\nThese post-build audits for absolute paths are popular, but you could argue that they are too brittle to start with, so why expect them to work at all?\n\nIndeed, Debian goes much further than a bad-path scan. Their audit asserts that a package can be rebuilt bit for bit in different circumstances: on a different machine, with a different user, time and date, hostname, locale, etc. That is a much more reliable way to keep machine-specific details out of binaries.[[10]](#fn10)\n\nI would argue that, despite that, it is *still* useful to keep string constants literally in the binary, even on Debian, because it improves interpretability of binaries. Running `strings ./binary` is such a simple and convenient way to get insight into an opaque binary blob, that it outweighs the marginal savings that come with splitting and deduplication. It is reminiscent of Fedora and Ubuntu turning frame pointers back on by default, despite the small overhead, just to make profilers and tracing tools work more reliably.\n\nOther than that, there is the argument of binary patching, which — despite being considered somewhat brittle — is common practice in Conda and Spack: upon install to a user-specified location, the absolute paths are patched in-place accordingly, through what can be seen as a glorified `sed` invocation. This only works if the path is stored in one piece.\n\n---\n\nIf you'd like to discuss this, a good place is the [gcc-patches thread](https://gcc.gnu.org/pipermail/gcc-patches/2026-November/738364.html) that I started recently, with an initial attempt at a patch that adds a way to opt out.\n\n[[1]](#fnref1) [RPM (Fedora, RHEL, openSUSE)](https://github.com/rpm-software-management/rpm/blob/4187d693cfd4704e3ffdf6483ea91a0d56134333/scripts/check-buildroot#L30-L42): `check-buildroot` greps every installed file for the build root.\n\n[[2]](#fnref2) [Arch Linux](https://gitlab.archlinux.org/pacman/pacman/-/blob/a6f7467d8c7c4d7e9cc846884e74c0ab7215c48d/scripts/libmakepkg/lint_package/build_references.sh.in#L30-L41): `makepkg` warns about references to `$srcdir` and `$pkgdir`.\n\n[[3]](#fnref3) [Yocto / OpenEmbedded](https://git.openembedded.org/openembedded-core/tree/meta/classes-global/insane.bbclass?id=c2ea9568b768de7c479aba22f15520793a7dace4#n427): the `buildpaths` QA check.\n\n[[4]](#fnref4) [FreeBSD ports](https://github.com/freebsd/freebsd-ports/blob/7ea5a0ba45376d1ca480b274157370705d3d01b2/Mk/Scripts/qa.sh#L201-L223): the stage QA greps for the staging directory.\n\n[[5]](#fnref5) [pkgsrc](https://github.com/NetBSD/pkgsrc/blob/e9b59cbd05f2c2ab1c37f8a8524bd38b1e256de8/mk/check/check-wrkref.mk#L90-L113): `CHECK_WRKREF`, off unless a package developer turns it on.\n\n[[6]](#fnref6) [Homebrew](https://github.com/Homebrew/brew/blob/8679d30f156018b0b184c64ab21a784f64b1d880/Library/Homebrew/keg_relocate.rb#L702-L775): `brew bottle` scans for the prefix to decide whether a bottle is relocatable.\n\n[[7]](#fnref7) [conda-build](https://github.com/conda/conda-build/blob/7dd6a86caf822254aac3217c5fded17cb915e004/conda_build/build.py#L1014-L1080): files containing the build prefix are listed in `info/has_prefix`, to be rewritten on install.\n\n[[8]](#fnref8) [rattler-build](https://github.com/prefix-dev/rattler-build/blob/0252f9ca2c5f8a9ab039b96ef09dc1d52d17de7d/crates/rattler_build_package/src/prefix/detector.rs#L15-L24): the same scheme as conda-build, with `memmem`.\n\n[[9]](#fnref9) [Julia's BinaryBuilder](https://github.com/JuliaPackaging/BinaryBuilder.jl/blob/d2b11c267ef8029af0f46a88b767246d7b9df1d1/src/auditor/filesystems.jl#L25-L45): `check_absolute_paths` warns about the build prefix in any file.\n\n[[10]](#fnref10) Even Debian keeps one path fixed: since early 2024 both builds use the [same build directory](https://tests.reproducible-builds.org/debian/index_variations.html), because it is recorded in the `.buildinfo` file and reused when rebuilding. So a build path embedded in a binary goes unnoticed there too.\n","body_html":"<h1 id=\"paths-in-pieces\">Paths in pieces</h1>\n<p><em>Nov 12th, 2026</em></p>\n<p>Many<a href=\"#fn1\">[1]</a><a href=\"#fn2\">[2]</a><a href=\"#fn3\">[3]</a><a href=\"#fn4\">[4]</a><a href=\"#fn5\">[5]</a><a href=\"#fn6\">[6]</a><a href=\"#fn7\">[7]</a><a href=\"#fn8\">[8]</a><a href=\"#fn9\">[9]</a> Linux distributions and package managers audit just-built binaries for non-relocatable absolute paths. If a binary contains a path <code>/path/from/build/machine</code>, it might not run on the end-user&#39;s machine.</p>\n<p>Now, a basic <code>grep</code> on the binary, or a slightly more sophisticated</p>\n<pre><code>$ strings bin/app | grep /path/from/build/machine</code></pre>\n<p>using GNU binutils&#39;s <code>strings</code> will detect these paths, right?</p>\n<p>The answer is <em>no</em>, at least when using GCC and targeting <code>x86-64</code>: you should <em>not</em> assume that string constants end up literally in the binary.</p>\n<h2 id=\"basic-example\">Basic example</h2>\n<p>In this C++ source we create a <code>std::string</code> from a string constant:</p>\n<pre><code>#include &lt;iostream&gt;\n#include &lt;string&gt;\n\n#define PREFIX &quot;/home/linuxbrew/.linuxbrew&quot;\n\nint main() {\n  std::string prefix{PREFIX};\n  std::cout &lt;&lt; prefix &lt;&lt; &#39;\\n&#39;;\n}</code></pre>\n<p>Compile with GCC 12 or later and run, which prints the path:</p>\n<pre><code>$ g++ -O2 main.cpp -o main\n$ ./main\n/home/linuxbrew/.linuxbrew</code></pre>\n<p>But the path occurs precisely 0 times in the binary itself:</p>\n<pre><code>$ grep -acF /home/linuxbrew/.linuxbrew main\n0\n$ strings ./main | grep -cF /home/linuxbrew/.linuxbrew\n0</code></pre>\n<p>Surely these bytes must be part of the binary <em>somewhere</em>? Let&#39;s run <code>strings</code> on it and grep just for the <code>/home</code> prefix:</p>\n<pre><code>$ strings ./main | grep /home\n/home/linuxbrew/xbrew/.linuxbrew</code></pre>\n<p>Wait, did GCC just turn</p>\n<pre><code>/home/linuxbrew/.linuxbrew</code></pre>\n<p>into an entirely <em>different</em> path</p>\n<pre><code>/home/linuxbrew/xbrew/.linuxbrew</code></pre>\n<p>with a made-up subdirectory <code>xbrew</code>? How?</p>\n<h2 id=\"store-by-pieces\">Store by pieces</h2>\n<p>The answer is that GCC optimizes our <code>std::string{PREFIX}</code>. The fact that we see something that looks like the prefix is merely a coincidence.</p>\n<p>GCC splits our string up into two (overlapping) pieces of 16 bytes, like so</p>\n<pre><code>/home/linuxbrew/.linuxbrew\n|--------------|..........  - constant 1\n..........|--------------|  - constant 2</code></pre>\n<p>which fit exactly in <code>xmm</code> registers, so that it can copy our string to the <code>std::string</code> buffer using vectorized move instructions.</p>\n<p>Filtering the relevant bits from <code>g++ -O2 -S -masm=intel</code>, we get</p>\n<pre><code>movdqa  xmm0, XMMWORD PTR .LC0[rip]\nmovups  XMMWORD PTR [rax], xmm0\nmovdqa  xmm0, XMMWORD PTR .LC1[rip]\nmovups  XMMWORD PTR 10[rax], xmm0</code></pre>\n<p>and our string is stored at <code>.LC0</code> and <code>.LC1</code> as constants, which just happen to be next to each other in the binary:</p>\n<pre><code>.LC0:\n.quad 7596498784141404207\n.quad 3420313983963919726\n.LC1:\n.quad 7795220194874516088\n.quad 8603408430414524009</code></pre>\n<p>In general, this happens when a string constant is copied into a buffer, as with <code>std::string</code>, <code>strcpy</code> or <code>memcpy</code>; strings that are only passed around as pointers, like in <code>fopen(PREFIX &quot;/x&quot;, &quot;r&quot;)</code>, stay intact.</p>\n<h2 id=\"deduplication\">Deduplication</h2>\n<p>Some package managers like Conda and Spack install packages into a padded prefix during their builds, with the idea that they can be “relocated” to a shorter prefix of the user&#39;s choice: the binaries are patched in-place. Conda uses a repeated string <code>_placehold</code> in a directory name to make the prefix long enough.</p>\n<p>Now, even if we pick a 256-byte path (a convenient multiple of all x86-64 register widths) by padding the path Conda-style</p>\n<pre><code>#define PREFIX &quot;/home/conda/feedstock_root/build_artifacts/&quot; \\\n               &quot;foo_1699999999999/_h_env&quot; \\\n               &quot;_placehold_placehold_placehold_placehold_placehold&quot; \\\n               &quot;_placehold_placehold_placehold_placehold_placehold&quot; \\\n               &quot;_placehold_placehold_placehold_placehold_placehold&quot; \\\n               &quot;_placehold_placehold_placehold_placeho/&quot;</code></pre>\n<p>and keep our fingers crossed that GCC puts the pieces of the path contiguously in the binary, we do <em>not</em> see our prefix back in the binary. What we get instead is a much shorter string of only 176 bytes (that is 11 times 16):</p>\n<pre><code>$ strings main | grep /home\n/home/conda/feedstock_root/build_artifacts/foo_1699999999999/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/</code></pre>\n<p>This is thanks to a further optimization: since the string <code>_placehold</code> repeats every 10 bytes, the 16-byte pieces repeat every <code>lcm(10, 16) = 80</code> bytes, and GCC needs to store only 5 distinct 16-byte constants for the padding:</p>\n<pre><code>/home/conda/feed\nstock_root/build\n_artifacts/foo_1\n699999999999/_h_\nenv_placehold_pl\nacehold_placehol  # note\nd_placehold_plac  # that\nehold_placehold_  # this\nplacehold_placeh  # is\nold_placehold_pl  # cyclic\nacehold_placeho/</code></pre>\n<h2 id=\"is-this-optimization-helpful\">Is this optimization helpful?</h2>\n<p>For string literals, I don&#39;t think so. Clang does not split strings into constants, yet it generates essentially the same instructions. For example, take a longer path, and target AVX2 with <code>-march=x86-64-v3</code>:</p>\n<pre><code>#define PREFIX &quot;/home/linuxbrew/.linuxbrew/Cellar/foo/1.2.3/share/foo&quot;</code></pre>\n<p>Clang simply puts the string in a section dedicated to strings, <code>.rodata.str1.1</code>:</p>\n<pre><code>.L.str:\n.asciz &quot;/home/linuxbrew/.linuxbrew/Cellar/foo/1.2.3/share/foo&quot;</code></pre>\n<p>and copies its 53 bytes with two overlapping 32-byte <code>ymm</code> loads and stores, at offsets 21 and 0:</p>\n<pre><code>vmovups ymm0, ymmword ptr [rip + .L.str+21]\nvmovups ymmword ptr [rax + 21], ymm0\nvmovups ymm0, ymmword ptr [rip + .L.str]\nvmovups ymmword ptr [rax], ymm0</code></pre>\n<p>That isn&#39;t particularly different from GCC&#39;s version, which loads the same two pieces from constants in <code>.rodata.cst32</code> instead:</p>\n<pre><code>vmovdqa ymm0, YMMWORD PTR .LC0[rip]\nvmovdqu YMMWORD PTR [rax], ymm0\nvmovdqa ymm0, YMMWORD PTR .LC1[rip]\nvmovdqu YMMWORD PTR 21[rax], ymm0</code></pre>\n<p>So what does GCC gain? In terms of performance, probably nothing measurable: both do the same loads and stores. With repeated pieces, GCC might have a slight edge, because a repeated piece is loaded once and stored multiple times (11 loads for 16 stores in the earlier example). It also uses aligned reads, but that matters only for ancient CPUs.</p>\n<p>In terms of size, GCC&#39;s pieces can take more space than the string itself: overlapping bytes are stored twice, and the pieces are aligned to 16, 32 or 64 bytes. The 53-byte path above takes 64 bytes as two pieces, against 54 bytes as a string. It only pays off if it results in deduplication, for example when many strings share a prefix of at least 16 bytes for SSE2, 32 bytes for AVX2, and 64 bytes for AVX-512. Presumably deduplication does not save much in practice, especially now that some distributions use AVX2 as their baseline.</p>\n<h2 id=\"can-i-disable-this-optimization\">Can I disable this optimization?</h2>\n<p>Other than compiling with <code>-Os</code>, not really. From GCC 10 onwards (maybe older versions too?) the split-into-pieces optimization triggers for strings up to 256 bytes even without specifying <code>-march</code>. From GCC 12 it is relative to the target&#39;s vector width, so longer strings get split too: up to 512 bytes for AVX2 and 1024 bytes for AVX-512.</p>\n<p>I believe the only control you have over this is setting the maximum vector width to 128 bits (forcing <code>xmm</code> operations), by passing <code>-mstore-max=128</code>. But this merely restores old defaults, and means strings of up to 256 bytes are still stored in pieces.</p>\n<h2 id=\"maybe-post-hoc-scanning-is-bad-practice\">Maybe post-hoc scanning is bad practice?</h2>\n<p>These post-build audits for absolute paths are popular, but you could argue that they are too brittle to start with, so why expect them to work at all?</p>\n<p>Indeed, Debian goes much further than a bad-path scan. Their audit asserts that a package can be rebuilt bit for bit in different circumstances: on a different machine, with a different user, time and date, hostname, locale, etc. That is a much more reliable way to keep machine-specific details out of binaries.<a href=\"#fn10\">[10]</a></p>\n<p>I would argue that, despite that, it is <em>still</em> useful to keep string constants literally in the binary, even on Debian, because it improves interpretability of binaries. Running <code>strings ./binary</code> is such a simple and convenient way to get insight into an opaque binary blob, that it outweighs the marginal savings that come with splitting and deduplication. It is reminiscent of Fedora and Ubuntu turning frame pointers back on by default, despite the small overhead, just to make profilers and tracing tools work more reliably.</p>\n<p>Other than that, there is the argument of binary patching, which — despite being considered somewhat brittle — is common practice in Conda and Spack: upon install to a user-specified location, the absolute paths are patched in-place accordingly, through what can be seen as a glorified <code>sed</code> invocation. This only works if the path is stored in one piece.</p>\n<hr />\n<p>If you&#39;d like to discuss this, a good place is the <a href=\"https://gcc.gnu.org/pipermail/gcc-patches/2026-November/738364.html\" rel=\"nofollow ugc noopener\">gcc-patches thread</a> that I started recently, with an initial attempt at a patch that adds a way to opt out.</p>\n<p><a href=\"#fnref1\">[1]</a> <a href=\"https://github.com/rpm-software-management/rpm/blob/4187d693cfd4704e3ffdf6483ea91a0d56134333/scripts/check-buildroot#L30-L42\" rel=\"nofollow ugc noopener\">RPM (Fedora, RHEL, openSUSE)</a>: <code>check-buildroot</code> greps every installed file for the build root.</p>\n<p><a href=\"#fnref2\">[2]</a> <a href=\"https://gitlab.archlinux.org/pacman/pacman/-/blob/a6f7467d8c7c4d7e9cc846884e74c0ab7215c48d/scripts/libmakepkg/lint_package/build_references.sh.in#L30-L41\" rel=\"nofollow ugc noopener\">Arch Linux</a>: <code>makepkg</code> warns about references to <code>$srcdir</code> and <code>$pkgdir</code>.</p>\n<p><a href=\"#fnref3\">[3]</a> <a href=\"https://git.openembedded.org/openembedded-core/tree/meta/classes-global/insane.bbclass?id=c2ea9568b768de7c479aba22f15520793a7dace4#n427\" rel=\"nofollow ugc noopener\">Yocto / OpenEmbedded</a>: the <code>buildpaths</code> QA check.</p>\n<p><a href=\"#fnref4\">[4]</a> <a href=\"https://github.com/freebsd/freebsd-ports/blob/7ea5a0ba45376d1ca480b274157370705d3d01b2/Mk/Scripts/qa.sh#L201-L223\" rel=\"nofollow ugc noopener\">FreeBSD ports</a>: the stage QA greps for the staging directory.</p>\n<p><a href=\"#fnref5\">[5]</a> <a href=\"https://github.com/NetBSD/pkgsrc/blob/e9b59cbd05f2c2ab1c37f8a8524bd38b1e256de8/mk/check/check-wrkref.mk#L90-L113\" rel=\"nofollow ugc noopener\">pkgsrc</a>: <code>CHECK_WRKREF</code>, off unless a package developer turns it on.</p>\n<p><a href=\"#fnref6\">[6]</a> <a href=\"https://github.com/Homebrew/brew/blob/8679d30f156018b0b184c64ab21a784f64b1d880/Library/Homebrew/keg_relocate.rb#L702-L775\" rel=\"nofollow ugc noopener\">Homebrew</a>: <code>brew bottle</code> scans for the prefix to decide whether a bottle is relocatable.</p>\n<p><a href=\"#fnref7\">[7]</a> <a href=\"https://github.com/conda/conda-build/blob/7dd6a86caf822254aac3217c5fded17cb915e004/conda_build/build.py#L1014-L1080\" rel=\"nofollow ugc noopener\">conda-build</a>: files containing the build prefix are listed in <code>info/has_prefix</code>, to be rewritten on install.</p>\n<p><a href=\"#fnref8\">[8]</a> <a href=\"https://github.com/prefix-dev/rattler-build/blob/0252f9ca2c5f8a9ab039b96ef09dc1d52d17de7d/crates/rattler_build_package/src/prefix/detector.rs#L15-L24\" rel=\"nofollow ugc noopener\">rattler-build</a>: the same scheme as conda-build, with <code>memmem</code>.</p>\n<p><a href=\"#fnref9\">[9]</a> <a href=\"https://github.com/JuliaPackaging/BinaryBuilder.jl/blob/d2b11c267ef8029af0f46a88b767246d7b9df1d1/src/auditor/filesystems.jl#L25-L45\" rel=\"nofollow ugc noopener\">Julia&#39;s BinaryBuilder</a>: <code>check_absolute_paths</code> warns about the build prefix in any file.</p>\n<p><a href=\"#fnref10\">[10]</a> Even Debian keeps one path fixed: since early 2024 both builds use the <a href=\"https://tests.reproducible-builds.org/debian/index_variations.html\" rel=\"nofollow ugc noopener\">same build directory</a>, because it is recorded in the <code>.buildinfo</code> file and reused when rebuilding. So a build path embedded in a binary goes unnoticed there too.</p>","headings":[{"level":1,"text":"Paths in pieces","id":"paths-in-pieces"},{"level":2,"text":"Basic example","id":"basic-example"},{"level":2,"text":"Store by pieces","id":"store-by-pieces"},{"level":2,"text":"Deduplication","id":"deduplication"},{"level":2,"text":"Is this optimization helpful?","id":"is-this-optimization-helpful"},{"level":2,"text":"Can I disable this optimization?","id":"can-i-disable-this-optimization"},{"level":2,"text":"Maybe post-hoc scanning is bad practice?","id":"maybe-post-hoc-scanning-is-bad-practice"}]}}