<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://yashbhiwania.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://yashbhiwania.github.io/" rel="alternate" type="text/html" /><updated>2026-08-26T22:49:45+00:00</updated><id>https://yashbhiwania.github.io/feed.xml</id><title type="html">Yash Bhiwania</title><subtitle>Systems programming, embedded development, and my GSoC 2026 journey with the RTEMS Project.</subtitle><author><name>Yash Bhiwania</name></author><entry><title type="html">GSoC 2026 Final Report: Securing the RTEMS Toolchain with C11 Annex K &amp;amp; Multilib Support</title><link href="https://yashbhiwania.github.io/gsoc/rtems/c11/2026/08/18/gsoc-final-report.html" rel="alternate" type="text/html" title="GSoC 2026 Final Report: Securing the RTEMS Toolchain with C11 Annex K &amp;amp; Multilib Support" /><published>2026-08-18T11:45:00+00:00</published><updated>2026-08-18T11:45:00+00:00</updated><id>https://yashbhiwania.github.io/gsoc/rtems/c11/2026/08/18/gsoc-final-report</id><content type="html" xml:base="https://yashbhiwania.github.io/gsoc/rtems/c11/2026/08/18/gsoc-final-report.html"><![CDATA[<table>
  <tbody>
    <tr>
      <td><strong>Author:</strong> Yash Bhiwania</td>
      <td><strong>Organization:</strong> RTEMS Project</td>
      <td><strong>Mentors:</strong> Joel Sherrill, Wayne Thornton</td>
    </tr>
  </tbody>
</table>

<p><img width="846" height="427" alt="Screenshot 2026-08-19 004006" src="https://github.com/user-attachments/assets/714fb694-f6af-4745-8276-e2c2073d6a37" /></p>

<p>As a 3rd-year B.Tech student in Communication and Computer Engineering at LNMIIT Jaipur, my Google Summer of Code (GSoC) 2026 journey with the RTEMS Project has officially reached the finish line. RTEMS is a Real-Time Operating System (RTOS) that powers safety-critical embedded systems like spacecraft, medical devices, and automotive controllers.</p>

<p>Because RTEMS uses Newlib as its standard C library, which lacks the C11 Annex K standard, RTEMS developers have historically had no standard way to use bounds-checked string and memory functions. My project bridged this gap by packaging the MIT-licensed <code class="language-plaintext highlighter-rouge">safeclib</code> library into the RTEMS Source Builder (RSB), giving embedded developers secure alternatives like <code class="language-plaintext highlighter-rouge">memcpy_s</code> and <code class="language-plaintext highlighter-rouge">sprintf_s</code>.</p>

<hr />

<h2 id="part-1-the-executive-summary-gsoc-submission">Part 1: The Executive Summary (GSoC Submission)</h2>

<ul>
  <li><strong>Project Goal:</strong> Bring C11 Annex K bounds-checking functions to the RTEMS toolchain via <code class="language-plaintext highlighter-rouge">safeclib</code> integration.</li>
  <li><strong>What I Did:</strong> I engineered the cross-compilation recipe for <code class="language-plaintext highlighter-rouge">safeclib</code> within the RSB, solved configure-time linker failures on bare-metal targets, wrapped the test suite in RTEMS standard tasks, and successfully built multilib support.</li>
  <li><strong>Current State:</strong> The core RSB integration for per-BSP builds is complete and in active upstream review.
    <h3 id="what-code-got-mergedsubmitted">What Code Got Merged/Submitted:</h3>
  </li>
  <li><strong>Core RSB Recipe Integration:</strong> <a href="https://gitlab.rtems.org/rtems/tools/rtems-source-builder/-/merge_requests/287">RSB Merge Request !287</a>
    <ul>
      <li><em>Description:</em> RSB cross-compilation recipe for <code class="language-plaintext highlighter-rouge">safeclib</code>, refined with modular configs and base64 hashes based on maintainer feedback.</li>
    </ul>
  </li>
  <li><strong>Upstream Test Suite Submission:</strong> <a href="https://github.com/rurban/safeclib/pull/172">Safeclib Pull Request #172</a>
    <ul>
      <li><em>Description:</em> Submitted the pure C Annex K edge-case test suite (<code class="language-plaintext highlighter-rouge">test_baremetal_edges.c</code>) upstream.</li>
    </ul>
  </li>
  <li><strong>Upstream Feature Request:</strong> <a href="https://github.com/rurban/safeclib/issues/171">Safeclib Issue #171</a>
    <ul>
      <li><em>Description:</em> Opened an upstream issue requesting a proper <code class="language-plaintext highlighter-rouge">--disable-tests</code> configuration flag.</li>
    </ul>
  </li>
  <li><strong>RTEMS Workaround Tracking:</strong> <a href="https://gitlab.rtems.org/rtems/tools/rtems-source-builder/-/work_items/209">RTEMS Tools Work Item #209</a>
    <ul>
      <li><em>Description:</em> Tracked the temporary <code class="language-plaintext highlighter-rouge">sed</code> Makefile workaround until the upstream issue is resolved.</li>
    </ul>
  </li>
  <li><strong>POSIX Compliance Tracking:</strong> <a href="https://gitlab.rtems.org/rtems/tools/rtems-source-builder/-/work_items/156">RTEMS Work Item #156</a>
    <ul>
      <li><em>Description:</em> Mapped and documented C11 Annex K functions into the RTEMS compliance master spreadsheet.</li>
    </ul>
  </li>
  <li><strong>What’s Left To Do:</strong> Once MR !287 establishes the baseline, I will push the multilib code upstream, update the RTEMS 7 Release Notes, and publish a Developer Wiki Guide.</li>
</ul>

<hr />

<h2 id="part-2-the-deep-technical-dive">Part 2: The Deep Technical Dive</h2>

<p>For developers and engineers curious about the intricacies of cross-compiling standard libraries for bare-metal targets, here is a breakdown of the core technical challenges I solved this summer.</p>

<h3 id="1-upstream-contributions-pre-gsoc">1. Upstream Contributions (Pre-GSoC)</h3>

<p>Before the GSoC coding period even began, I analyzed the <code class="language-plaintext highlighter-rouge">safeclib</code> source code and identified several portability blockers. I worked directly with the upstream maintainer (Reini Urban) to get several fixes merged upstream:</p>

