Skip to content

Instantly share code, notes, and snippets.

@baryluk
Last active December 5, 2020 12:22
Show Gist options
  • Save baryluk/047224e28b06c272d14af73bac5f0d23 to your computer and use it in GitHub Desktop.
Save baryluk/047224e28b06c272d14af73bac5f0d23 to your computer and use it in GitHub Desktop.
Minimal betterC (D programming language) example
#!/bin/sh
# Comparing minimal practical (no assembler used, C library used) binaries
# for various languages and compilers.
# Mainly to test D programming language mode called betterC
time g++-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniCPP.cpp -o miniCPP_gcc
time gcc-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniC.c -o miniC_gcc
time clang++-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniCPP.cpp -o miniCPP_clang
time clang-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniC.c -o miniC_clang
time dmd -betterC -O -inline -release -of=miniD_dmd miniD.d
time gdc-10 -Os -g0 -frelease -fno-weak -fno-moduleinfo -fomit-frame-pointer -fno-druntime -o miniD_gdc10 miniD.d
time ldc2 --Os --release --betterC -of=miniD_ldc2 miniD.d
betterC.d$ ls -ltr
total 260
-rw-r--r-- 1 user user 76 May 19 21:05 miniC.c
-rw-r--r-- 1 user user 122 May 19 21:06 miniD.d
-rw-r--r-- 1 user user 77 May 19 21:12 miniCPP.cpp
-rw-r--r-- 1 user user 1816 May 19 21:15 miniD.o
-rwxr-xr-x 1 user user 866 May 19 21:24 compile.sh
-rwxr-xr-x 1 user user 16608 May 19 21:24 miniCPP_gcc
-rwxr-xr-x 1 user user 16600 May 19 21:24 miniC_gcc
-rwxr-xr-x 1 user user 16520 May 19 21:24 miniCPP_clang
-rwxr-xr-x 1 user user 16520 May 19 21:24 miniC_clang
-rw-r--r-- 1 user user 1816 May 19 21:24 miniD_dmd.o
-rwxr-xr-x 1 user user 16632 May 19 21:24 miniD_dmd
-rwxr-xr-x 1 user user 16608 May 19 21:24 miniD_gdc10
-rw-r--r-- 1 user user 1288 May 19 21:24 miniD_ldc2.o
-rwxr-xr-x 1 user user 7784 May 19 21:24 miniD_ldc2
-rwxr-xr-x 1 user user 14408 May 19 21:24 miniCPP_gcc_stripped
-rwxr-xr-x 1 user user 14408 May 19 21:24 miniC_gcc_stripped
-rwxr-xr-x 1 user user 14432 May 19 21:24 miniCPP_clang_stripped
-rwxr-xr-x 1 user user 14432 May 19 21:24 miniC_clang_stripped
-rwxr-xr-x 1 user user 14408 May 19 21:24 miniD_dmd_stripped
-rwxr-xr-x 1 user user 6344 May 19 21:24 miniD_ldc2_stripped
-rwxr-xr-x 1 user user 14408 May 19 21:24 miniD_gdc10_stripped
betterC.d$
$ for i in *_stripped; do echo $(objdump -d $i | wc -l) "$i"; done
142 miniC_clang_stripped
147 miniC_gcc_stripped
142 miniCPP_clang_stripped
147 miniCPP_gcc_stripped
155 miniD_dmd_stripped
147 miniD_gdc10_stripped
147 miniD_ldc2_stripped
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment