Fix #1 by adding debug makefile variable

This commit is contained in:
blackle 2019-06-15 00:41:56 -04:00
parent d317e693b0
commit 6624f2faed
3 changed files with 19 additions and 5 deletions

View File

@ -1,8 +1,16 @@
DEBUG=false
CFLAGS := -fno-plt -O1 -std=gnu11 -nostartfiles -Wall -Wextra
CFLAGS += -fno-stack-protector -fno-stack-check -fno-unwind-tables -fno-asynchronous-unwind-tables -fomit-frame-pointer
CFLAGS += -no-pie -fno-pic -fno-PIE -fno-PIC -march=core2 -ffunction-sections -fdata-sections
ifeq ($(DEBUG),false)
CFLAGS += -nostdlib
else
CFLAGS += -DDEBUG=true
endif
.PHONY: clean checkgccversion noelfver
all : checkgccversion gtk-opengl xlib-opengl sdl2-opengl

View File

@ -4,15 +4,15 @@ Here are examples of rendering a shader full screen on linux. All of these examp
There are three examples, each using a different library to open a window and get an opengl context.
## xlib-opengl - 1503 bytes
## xlib-opengl - 1492 bytes
Vanilla xlib is the largest of the bunch and the most brittle. It is highly not recommended to use xlib in a demo unless you cannot assume these other libraries will be on the system.
Vanilla xlib is the largest of the bunch and the most brittle. It is highly not recommended to use xlib in a demo unless you cannot assume these other libraries will be on the system. (note, unlike all the other programs that close with the window manager's quit key combination, this program must be closed with ESC.)
## gtk-opengl - 1396 bytes
## gtk-opengl - 1382 bytes
GTK is a step up from xlib, being both smaller and more robust. If the compo you are entering doesn't allow using SDL2, GTK is an ok alternative. Before switching to GCC 8.3.0, this was 100 bytes smaller than it is now. I am not sure why it is larger, but this likely means it can be sizecoded/stripped further.
## sdl2-opengl - 1010 bytes
## sdl2-opengl - 996 bytes
Using SDL2 will give you very small binaries. Use SDL2 whenever you can, as it also has a few other useful subsystems at minimal cost (for example, audio.)

View File

@ -94,7 +94,13 @@ void _start() {
|| (Event.type == SDL_KEYDOWN && Event.key.keysym.sym == SDLK_ESCAPE)
#endif
) {
exit(0);
asm volatile(".intel_syntax noprefix");
asm volatile("push 231"); //exit_group
asm volatile("pop rax");
asm volatile("xor edi, edi");
asm volatile("syscall");
asm volatile(".att_syntax prefix");
__builtin_unreachable();
}
if (Event.type == SDL_WINDOWEVENT) {
switch(Event.window.event) {