<ul>
  <li><strong>PR #152 &amp; #153:</strong> Fixed missing labels and <code class="language-plaintext highlighter-rouge">-Wunused-variable</code> compiler errors that caused <code class="language-plaintext highlighter-rouge">-Werror</code> failures on RTEMS bare-metal targets.</li>
  <li><strong>The <code class="language-plaintext highlighter-rouge">isinfl()</code> Portability Issue:</strong> <code class="language-plaintext highlighter-rouge">safeclib</code> relies on <code class="language-plaintext highlighter-rouge">isinfl()</code>, which Newlib only provides under specific Cygwin macros. I proposed a tiered fallback strategy (PR #154) which led to the upstream implementation of a robust <code class="language-plaintext highlighter-rouge">isinf</code> fallback.</li>
</ul>

<h3 id="2-the-linker--cross-compilation-puzzle">2. The Linker &amp; Cross-Compilation Puzzle</h3>

<p>When building libraries with <code class="language-plaintext highlighter-rouge">autotools</code> for bare-metal systems, configure-time link tests routinely fail because there is no standard OS environment (like a default <code class="language-plaintext highlighter-rouge">main()</code> or POSIX I/O).</p>

<p>Initially, I attempted to force the linker to succeed by injecting a pre-compiled <code class="language-plaintext highlighter-rouge">rtems_config.o</code> object file. However, after architectural discussions with my mentors, I implemented the correct, robust solution: utilizing <code class="language-plaintext highlighter-rouge">pkg-config</code> to fetch BSP-specific flags and linking against <code class="language-plaintext highlighter-rouge">librtemsdefaultconfig.a</code>. This allowed the <code class="language-plaintext highlighter-rouge">configure</code> script to correctly evaluate the environment without artificial scaffolding.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>build: safeclib-3.9.1-x86_64-linux-gnu-1
install: safeclib-3.9.1-x86_64-linux-gnu-1
cleaning: safeclib-3.9.1-x86_64-linux-gnu-1
Build Set: Time 0:02:14.453210
Build Set: Time 0:02:28.109432
Packages: 1
Sizes: 1.2MB
Installed: 1
==&gt; build successfully: 7/devel/safeclib
</code></pre></div></div>

<h3 id="3-bare-metal-test-scaffolding">3. Bare-Metal Test Scaffolding</h3>

<p><code class="language-plaintext highlighter-rouge">safeclib</code> ships with approximately 126 tests. On Linux, these just run. On RTEMS, a bare-metal environment has no concept of a standalone executable starting from <code class="language-plaintext highlighter-rouge">main()</code>.</p>

<p>I had to manually wrap the test suite within minimal RTEMS applications—specifically, injecting an Init task and a configuration table into each test. I cross-compiled these for <code class="language-plaintext highlighter-rouge">sparc-rtems7</code> and ran them under QEMU SPARC emulation, strictly documenting the results (PASS, FAIL, or SKIP for tests requiring unavailable resources like signals).</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>*** BEGIN OF TEST SAFECLIB MEMCPY_S ***
*** TEST VERSION: 7.0.0.db2a265691d1e4347715fba394f4ed81eb
*** TEST STATE: EXPECTED_PASS
*** TEST BUILD: RTEMS_POSIX_API
*** TEST TOOLS: 13.2.0 20230727 (RTEMS 7, RSB d5d9d1a4470134ea9292514c)

Testing memcpy_s()...
PASS: memcpy_s(dest, dmax, src, smax) with valid inputs
PASS: memcpy_s(dest, dmax, NULL, smax) returns ESNULLP
PASS: memcpy_s(NULL, dmax, src, smax) returns ESNULLP
PASS: memcpy_s(dest, 0, src, smax) returns ESZEROL
PASS: memcpy_s(dest, dmax, src, smax) where dmax &lt; smax returns ESLEMAX

All 24 test cases passed successfully.

*** END OF TEST SAFECLIB MEMCPY_S ***
</code></pre></div></div>

<h3 id="4-above--beyond-the-multilib-loop-challenge">4. Above &amp; Beyond: The Multilib Loop Challenge</h3>

<p>My original proposal listed “multilib integration” as a future improvement. I tackled it early. True multilib support means building the library for every supported ABI variant of an architecture simultaneously.</p>

<p>To achieve this, I wrote a custom shell loop in the <code class="language-plaintext highlighter-rouge">%build</code> phase of the RSB recipe that parses <code class="language-plaintext highlighter-rouge">gcc --print-multi-lib</code>. The hardest bug here involved nested architecture directories (like <code class="language-plaintext highlighter-rouge">leon3/gr712rc</code>). Standard relative pathing to <code class="language-plaintext highlighter-rouge">../configure</code> crashed because the depth was variable. I engineered a fix by caching the absolute root path:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Caching the absolute top-level directory to handle nested multilib variants</span>
<span class="nv">build_top</span><span class="o">=</span><span class="si">$(</span><span class="nb">pwd</span><span class="si">)</span>

<span class="c"># Iterate through all architecture variants</span>
<span class="k">for </span>i <span class="k">in</span> <span class="si">$(</span>gcc <span class="nt">--print-multi-lib</span><span class="si">)</span><span class="p">;</span> <span class="k">do
  </span><span class="nv">variant</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nv">$i</span> | <span class="nb">sed</span> <span class="nt">-e</span> <span class="s1">'s/;.*//'</span><span class="si">)</span>
  <span class="nb">mkdir</span> <span class="nt">-p</span> <span class="nv">$variant</span>
  <span class="nb">cd</span> <span class="nv">$variant</span>

  <span class="c"># Inject the absolute path to solve nested directory crashes</span>
  <span class="k">${</span><span class="nv">build_top</span><span class="k">}</span>/configure <span class="se">\</span>
    <span class="nt">--host</span><span class="o">=</span>%<span class="o">{</span>_host<span class="o">}</span> <span class="se">\</span>
    <span class="nt">--disable-shared</span> <span class="nt">--enable-static</span> <span class="se">\</span>
    <span class="nt">--disable-extensions</span> <span class="se">\</span>
    <span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BSP_CFLAGS</span><span class="k">}</span><span class="s2">"</span>

  make
  <span class="nb">cd</span> <span class="k">${</span><span class="nv">build_top</span><span class="k">}</span>
