{
 "number": 36709,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36709",
 "title": "guix: compute --build triplet when lowering, not at load time",
 "author": "jespada",
 "author_association": "FIRST_TIME_CONTRIBUTOR",
 "created_at": "2026-10-30T14:53:45Z",
 "updated_at": "2026-10-30T15:38:55Z",
 "description_hash": "28907c8061ce9f21",
 "age_days": 2,
 "draft": false,
 "labels": [
  "Build system"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "1ea9ffd556e5d9576b5226239e0eceacb516bc82",
 "head_ref": "guix-building-on-system",
 "head_repo": "jespada/bitcoin",
 "head_history": [],
 "additions": 4,
 "deletions": 4,
 "changed_files": 1,
 "commit_count": 1,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "concept_ack": [
     {
      "login": "hebasto",
      "url": "https://github.com/bitcoin/bitcoin/pull/36709#pullrequestreview-5714645723"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "hebasto": {
   "kind": "concept_ack",
   "hash": null,
   "t": "2026-10-30T15:33:03Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 1,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "hebasto",
   "sedited"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-30T15:38:55Z",
  "last_reviewer_activity": "2026-10-30T15:33:03Z",
  "last_reviewer": "hebasto",
  "author_silent_days": 2,
  "waiting_on_author_days": 0,
  "days_since_update": 2
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "### Why\n\n`building-on` in `contrib/guix/toolchains.scm` reads `(%current-system)` once, when the module is loaded. `guix shell` loads the manifest before it applies `--system`, so the value is the system of the machine that runs the build, not the system that Guix builds for.\n\nSo a build with `ADDITIONAL_GUIX_ENVIRONMENT_FLAGS=\"--system=aarch64-linux\"` on an x86_64 machine (for example with `qemu-binfmt-service-type`, to get an aarch64 build machine) configures the aarch64 cross toolchain with `--build=x86_64-guix-linux-gnu`. `gcc-cross-sans-libc` then fails to configure:\n\n```\nchecking for CET support... configure: error: compiler and assembler with CET support are required for --enable-cet\n```\n\n### What changes\n\n`building-on` becomes a procedure, and its three call sites call it. Guix then computes the triplet for each derivation, under the system that the derivation is built for.\n\n### How I checked\n\n- On master, `HOST=x86_64-linux-gnu guix shell -n --system=aarch64-linux -m contrib/guix/linux_static.scm` (with `toolchains.scm` on the load path, as `guix-build` does) gives `gcc-cross-sans-libc` with `--build=x86_64-guix-linux-gnu`. With this PR it gives `--build=aarch64-guix-linux-gnu`. That is the same derivation that `guix build -d --system=aarch64-linux` gives on master.\n- Native builds (no `--system`): the toolchain derivations from `linux_static.scm` and `manifest_gui.scm` are identical on master and with this PR. So this PR does not change release builds.\n- With this PR, an emulated aarch64 build of `x86_64-linux-gnu` on x86_64 built the whole cross toolchain and the non-GUI binaries. The GUI environment then failed in the tests of `python-pylint` (timeout under emulation) and `maturin` (snapshot mismatch). These packages have no aarch64 substitutes at the pinned Guix commit, and the failures are not related to this change.",
 "commits": [
  {
   "sha": "1ea9ffd556e5d9576b5226239e0eceacb516bc82",
   "date": "2026-10-30T11:56:46Z",
   "message": "guix: compute --build triplet when lowering, not at load time\n\nbuilding-on read %current-system when toolchains.scm was loaded. guix\nshell loads the manifest before it applies --system, so a\n--system=aarch64-linux build on an x86_64 machine configured the aarch64\ntoolchain with --build=x86_64-guix-linux-gnu, and gcc-cross failed to\nconfigure. Make building-on a procedure so each derivation uses its own\nsystem. Native builds produce the same derivations as before."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-30T15:24:48Z",
   "kind": "comment",
   "who": "sedited",
   "assoc": "MEMBER",
   "text": "How and why did you run into this?",
   "id": "c:6526424366",
   "url": "https://github.com/bitcoin/bitcoin/pull/36709#issuecomment-6526424366",
   "hash": "bee3ffc2f4026063",
   "edited": null
  },
  {
   "t": "2026-10-30T15:33:03Z",
   "kind": "review",
   "who": "hebasto",
   "assoc": "MEMBER",
   "state": "COMMENTED",
   "commit": "1ea9ffd556e5d9576b5226239e0eceacb516bc82",
   "text": "Concept ACK.",
   "id": "r:5714645723",
   "url": "https://github.com/bitcoin/bitcoin/pull/36709#pullrequestreview-5714645723",
   "hash": "39bcd188b11b7a83",
   "edited": "2026-10-30T15:33:04Z"
  },
  {
   "t": "2026-10-30T15:38:55Z",
   "kind": "comment",
   "who": "jespada",
   "assoc": "NONE",
   "text": "[quoted text omitted]\n\nI hit it while trying to build https://github.com/bitcoin/bitcoin/pull/36708 with an aarch64 build machine (QEMU binfmt emulation on an x86_64 box, via ADDITIONAL_GUIX_ENVIRONMENT_FLAGS=\"--system=aarch64-linux\"), to check that the build is reproducible across build architectures. I have a Guix box so I was looking for Guix issues to help with.",
   "id": "c:6526771255",
   "url": "https://github.com/bitcoin/bitcoin/pull/36709#issuecomment-6526771255",
   "hash": "7418705541e0082c",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-30T14:53:51Z",
   "action": "labeled",
   "label": "Build system",
   "who": "DrahtBot"
  }
 ],
 "state_log": [
  {
   "t": "2026-10-30T14:57:06Z",
   "kind": "ready_for_review",
   "who": "jespada"
  }
 ],
 "text_chars": 2808,
 "text_tokens_estimate": 702,
 "changed_paths": [
  "contrib/guix/toolchains.scm"
 ],
 "files": [
  {
   "path": "contrib/guix/toolchains.scm",
   "add": 4,
   "del": 4
  }
 ],
 "test_lines": 8,
 "git": {
  "head": "1ea9ffd556e5d9576b5226239e0eceacb516bc82",
  "head_matches_backup": true,
  "base": "363d9e9d38154b7dced1767e996f8f18f391fcff",
  "patch_id": "319c2df4801f69bb",
  "commits": [
   {
    "sha": "1ea9ffd556",
    "subject": "guix: compute --build triplet when lowering, not at load time",
    "files": 1,
    "add": 4,
    "del": 4
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "319c2df4801f69bb",
 "input_hash": "309cceee638384ce",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}