{"slug":"cross-gcc","title":"cross-gcc","summary":"Use when compiling for ARM, AArch64, RISC-V, or MIPS from x86-64 with a GCC cross toolchain: triplets, sysroots, pkg-config, CMake toolchain files, QEMU. Not for Zig: use zig-cross.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-30T19:50:11.620244Z","repo":{"url":"https://github.com/OutlineDriven/outline-driven-development","stars":54,"forks":10,"license":"Apache-2.0","updatedAt":"2026-09-28T03:16:21Z"},"bodyHtml":"<hr>\n<h2>name: cross-gcc\ndescription: 'Use when compiling for ARM, AArch64, RISC-V, or MIPS from x86-64 with a GCC cross toolchain: triplets, sysroots, pkg-config, CMake toolchain files, QEMU. Not for Zig: use zig-cross.'</h2>\n<h1>Cross-compilation with GCC</h1>\n<h2>Contract</h2>\n<table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Bound contract</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Trigger</td>\n<td>The user needs to build for a different architecture with a <code>&lt;triplet&gt;-gcc</code> toolchain, gets <code>Exec format error</code> or <code>wrong ELF class</code>, finds host libraries leaking into a cross link, or wants to run and debug a cross-built binary under QEMU.</td>\n</tr>\n<tr>\n<td>Authority</td>\n<td>Read-only. The skill emits install commands, compiler invocations, environment settings, and a toolchain file to chat; the user runs them. Rollback is not needed. No remote mutation.</td>\n</tr>\n<tr>\n<td>Side effect</td>\n<td>Chat output. Confirmation compiles run on scratch files.</td>\n</tr>\n<tr>\n<td>Done</td>\n<td>The triplet, toolchain, sysroot, and build-system wiring are stated for the target, every flag is confirmed against the GCC target-options documentation or the installed cross compiler, and each error in the request has a cause and fix.</td>\n</tr>\n</tbody>\n</table>\n<h2>Inputs</h2>\n<ul>\n<li>Target: required. Architecture, OS or bare metal, ABI, and CPU when known.</li>\n<li>Host distribution: required for install commands; the package names below are Debian and Ubuntu names.</li>\n<li>Whether the program links target libraries beyond libc: required; decides whether a sysroot is needed.</li>\n<li>Build system: required. Plain compiler, Make, autoconf, or CMake.</li>\n<li>GCC line of the cross compiler, from <code>&lt;triplet&gt;-gcc --version</code>: required. Current stable is GCC 16.2; distribution cross packages often lag.</li>\n</ul>\n<h2>Procedure</h2>\n<ol>\n<li><p>Choose the triplet <code>&lt;arch&gt;-&lt;vendor&gt;-&lt;os&gt;-&lt;abi&gt;</code>, three or four parts. Common values: <code>aarch64-linux-gnu</code> (64-bit ARM, glibc), <code>arm-linux-gnueabihf</code> (32-bit ARM, hard float), <code>arm-none-eabi</code> (bare-metal ARM), <code>riscv64-linux-gnu</code>, <code>mipsel-linux-gnu</code>, <code>x86_64-w64-mingw32</code> (Windows from Linux). Done when: one triplet is chosen.</p>\n</li>\n<li><p>Install and confirm the toolchain. Debian and Ubuntu: <code>apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu</code>; bare-metal ARM: <code>apt install gcc-arm-none-eabi</code>. Confirm with <code>aarch64-linux-gnu-gcc --version</code>. Done when: the compiler prints its version.</p>\n</li>\n<li><p>Compile. Hosted: <code>aarch64-linux-gnu-gcc -O2 -o hello hello.c</code>, <code>aarch64-linux-gnu-g++ -O2 -std=c++20 -o hello hello.cpp</code>. Bare-metal Cortex-M4: <code>arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffreestanding -nostdlib -nostartfiles -T linker.ld -o firmware.elf startup.s main.c</code>. Target flags from the reference: <code>-march</code>, <code>-mcpu</code>, <code>-mthumb</code>, <code>-mfloat-abi=soft|softfp|hard</code>, <code>-mfpu</code>, and for AArch64 <code>-moutline-atomics</code>; RISC-V uses <code>-march=rv64gc -mabi=lp64d</code> style ISA strings. Done when: the compile command names the CPU and ABI.</p>\n</li>\n<li><p>Add a sysroot when the program links target libraries: <code>--sysroot=/path/to/sysroot</code> on every compile and link. Sources: a vendor image, <code>debootstrap --arch arm64 &lt;suite&gt; &lt;dir&gt;</code> for Debian, or the Yocto or Buildroot output tree. Confirm with <code>aarch64-linux-gnu-gcc --sysroot=&lt;dir&gt; -v -E - &lt; /dev/null 2&gt;&amp;1 | grep sysroot</code>. Done when: the sysroot path appears in the compiler's verbose output.</p>\n</li>\n<li><p>Redirect pkg-config, which returns host paths by default: <code>export PKG_CONFIG_SYSROOT_DIR=&lt;sysroot&gt;</code>, <code>export PKG_CONFIG_LIBDIR=$PKG_CONFIG_SYSROOT_DIR/usr/lib/aarch64-linux-gnu/pkgconfig:$PKG_CONFIG_SYSROOT_DIR/usr/share/pkgconfig</code>, <code>export PKG_CONFIG_PATH=</code>. Check with <code>pkg-config --libs &lt;lib&gt;</code>. Done when: the printed paths are under the sysroot.</p>\n</li>\n<li><p>Wire the build system. Environment for Make and autoconf: <code>CC</code>, <code>CXX</code>, <code>AR</code>, <code>STRIP</code>, <code>OBJDUMP</code> set to the triplet-prefixed tools, and <code>./configure --host=aarch64-linux-gnu</code>. CMake toolchain file:</p>\n<pre><code>set(CMAKE_SYSTEM_NAME Linux)\nset(CMAKE_SYSTEM_PROCESSOR aarch64)\nset(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)\nset(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)\nset(CMAKE_SYSROOT /path/to/sysroot)\nset(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\nset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nset(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n</code></pre>\n<p>Configure with <code>cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=aarch64.cmake</code>. Done when: the build system resolves the cross compiler and searches only the sysroot for libraries.</p>\n</li>\n<li><p>Run under QEMU user mode: <code>apt install qemu-user-static</code>, then <code>qemu-aarch64-static ./hello</code>; with binfmt_misc registered the binary runs directly. Debug: <code>qemu-aarch64-static -g 1234 ./hello &amp;</code> then <code>aarch64-linux-gnu-gdb -ex \"target remote :1234\" ./hello</code>. Done when: the binary runs or the debugger attaches.</p>\n</li>\n<li><p>Map errors from the table. Done when: each reported error has a cause and fix.</p>\n<table>\n<thead>\n<tr>\n<th>Error</th>\n<th>Cause</th>\n<th>Fix</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>cannot execute binary file: Exec format error</code></td>\n<td>Target binary run on the host</td>\n<td>Run under <code>qemu-&lt;arch&gt;-static</code></td>\n</tr>\n<tr>\n<td><code>wrong ELF class: ELFCLASS64</code> (or 32)</td>\n<td>Object from another architecture in the link</td>\n<td>One toolchain for every object; check <code>AR</code> and <code>CC</code></td>\n</tr>\n<tr>\n<td><code>ld: cannot find -lfoo</code></td>\n<td>Host library path used in a cross link</td>\n<td>Set <code>--sysroot</code>; fix <code>PKG_CONFIG_LIBDIR</code></td>\n</tr>\n<tr>\n<td><code>undefined reference to '__aeabi_*'</code></td>\n<td>ARM runtime helpers missing from a <code>-nostdlib</code> link</td>\n<td>Add <code>-lgcc</code></td>\n</tr>\n<tr>\n<td><code>relocation ... out of range</code></td>\n<td>Code or data too far apart for the relocation</td>\n<td><code>-mcmodel=large</code> or restructure</td>\n</tr>\n<tr>\n<td><code>unrecognized opcode</code></td>\n<td><code>-mcpu</code> or <code>-march</code> does not match the source</td>\n<td>Set the CPU flags for the real target</td>\n</tr>\n</tbody>\n</table>\n</li>\n</ol>\n<h2>Failure and recovery</h2>\n<table>\n<thead>\n<tr>\n<th>Failure class</th>\n<th>Behavior</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>No distribution package for the target</td>\n<td>Point to the vendor toolchain download; do not invent a package name.</td>\n</tr>\n<tr>\n<td>Sysroot lacks a needed library</td>\n<td>Report the library as missing from the sysroot; the fix is to install it into the sysroot, not to use the host copy.</td>\n</tr>\n<tr>\n<td>Windows target requested</td>\n<td>Use the <code>x86_64-w64-mingw32</code> triplet; MSVC-flavored builds: use msvc-cl.</td>\n</tr>\n<tr>\n<td>No system cross toolchain wanted</td>\n<td><code>zig cc -target</code> cross-compiles C without one: use zig-cross.</td>\n</tr>\n<tr>\n<td>Assembly-level question</td>\n<td>AArch64 or ARM assembly: use assembly-arm.</td>\n</tr>\n</tbody>\n</table>\n<h2>Output</h2>\n<p>A chat report with the triplet, install and confirmation commands, the compile command with target flags, sysroot and pkg-config settings when needed, the build-system wiring, the QEMU run or debug command, and the error table entries that apply. Flag details are in <code>references/arm-flags.md</code>.</p>\n","files":[{"path":"agents/openai.yaml","sizeBytes":216,"isText":true},{"path":"references/arm-flags.md","sizeBytes":2379,"isText":true},{"path":"SKILL.md","sizeBytes":6368,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-30T19:52:47.632584Z","sha256":"1513121CCD44A4DA0BC8F2320EA9E9C552B89FFA2EAF805AFC20AF7BD32E0C60","sizeBytes":4405},"review":null,"source":{"repositoryUrl":"https://github.com/OutlineDriven/outline-driven-development","path":".devin/skills/cross-gcc","license":"Apache-2.0","commit":"b0e8ce89a19fac880251dc3ea1babfeb4503a4fe","subtreeSha":"3CED6034F4A7C368978B9D800EBD717FDF8D1B8D7CEA38AA60657C91F9A46137","lastSyncedAt":"2026-09-30T19:49:48.917811Z"},"reviewedAt":"2026-09-30T19:57:58.062958Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/OutlineDriven/outline-driven-development/tree/main/.devin/skills/cross-gcc"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install outlinedriven-outline-driven-development@llmmart"},{"target":"git","command":"git clone https://github.com/OutlineDriven/outline-driven-development.git"}]}