<span class="k">done</span>
</code></pre></div></div>

<p>This loop dynamically adapts to the depth of the variant’s folder, ensuring a stable multilib build across the entire RTEMS ecosystem.</p>

<h2 id="final-thoughts--acknowledgments">Final Thoughts &amp; Acknowledgments</h2>

<p>Working on RTEMS has fundamentally shifted how I view systems programming and OS architecture. I want to extend a massive thank you to my mentors, Joel Sherrill and Wayne Thornton, for their incredible guidance, architectural insights, and code reviews this summer. I also want to thank Reini Urban for his responsiveness upstream.</p>

<p>GSoC may be ending, but my work with RTEMS is not. I look forward to continuing as a maintainer for the safeclib integration and tackling more toolchain challenges in the future.</p>]]></content><author><name>Yash Bhiwania</name></author><category term="gsoc" /><category term="rtems" /><category term="c11" /><summary type="html"><![CDATA[Author: Yash Bhiwania Organization: RTEMS Project Mentors: Joel Sherrill, Wayne Thornton]]></summary></entry><entry><title type="html">Midterm Deliverable: Porting Safeclib to RTEMS, Multi-Arch Recipes, and SPARC Bug Hunting</title><link href="https://yashbhiwania.github.io/gsoc/rtems/2026/06/16/midterm-safeclib-rtems.html" rel="alternate" type="text/html" title="Midterm Deliverable: Porting Safeclib to RTEMS, Multi-Arch Recipes, and SPARC Bug Hunting" /><published>2026-06-16T00:00:00+00:00</published><updated>2026-06-16T00:00:00+00:00</updated><id>https://yashbhiwania.github.io/gsoc/rtems/2026/06/16/midterm-safeclib-rtems</id><content type="html" xml:base="https://yashbhiwania.github.io/gsoc/rtems/2026/06/16/midterm-safeclib-rtems.html"><![CDATA[<p>As part of my Google Summer of Code (GSoC) 2026 journey with the RTEMS Project, my midterm objective was clear: cross-compile the C11 Annex K Bounds Checking Library (<code class="language-plaintext highlighter-rouge">safeclib</code>) for RTEMS, seamlessly integrate it into the RTEMS Source Builder (RSB), and validate it on bare-metal architecture.</p>

<p>What sounded like a straightforward porting task quickly evolved into a deep dive into cross-compilation quirks, dynamic build configurations, and debugging strict-alignment hardware exceptions on the SPARC architecture.</p>

<p>In this post, I will break down exactly how I patched the library, conquered the RSB, and validated the test suite in the SPARC simulator, documenting every pitfall so future developers can navigate them easily.</p>

<h3 id="challenge-1-architecture-independence-the-patch">Challenge 1: Architecture Independence (The Patch)</h3>
<p>The first major hurdle was the “multilib” problem. The <code class="language-plaintext highlighter-rouge">safeclib</code> source code relied heavily on hardcoded compiler checks (like <code class="language-plaintext highlighter-rouge">sizeof(uint32_t)</code>) that inherently break when cross-compiling for different architectures.</p>

<p><strong>The Fix:</strong> I created a C patch to rip out those hardcoded checks and replace them with dynamic GCC macros (like <code class="language-plaintext highlighter-rouge">__SIZEOF_POINTER__</code>). This ensures the library is truly architecture-independent and adapts at compile-time to whatever target RTEMS requires.</p>

<h3 id="challenge-2-taming-the-build-system-the-rsb-recipe">Challenge 2: Taming the Build System (The RSB Recipe)</h3>
<p>Writing the RSB <code class="language-plaintext highlighter-rouge">.cfg</code> recipe required bypassing several unique build system bugs and bare-metal traps:</p>

