Compare commits

..

10 Commits

Author SHA1 Message Date
Benjamin
a01858615d README.md updates, about why this code is public domain.
Some checks failed
C/C++ CI / build (push) Has been cancelled
2026-04-07 15:45:05 -04:00
Benjamin
6c2af30345 Fixed a linker problem for systems, where bash is install at a non standard location. 2026-04-07 15:07:57 -04:00
Benjamin
cfd3e2ba51 Added LICENSE file. 2026-03-19 23:27:29 +00:00
RoyR
8a60ebbfbf Added a linker scripts, instead of using gcc directly. 2026-03-16 11:47:38 -04:00
RoyR
01cb40babc Added the -no-pie option for linking 2026-03-14 15:43:11 -04:00
RoyR
a0175024f3 Updated to install gcc-multilib 2026-03-14 15:38:20 -04:00
RoyR
270c34518a Another try with the yaml 2026-03-14 15:34:02 -04:00
RoyR
d82ebb7986 Updated stuff for NASM. 2026-03-14 15:28:30 -04:00
RoyR
94248e38fb Updated the indention for emacs 2026-03-14 15:22:02 -04:00
RoyR
3590f26005 Added uses ilammy/setup-nasm. 2026-03-14 15:19:24 -04:00
7 changed files with 1144 additions and 1097 deletions

View File

@@ -13,6 +13,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install NASM & gcc-multilib
run: |
sudo apt-get update
sudo apt-get install -y nasm gcc-multilib
- name: make - name: make
run: make run: make
- name: make test - name: make test

19
LICENSE Normal file
View File

@@ -0,0 +1,19 @@
No Copyright
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.
You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission. See Other Information below.
Other Information
In no way are the patent or trademark rights of any person affected by CC0, nor are the rights that other persons may have in the work or in how the work is used, such as publicity or privacy rights.
Unless expressly stated otherwise, the person who associated a work with this deed makes no warranties about the work, and disclaims liability for all uses of the work, to the fullest extent permitted by applicable law.
When using or citing the work, you should not imply endorsement by the author or the affirmer.
Notice
The Commons Deed is not a legal instrument. It is simply a handy reference for understanding the CC0 Legal Code, a human-readable expression of some of its key terms. Think of it as the user-friendly interface to the CC0 Legal Code beneath. This Deed itself has no legal value, and its contents do not appear in CC0.
Creative Commons is not a law firm and does not provide legal services. Distributing, displaying, or linking to this Commons Deed does not create an attorney-client relationship.
Creative Commons has not verified the copyright status of any work to which CC0 has been applied. CC makes no warranties about any work or its copyright status in any jurisdiction, and disclaims all liability for all uses of any work.

View File

@@ -4,8 +4,8 @@ CC = gcc
CFLAGS = -std=c99 -Wall -O2 CFLAGS = -std=c99 -Wall -O2
NASM = nasm NASM = nasm
NASMFLAGS = -f elf32 NASMFLAGS = -f elf32
LD = gcc LD = ./commonl
LDFLAGS = -m32 LDFLAGS =
# Compiler # Compiler
COMPILER = common COMPILER = common

View File

@@ -302,6 +302,7 @@ gcc -m32 main.c common.o -o program
``` ```
. .
├── common.c # Compiler source (2000 LOC) ├── common.c # Compiler source (2000 LOC)
├── commonl # Linker
├── Makefile # Build automation ├── Makefile # Build automation
├── run_tests.sh # Quick test script ├── run_tests.sh # Quick test script
@@ -328,19 +329,30 @@ gcc -m32 main.c common.o -o program
└── linkedlist.cm └── linkedlist.cm
``` ```
## License ## License & Educational Purpose
Public domain / CC0. Use freely for any purpose. ### Public Domain / CC0
This project is dedicated to the public domain under the CC0 1.0 Universal license. This means you can copy, modify, distribute, and perform the work, even for commercial purposes, all without asking permission.
### Why Public Domain?
- **Ease of Use:** - By removing all licensing restrictions, students can freely integrate code snippets from common.c into their own projects without legal overhead or attribution requirements.
- **Educational Accessibility:** - The compiler is designed to be a "pure" learning resource. Its single-file implementation is intended to be read and modified as if it were a textbook example.
No Barriers: Just as the language requires "zero external dependencies," its legal status requires no compliance tracking, making it ideal for classroom settings and open-source forks.
- **Simplicity:** - A complex license would contradict the project's philosophy of "simplicity over features"
## Credits ## Credits
Inspired by: Inspired by:
- **C** - Dennis Ritchie and Brian Kernighan - **C** - Dennis Ritchie and Brian Kernighan
- **chibicc** - Rui Ueyama's educational C compiler - **chibicc** - Rui Ueyama's educational C compiler
- **8cc** - Rui Ueyama's C compiler - **8cc** - Rui Ueyama's C compiler
- **tcc** - Fabrice Bellard's Tiny C Compiler - **tcc** - Fabrice Bellard's Tiny C Compiler
Built for programmers who value: Built for programmers who value:
- Simplicity over features - Simplicity over features
- Control over convenience - Control over convenience
- Learning over abstraction - Learning over abstraction

11
commonl Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Public domain / CC0. Use freely for any purpose. RoyR 2026
GCC_NO_PIE=1
echo 'int main() {}' | gcc -E -no-pie - -o /dev/null || GCC_NO_PIE=0
if [ $GCC_NO_PIE = 1 ];then
gcc -m32 -no-pie "$@"
else
gcc -m32 "$@"
fi

View File

@@ -72,7 +72,7 @@ static void run_test(Test *t) {
} }
/* Link */ /* Link */
if (run_command("gcc -m32 /tmp/test.o -o /tmp/test 2>/tmp/test.err") != 0) { if (run_command("./commonl /tmp/test.o -o /tmp/test 2>/tmp/test.err") != 0) {
printf("FAIL (linker error)\n"); printf("FAIL (linker error)\n");
test_failed++; test_failed++;
return; return;