https://dl.acm.org/doi/10.1145/3687997.3695639 skip to main content * ACM Digital Library home * ACM Association for Computing Machinery corporate logo * Advanced Search * Browse * About * + Sign in + Register * * Advanced Search * Journals * Magazines * Proceedings * Books * SIGs * Conferences * People * * More * Search ACM Digital Library[ ] SearchSearch Advanced Search 10.1145/3687997.3695639acmconferencesArticle/Chapter ViewAbstract Publication PagessplashConference Proceedingsconference-collections splash * Conference * Proceedings * Upcoming Events * Authors * Affiliations * Award Winners * More * Home * Conferences * SPLASH * Proceedings * SLE '24 * The Design of a Self-Compiling C Transpiler Targeting POSIX Shell research-article Free access [icon-small][icon-small] Share on * * * * * * The Design of a Self-Compiling C Transpiler Targeting POSIX Shell Authors: [default-pr]Laurent Huberdeau, [default-pr]Cassandre Hamel, [default-pr]Stefan Monnier, [contrib-81]Marc FeeleyAuthors Info & Claims SLE 2024: Proceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering Pages 70 - 83 https://doi.org/10.1145/3687997.3695639 Published: 17 October 2024 Publication History Related Artifact: Pnut: A C Transpiler Targeting POSIX Shell October 2024 software https://doi.org/10.5281/zenodo.13851394 0citation120Downloads Metrics Total Citations0 Total Downloads120 Last 12 Months120 Last 6 weeks120 Get Citation Alerts New Citation Alert added! This alert has been successfully added and will be sent to: You will be notified whenever a record that you have chosen has been cited. To manage your alert preferences, click on the button below. Manage my Alerts New Citation Alert! Please log in to your account PDFeReader * Contents SLE 2024: Proceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering The Design of a Self-Compiling C Transpiler Targeting POSIX Shell Pages 70 - 83 PREVIOUS ARTICLE Efficient Demand Evaluation of Fixed-Point Attributes using Static Analysis Previous NEXT ARTICLE DSLs in Racket: You Want It How, Now? Next + Abstract + References ACM Digital Library * + Information & Contributors + Bibliometrics & Citations + View Options + References + Media + Tables + Share Abstract Software supply chain attacks are increasingly frequent and can be hard to guard against. Reproducible builds ensure that generated artifacts (executable programs) can be reliably created from their source code. However, the tools used by the build process are also vulnerable to supply chain attacks so a complete solution must also include reproducible builds for the various compilers used. With this problem as our main motivation we explore the use of the widely available POSIX shell as the only trusted pre-built binary for the reproducible build process. We have developed pnut, a C to POSIX shell transpiler written in C that generates human-readable shell code. Because the compiler is self-applicable, it is possible to distribute a human-readable shell script implementing a C compiler that depends only on the existence of a POSIX compliant shell such as bash, ksh, zsh, etc. Together, pnut and the shell serve as the seed for a chain of builds that create increasingly capable compilers up to the most recent version of the GNU Compiler Collection (GCC) that is a convenient basis to build any other required tool in the toolchain. The end result is a complete build toolchain built only from a shell and human-readable source files. We discuss the level of C language support needed to achieve our goal, the generation of portable POSIX shell code from C, and the performance of the compiler and generated code. References [1] Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. 1986. Compilers: Principles, Techniques, and Tools (2 ed.). Addison-Wesley. Visited on 2024-07-01 Digital Library Google Scholar [2] Kenneth Almquist. 1989. Almquist shell. https://www.in-ulm.de/ ~mascheck/various/ash/ Visited on 2024-07-01 Google Scholar [3] Andrew W. Appel. 1994. Axiomatic bootstrapping: a guide for compiler hackers. Transactions on Programming Languages and Systems, 16, 6 (1994), 1699-1718. https://doi.org/10.1145/197320.197336 Digital Library Google Scholar [4] Morris Bolsky and David Korn. 1983. KornShell. https://github.com/ ksh93/ksh Visited on 2024-07-01 Google Scholar [5] Ludovic Courtes and Janneke Nieuwenhuizen. 2023. The Full-Source Bootstrap: Building from source all the way down. https:// guix.gnu.org/en/blog/2023/ the-full-source-bootstrap-building-from-source-all-the-way-down/ Visited on 2024-07-01 Google Scholar [6] Tyler Denniston. 2015. Bish. https://github.com/tdenniston/bish Visited on 2024-07-01 Google Scholar [7] Brian Fox et al. 1989. Bourne-Again SHell. https:// git.savannah.gnu.org/cgit/bash.git Visited on 2024-07-01 Google Scholar [8] Carbo Kuo et al. 2014. Batsh. https://github.com/batsh-dev-team/Batsh Visited on 2024-07-01 Google Scholar [9] Fabrice Bellard et al. 2001. Tiny C Compiler. https://bellard.org/tcc / Visited on 2024-04-15 Google Scholar [10] Herbert Xu et al. 1997. Debian Almquist shell (DASH). https:// git.kernel.org/pub/scm/utils/dash/dash.git Visited on 2024-07-01 Google Scholar [11] Paul Falstad et al. 1990. Z shell. https://www.zsh.org/ Visited on 2024-07-01 Google Scholar [12] Pawel Karas et al. 2023. Amber. https://github.com/Ph0enixKM/Amber Visited on 2024-07-01 Google Scholar [13] WATANABE Yuki et al. 2009. Yet another shell. https://github.com/ magicant/yash Visited on 2024-07-01 Google Scholar [14] Laurent Huberdeau, Cassandre Hamel, Stefan Monnier, and Marc Feeley. 2024. Pnut: A C Transpiler Targeting POSIX Shell. https://doi.org/ 10.5281/zenodo.13851394 Crossref Google Scholar [15] Gregor Kiczales, Jim Des Rivieres, and Daniel G. Bobrow. 1991. The Art of the Metaobject Protocol. MIT Press. Google Scholar [16] Leonard Oest O'Leary, Mathis Laroche, and Marc Feeley. 2023. A R4RS Compliant REPL in 7 KB. arxiv:2310.13589. arxiv:2310.13589 Google Scholar [17] Robert Swierczek. 2014. c4 - C in four functions. https://github.com/ rswier/c4/tree/master Visited on 2024-07-01 Google Scholar [18] 2018. The Open Group Base Specifications Issue 7. https:// pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html Google Scholar [19] Ken Thompson. 1984. Reflections on Trusting Trust. Commun. ACM, 27, 8 (1984), aug, 761-763. https://doi.org/10.1145/358198.358210 Digital Library Google Scholar [20] Simon Tournier. 2023. Is Guix full-source bootstrap a lie? https:// simon.tournier.info/posts/2023-10-01-bootstrapping.html Visited on 2024-07-01 Google Scholar [21] Leon van Kammen. 2016. Powscript. https://github.com/coderofsalvation /powscript Visited on 2024-07-01 Google Scholar [22] David Wheeler. 2005. Countering Trusting Trust through Diverse Double-Compiling. In Annual Computer Security Applications Conference. 33-48. https://doi.org/10.1109/CSAC.2005.17 Digital Library Google Scholar Index Terms 1. The Design of a Self-Compiling C Transpiler Targeting POSIX Shell 1. Security and privacy 1. Software and application security 1. Software security engineering 2. Software and its engineering 1. Software creation and management 1. Software development process management 2. Software notations and tools 1. Compilers 1. Source code generation Recommendations * Executable formal semantics for the POSIX shell The POSIX shell is a widely deployed, powerful tool for managing computer systems. The shell is the expert's control panel, a necessary tool for configuring, compiling, installing, maintaining, and deploying systems. Even though it is powerful, critical ... Read More * Word expansion supports POSIX shell interactivity Programming '18: Companion Proceedings of the 2nd International Conference on the Art, Science, and Engineering of Programming The POSIX shell is the standard tool to deploy, control, and maintain systems of all kinds; the shell is used on a sliding scale from one-off commands in an interactive mode all the way to complex scripts managing, e.g., system boot sequences. For all ... Read More * Shell Scripting: How to Automate Command Line Tasks Using Bash Scripting and Shell Programming Read More Comments Please enable JavaScript to view thecomments powered by Disqus. Information & Contributors Information Published In cover image ACM Conferences SLE '24: Proceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering October 2024 235 pages ISBN:9798400711800 DOI:10.1145/3687997 * General Chair: * Author PictureRalf Laemmel University of Koblenz, Germany , * Program Chairs: * Author PictureJuliana Alves Pereira PUC-Rio, Brazil , * Author PicturePeter D. Mosses TU Delft, Netherlands / Swansea University, United Kingdom Copyright (c) 2024 Copyright is held by the owner/author(s). Publication rights licensed to ACM. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. Sponsors * SIGPLAN: SIGPLAN Publisher Association for Computing Machinery New York, NY, United States Publication History Published: 17 October 2024 Permissions Request permissions for this article. Request Permissions Check for updates Badges * [icon-large]Artifacts Available / v1.1 * [icon-large]Artifacts Evaluated & Reusable / v1.1 Author Tags 1. Bootstrapping 2. Compiler 3. Reproducible Builds Qualifiers * Research-article Funding Sources * NSERC Conference SLE '24 Sponsor: * SIGPLAN SLE '24: 17th ACM SIGPLAN International Conference on Software Language Engineering October 20 - 21, 2024 CA, Pasadena, USA Upcoming Conference SPLASH '25 * Sponsor: * sigplan ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity October 20 - 27, 2025 Singapore , Singapore Contributors [loader-7e6] Other Metrics View Article Metrics Bibliometrics & Citations Bibliometrics Article Metrics * 0 Total Citations * 120 Total Downloads * Downloads (Last 12 months)120 * Downloads (Last 6 weeks)120 Reflects downloads up to 07 Nov 2024 Other Metrics View Author Metrics Citations View Options View options PDF View or Download as a PDF file. PDF eReader View online with eReader. eReader Get Access Login options Check if you have access through your login credentials or your institution to get full access on this article. Sign in Full Access Get this Publication Media Figures Other Tables Share Share Share this Publication link Copy Link Copied! Copying failed. Share on social media XLinkedInRedditFacebookemail Affiliations [default-pr] Laurent Huberdeau Universite de Montreal, Montreal, Canada https://orcid.org/0009-0000-7282-4621 View Profile [default-pr] Cassandre Hamel Universite de Montreal, Montreal, Canada https://orcid.org/0000-0003-4687-0397 View Profile [default-pr] Stefan Monnier Universite de Montreal, Montreal, Canada https://orcid.org/0000-0001-7597-5273 View Profile [contrib-81] Marc Feeley Universite de Montreal, Montreal, Canada https://orcid.org/0009-0005-5237-8712 View Profile Download PDF Go to Go to Show all references Request permissionsExpand All Collapse Expand Table Authors Info & Affiliations View Table of Contents Export Citations Select Citation format[BibTeX ] * Please download or close your previous search result export first before starting a new bulk export. Preview is not available. By clicking download,a status dialog will open to start the export process. The process may takea few minutes but once it finishes a file will be downloadable from your browser. You may continue to browse the DL while the export process is in progress. Download + Download citation + Copy citation Footer Categories * Journals * Magazines * Books * Proceedings * SIGs * Conferences * Collections * People About * About ACM Digital Library * ACM Digital Library Board * Subscription Information * Author Guidelines * Using ACM Digital Library * All Holdings within the ACM Digital Library * ACM Computing Classification System * Accessibility Statement Join * Join ACM * Join SIGs * Subscribe to Publications * Institutions and Libraries Connect * Contact us via email * ACM on Facebook * ACM DL on X * ACM on Linkedin * Send Feedback * Submit a Bug Report The ACM Digital Library is published by the Association for Computing Machinery. Copyright (c) 2024 ACM, Inc. * Terms of Usage * Privacy Policy * Code of Ethics ACM Digital Library home ACM Association for Computing Machinery corporate logo Your Search Results Download Request We are preparing your search results for download ... We will inform you here when the file is ready. Download now! Your Search Results Download Request Your file of search results citations is now ready. Download now! Your Search Results Download Request Your search export query has expired. Please try again.