<ol>
  <li><strong>The Git Extraction Bug:</strong> The RSB initially refused to clone the source properly. <strong>The Fix:</strong> I forced the RSB to unpack the code by explicitly appending <code class="language-plaintext highlighter-rouge">?checkout=master?pull=1</code> to the source URL.</li>
  <li><strong>The Symlink Bug:</strong> RSB had a hidden bug where it failed to define the source directory, breaking the build pipeline. <strong>The Fix:</strong> I bypassed this by manually injecting <code class="language-plaintext highlighter-rouge">source_dir_safeclib="rtems-safeclib"</code> into the <code class="language-plaintext highlighter-rouge">%prep</code> phase.</li>
  <li><strong>The Bare-Metal Compiler Trap:</strong> <code class="language-plaintext highlighter-rouge">safeclib</code> aggressively tried to enforce Linux-style Stack Smashing Protectors (<code class="language-plaintext highlighter-rouge">ssp.h</code>) and strict GCC warnings. <strong>The Fix:</strong> I injected custom bare-metal override flags (<code class="language-plaintext highlighter-rouge">-U_FORTIFY_SOURCE -fno-stack-protector -Wno-error</code>) into the <code class="language-plaintext highlighter-rouge">CFLAGS</code> during the <code class="language-plaintext highlighter-rouge">./configure</code> step.</li>
</ol>

<h3 id="challenge-3-dynamic-multi-architecture-support--linker-errors">Challenge 3: Dynamic Multi-Architecture Support &amp; Linker Errors</h3>
<p>To make the recipe robust for the RTEMS ecosystem, it needed to support cross-architecture builds out of the box (MR !269).</p>

<ol>
  <li><strong>Dynamic <code class="language-plaintext highlighter-rouge">pkg-config</code>:</strong> I replaced the hardcoded <code class="language-plaintext highlighter-rouge">rtems-bsps</code> placeholder with dynamic host/bsp extraction (<code class="language-plaintext highlighter-rouge">%{_host}-$(basename %{with_rtems_bsp})</code>) during the <code class="language-plaintext highlighter-rouge">%build</code> phase. This allows <code class="language-plaintext highlighter-rouge">pkg-config</code> to correctly extract compilation flags for <em>any</em> target architecture (SPARC, RISC-V, etc.).</li>
  <li><strong>Bypassing the Syslog Linker Error:</strong> On bare-metal targets, linking the performance tests failed entirely due to an undefined reference to <code class="language-plaintext highlighter-rouge">syslog</code>—a utility that simply doesn’t exist on these lightweight embedded targets. <strong>The Fix:</strong> I used <code class="language-plaintext highlighter-rouge">sed</code> to strip the <code class="language-plaintext highlighter-rouge">tests</code> directory from the generated Makefile targets. This prevented the broken test suite from interrupting the build while ensuring the core library, headers, and <code class="language-plaintext highlighter-rouge">.pc</code> files installed correctly.</li>
</ol>

<h3 id="the-first-milestone-minimal-proof-of-execution">The First Milestone: Minimal Proof of Execution</h3>
<p>With the library successfully building, the initial test was to link it against a basic bare-metal RTEMS application to verify the hooks.</p>

<p>I wrote a minimal RTEMS initialization task that invokes the <code class="language-plaintext highlighter-rouge">strcpy_s</code> (secure string copy) function from my newly compiled static library. Running it in the SPARC Instruction Simulator (<code class="language-plaintext highlighter-rouge">sparc-rtems7-sis</code>) yielded a clean execution:</p>

<p><img src="/assets/images/safeclib-hello-success.png" alt="Safeclib RTEMS Minimal Success" /></p>

<h3 id="the-final-boss-full-test-suite-validation">The Final Boss: Full Test Suite Validation</h3>
<p>With basic execution proven, the final step was running the entire <code class="language-plaintext highlighter-rouge">safeclib</code> test suite on the simulator. This is where the real bare-metal debugging began.</p>

