<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/default.xsl"?>
<fr:tree xmlns:fr="http://www.forester-notes.org" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" root="false" base-url="/">
  <fr:frontmatter>
    <fr:authors>
      <fr:author>
        <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
      </fr:author>
    </fr:authors>
    <fr:date>
      <fr:year>2019</fr:year>
      <fr:month>11</fr:month>
      <fr:day>10</fr:day>
    </fr:date>
    <fr:date>
      <fr:year>2025</fr:year>
      <fr:month>8</fr:month>
      <fr:day>11</fr:day>
    </fr:date>
    <fr:uri>https://xw.is/binutils-build/</fr:uri>
    <fr:display-uri>binutils-build</fr:display-uri>
    <fr:route>/binutils-build/</fr:route>
    <fr:title text="Toolchains › Build GNU Binutils"><fr:link href="/toolchain-index/" title="Toolchains" uri="https://xw.is/toolchain-index/" display-uri="toolchain-index" type="local">Toolchains</fr:link> › Build <fr:link href="/binutils/" title="GNU Binutils" uri="https://xw.is/binutils/" display-uri="binutils" type="local">GNU Binutils</fr:link></fr:title>
  </fr:frontmatter>
  <fr:mainmatter>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2019</fr:year>
          <fr:month>11</fr:month>
          <fr:day>10</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>11</fr:day>
        </fr:date>
        <fr:title text="Create source and build directories">Create source and build directories</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>We use a suffix for the build directories so we can build for multiple targets at the same time. The name is arbitrary, we just choose the target name for convenience.</html:p>
        <html:pre>
mkdir -p ${HOME}/src
mkdir -p ${HOME}/obj/binutils-2.45-riscv64-unknown-elf</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2019</fr:year>
          <fr:month>11</fr:month>
          <fr:day>10</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>11</fr:day>
        </fr:date>
        <fr:title text="Download the source code">Download the source code</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:pre>curl https://sourceware.org/pub/binutils/releases/binutils-2.45.tar.xz | tar -C $HOME/src -xJf -</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2019</fr:year>
          <fr:month>11</fr:month>
          <fr:day>10</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>11</fr:day>
        </fr:date>
        <fr:title text="Build and install">Build and install</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>Set <html:code>--target</html:code> to your desired platform, here we use <html:code>riscv64-unknown-elf</html:code> representing bare-metal 64-bit <fr:link href="https://riscv.org/" type="external">RISC-V</fr:link>. It is fine for multiple cross toolchains to share the same <html:code>--prefix</html:code> and <html:code>--bindir</html:code>.</html:p>
        <html:pre>
cd ${HOME}/obj/binutils-2.45-riscv64-unknown-elf
../../src/binutils-2.45/configure --prefix ${HOME}/cross --with-system-zlib --target riscv64-unknown-elf 
make -j12 &amp;&amp; make install</html:pre>
      </fr:mainmatter>
    </fr:tree>
  </fr:mainmatter>
  <fr:backmatter>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="References">References</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Context">Context</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Backlinks">Backlinks</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Related">Related</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://xw.is/binutils/</fr:uri>
            <fr:display-uri>binutils</fr:display-uri>
            <fr:route>/binutils/</fr:route>
            <fr:title text="GNU Binutils">GNU Binutils</fr:title>
            <fr:taxon>Software</fr:taxon>
            <fr:meta name="external">https://www.gnu.org/software/binutils/</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Collection of low-level binary tools such as linkers and assemblers.</html:p>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Contributions">Contributions</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
  </fr:backmatter>
</fr:tree>