<p>Initially, the test suite threw catastrophic OS-level crashes. I had to debug and apply two critical OS-level fixes to my RTEMS initialization task:</p>
<ol>
  <li><strong>FPU Exceptions (Code 38):</strong> The simulator was crashing due to illegal floating-point unit usage. <strong>The Fix:</strong> I injected the <code class="language-plaintext highlighter-rouge">RTEMS_FLOATING_POINT</code> attribute into the Init task.</li>
  <li><strong>File Descriptor Exhaustion:</strong> The library’s <code class="language-plaintext highlighter-rouge">fopen</code> tests were crashing the OS because RTEMS defaults to a highly restrictive file descriptor limit. <strong>The Fix:</strong> I bumped <code class="language-plaintext highlighter-rouge">CONFIGURE_MAXIMUM_FILE_DESCRIPTORS</code> up to 32.</li>
</ol>

<h3 id="the-result-116-pass-and-hardware-bug-hunting">The Result: 116 PASS and Hardware Bug Hunting</h3>
<p>Once the OS configurations were patched, the test suite results immediately jumped to <strong>116 PASS</strong>.</p>

<p><img src="/assets/images/safeclib-suite-results.png" alt="Safeclib RTEMS Full Test Suite Results" /></p>

<p>More importantly, clearing away the OS crashes isolated the remaining 15 Fails and 6 Timeouts (in functions like <code class="language-plaintext highlighter-rouge">test_memcpy32_s</code> and <code class="language-plaintext highlighter-rouge">test_mbstowcs_s</code>). As suspected, these are not OS errors, but genuine SPARC strict-alignment data access exceptions (Trap 9s) and infinite loops.</p>

<p>Standard x86 desktop processors often hide these memory alignment flaws, proving exactly why validating this library on strict bare-metal architectures like SPARC is so critical. I am currently documenting these isolated hardware traps to file as upstream bug reports to the <code class="language-plaintext highlighter-rouge">safeclib</code> maintainers.</p>

<p>With the library ported, dynamically compiling across architectures in the RSB, and the SPARC validation complete, my midterm deliverables are officially wrapped. Next up: building the <code class="language-plaintext highlighter-rouge">riscv-rtems7-gcc</code> toolchain and seeing how RISC-V handles these exact same memory alignment tests!</p>]]></content><author><name>Yash Bhiwania</name></author><category term="GSoC" /><category term="RTEMS" /><summary type="html"><![CDATA[As part of my Google Summer of Code (GSoC) 2026 journey with the RTEMS Project, my midterm objective was clear: cross-compile the C11 Annex K Bounds Checking Library (safeclib) for RTEMS, seamlessly integrate it into the RTEMS Source Builder (RSB), and validate it on bare-metal architecture.]]></summary></entry><entry><title type="html">Cross-Compiling C Libraries for Bare-Metal: Escaping the Autotools Trap</title><link href="https://yashbhiwania.github.io/gsoc/rtems/c/2026/05/29/cross-compiling-safeclib-rtems.html" rel="alternate" type="text/html" title="Cross-Compiling C Libraries for Bare-Metal: Escaping the Autotools Trap" /><published>2026-05-29T11:05:00+00:00</published><updated>2026-05-29T11:05:00+00:00</updated><id>https://yashbhiwania.github.io/gsoc/rtems/c/2026/05/29/cross-compiling-safeclib-rtems</id><content type="html" xml:base="https://yashbhiwania.github.io/gsoc/rtems/c/2026/05/29/cross-compiling-safeclib-rtems.html"><![CDATA[<h1 id="cross-compiling-c-libraries-for-bare-metal-escaping-the-autotools-ignore-trap">Cross-Compiling C Libraries for Bare-Metal: Escaping the Autotools “Ignore” Trap</h1>

<table>
  <tbody>
    <tr>
      <td><strong>By Yash Bhiwania</strong></td>
      <td>GSoC 2026 Contributor for RTEMS</td>
    </tr>
  </tbody>
</table>

<p>When porting a standard C library to a bare-metal embedded real-time operating system (RTOS) like RTEMS, you quickly learn that standard build tools make a lot of assumptions about your environment. Specifically, tools like Autoconf expect a standard POSIX-compliant OS to be sitting underneath them.</p>

<p>For my Google Summer of Code project, I am porting the <code class="language-plaintext highlighter-rouge">safeclib</code> library to RTEMS. Recently, I ran into a classic cross-compilation trap involving autoconf probes, linker errors, and the temptation to just “brute-force” the build.</p>

<p>Here is how I fell into the trap, and more importantly, the architectural pivot required to do it the “RTEMS way.”</p>

<h3 id="the-blindfold-method-ignoring-unresolved-symbols">The “Blindfold” Method: Ignoring Unresolved Symbols</h3>
<p>Initially, to get the autotools <code class="language-plaintext highlighter-rouge">./configure</code> script to pass its generic C compiler dummy test without failing on missing RTEMS scaffolding, I bypassed the linker errors using a brute-force flag:</p>

<p>LDFLAGS=”-Wl,–unresolved-symbols=ignore-all”</p>

<p>It worked… sort of. The build moved forward, but as my mentor pointed out, ignoring undefined symbols on an autoconf probe is a terrible idea. It effectively puts a blindfold on the compiler. It allows the autoconf probes to falsely report features as “present” (like <code class="language-plaintext highlighter-rouge">fork()</code> or <code class="language-plaintext highlighter-rouge">getpid()</code>) even when they are entirely missing from the bare-metal environment. This guarantees silent crashes down the line.</p>

<h3 id="the-pivot-linking-the-board-support-package-bsp">The Pivot: Linking the Board Support Package (BSP)</h3>
<p>To fix this, I dropped the <code class="language-plaintext highlighter-rouge">ignore-all</code> flag and decided to point the configuration script directly to the installed SPARC RTEMS7 BSP (<code class="language-plaintext highlighter-rouge">erc32</code>). This forces the script to look at the <em>actual</em> symbols available in the embedded environment.</p>

<p>export RTEMS_ROOT=$HOME/development/rtems/7/sparc-rtems7/erc32</p>

<p>./configure <br />
  –host=sparc-rtems7 <br />
  –prefix=$RTEMS_ROOT <br />
  –enable-static <br />
  –disable-shared <br />
  CC=”sparc-rtems7-gcc -qrtems -B$RTEMS_ROOT/lib/” <br />
  CPPFLAGS=”-I$RTEMS_ROOT/include”</p>

<h3 id="unveiling-the-true-linker-errors">Unveiling the True Linker Errors</h3>
<p>Once the blindfold was off, the script failed immediately on the very first probe: <code class="language-plaintext highlighter-rouge">checking whether the C compiler works... no</code>.</p>

<p>Digging into the <code class="language-plaintext highlighter-rouge">config.log</code>, I found the exact culprit. The RTEMS compiler was refusing to link the autoconf <code class="language-plaintext highlighter-rouge">conftest.c</code> dummy file, throwing these undefined references:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">_ISR_Stack_size</code></li>
  <li><code class="language-plaintext highlighter-rouge">_ISR_Stack_area_begin</code></li>
  <li><code class="language-plaintext highlighter-rouge">_Scheduler_Table</code></li>
  <li><code class="language-plaintext highlighter-rouge">_Thread_Information</code></li>
</ul>

<p><strong>The Aha Moment:</strong> These are not standard C library functions; they are RTEMS kernel configuration symbols! In RTEMS, an application requires a configuration block (typically via <code class="language-plaintext highlighter-rouge">&lt;rtems/confdefs.h&gt;</code>) to allocate memory for the scheduler, threads, and interrupts. Because the autotools dummy script is just an empty <code class="language-plaintext highlighter-rouge">int main()</code> without this header, the RTEMS linker panicked.</p>

<h3 id="the-path-forward">The Path Forward</h3>
<p>In cross-compilation, there are generally two professional ways to handle autoconf probes failing on bare-metal:</p>
<ol>
  <li><strong>Use a Dummy Config Library:</strong> RTEMS provides <code class="language-plaintext highlighter-rouge">librtemsdefaultconfig.a</code>, which defines stubs for these exact configuration macros to satisfy the linker during tests.</li>
  <li><strong>Hard-code the Variables:</strong> Bypass the executable tests entirely and manually inject a <code class="language-plaintext highlighter-rouge">config.site</code> file that tells the build system exactly which OS features are (and aren’t) available.</li>
</ol>

<p>I am currently discussing the best architectural approach with my mentors to integrate this cleanly into the RTEMS Source Builder (RSB).</p>

<p><em>If you want to follow along with the code, I am pushing all my Work-In-Progress (including some MSVC test stub adjustments) to my personal RTEMS GitLab fork here:</em> <a href="https://gitlab.rtems.org/Yash/rtems-safeclib">https://gitlab.rtems.org/Yash/rtems-safeclib</a></p>]]></content><author><name>Yash Bhiwania</name></author><category term="GSoC" /><category term="RTEMS" /><category term="C" /><category term="cross-compilation" /><category term="embedded" /><category term="autotools" /><summary type="html"><![CDATA[Cross-Compiling C Libraries for Bare-Metal: Escaping the Autotools “Ignore” Trap]]></summary></entry><entry><title type="html">GSoC 2026: Bringing Safe C to Space with RTEMS</title><link href="https://yashbhiwania.github.io/gsoc/rtems/2026/05/24/gsoc-rtems-kickoff.html" rel="alternate" type="text/html" title="GSoC 2026: Bringing Safe C to Space with RTEMS" /><published>2026-05-24T08:30:00+00:00</published><updated>2026-05-24T08:30:00+00:00</updated><id>https://yashbhiwania.github.io/gsoc/rtems/2026/05/24/gsoc-rtems-kickoff</id><content type="html" xml:base="https://yashbhiwania.github.io/gsoc/rtems/2026/05/24/gsoc-rtems-kickoff.html"><![CDATA[<p>Hello world! I am Yash, a 3rd-year B.Tech student in Communication and Computer Engineering. This summer, I am incredibly excited to announce that I will be participating in Google Summer of Code 2026 with the <strong>RTEMS Project</strong>.</p>

<p>For those who might not know, RTEMS is a real-time operating system that flies on ESA and NASA spacecraft, runs medical devices, and powers automotive controllers.</p>

<h3 id="the-problem">The Problem</h3>
<p>RTEMS currently uses Newlib as its C library. However, Newlib does not implement the standard C11 Annex K bounds-checking interfaces. This means RTEMS developers writing code for safety-critical systems have no standardized way to use bounds-checked memory and string functions (like <code class="language-plaintext highlighter-rouge">strcpy_s</code> or <code class="language-plaintext highlighter-rouge">memset_s</code>). They usually have to rely on the unsafe originals or write their own wrappers.</p>

<h3 id="my-project">My Project</h3>
<p>My mission for the summer is to package <code class="language-plaintext highlighter-rouge">safeclib</code>—a library that implements all 45 Annex K functions—through the RTEMS Source Builder (RSB). By the end of August, developers will be able to easily build and link these safe functions for any RTEMS Board Support Package (BSP) just by adding <code class="language-plaintext highlighter-rouge">-lsafec</code>.</p>

<p>The pre-coding community bonding period is officially wrapping up today. I’ve spent the last couple of weeks finalizing the RSB recipe design with my mentors, Joel Sherrill and Gedare Bloom, and verifying upstream compatibility.</p>

<p>Coding officially begins tomorrow! My immediate next step is to draft the RSB <code class="language-plaintext highlighter-rouge">.cfg</code> and <code class="language-plaintext highlighter-rouge">.bset</code> skeleton and get the RTEMS <code class="language-plaintext highlighter-rouge">Init</code> task scaffolding running under QEMU SPARC to test the library on bare metal.</p>

<p>I’ll be posting weekly technical updates right here. Stay tuned!</p>]]></content><author><name>Yash Bhiwania</name></author><category term="gsoc" /><category term="rtems" /><summary type="html"><![CDATA[Hello world! I am Yash, a 3rd-year B.Tech student in Communication and Computer Engineering. This summer, I am incredibly excited to announce that I will be participating in Google Summer of Code 2026 with the RTEMS Project.]]></summary></entry></feed>