This commit is contained in:
2026-05-10 08:55:46 -05:00
parent 1ad732ea4b
commit 7e9f73bfa7
7 changed files with 102 additions and 17 deletions

15
.idea/misc.xml generated
View File

@@ -6,4 +6,19 @@
<component name="CMakeWorkspace"> <component name="CMakeWorkspace">
<contentRoot DIR="$PROJECT_DIR$" /> <contentRoot DIR="$PROJECT_DIR$" />
</component> </component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project> </project>

6
.idea/tyche.iml generated
View File

@@ -1,2 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module classpath="CIDR" type="CPP_MODULE" version="4" /> <module external.linked.project.id="tyche" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="Makefile" type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -9,46 +9,76 @@ VERSION_MINOR=1
VERSION=${VERSION_MAJOR}.${VERSION_MINOR} VERSION=${VERSION_MAJOR}.${VERSION_MINOR}
#
# flags/options
#
IS_CLANG := $(shell $(CC) -dM -E - < /dev/null | grep -c __clang__)
WARNINGS=@config/WARNINGS
ADD_DBG_FLAGS=
ifeq ($(IS_CLANG),1)
WARNINGS += @config/WARNINGS_CLANG
else
WARNINGS += @config/WARNINGS_GCC
ADD_DBG_FLAGS=-fanalyzer
endif
DEBUG_CFLAGS=-Og -ggdb3 ${WARNINGS} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined -fsanitize=leak \
-fno-sanitize-recover=all -fstack-protector-strong -fstack-clash-protection -fno-common ${ADD_DBG_FLAGS}
DEBUG_LDFLAGS=-fsanitize=address
RELEASE_CFLAGS=-O3 -flto=auto -march=native -mtune=native -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong
RELEASE_LDFLAGS=-flto=auto
CFLAGS+=-std=c99 -fPIC -fvisibility=hidden -MMD -MP
LDFLAGS+=
# #
# generic targets # generic targets
# #
all: tyche libtyche.a libtyche.so.${VERSION} all: tyche libtyche.a libtyche.so.${VERSION}
check: tyche-test check:
$(MAKE) clean
$(MAKE) tyche-test
./tyche-test ./tyche-test
clean: clean:
rm -f tyche libtyche.a libtyche.so* tyche-test src/tyche.o src/tests.o lib/vm.o rm -f tyche libtyche.a libtyche.so* tyche-test src/tyche.o src/tests.o lib/vm.o src/*.d lib/*.d
install: tyche libtyche.a libtyche.so.${VERSION} install: tyche libtyche.a libtyche.so.${VERSION} lib/tyche.h
install libtyche.a libtyche.so.${VERSION} ${PREFIX}/lib install -m 644 libtyche.a libtyche.so.${VERSION} ${PREFIX}/lib
install tyche ${PREFIX}/bin install tyche ${PREFIX}/bin
ln -s libfoo.so.${VERSION} libfoo.so.${VERSION_MAJOR} install -m 644 lib/tyche.h ${PREFIX}/include
ln -s libfoo.so.${VERSION_MAJOR} libfoo.so ln -s ${PREFIX}/lib/libtyche.so.${VERSION} ${PREFIX}/lib/libtyche.so.${VERSION_MAJOR}
ln -s ${PREFIX}/lib/libtyche.so.${VERSION_MAJOR} ${PREFIX}/lib/libtyche.so
uninstall: uninstall:
rm -f ${PREFIX}/lib/libtyche.* ${PREFIX}/bin/tyche rm -f ${PREFIX}/lib/libtyche.* ${PREFIX}/bin/tyche ${PREFIX}/include/tyche.h
# .PHONY: all check clean install uninstall
# flags/options
#
CFLAGS=-fPIC
LIBS=
# #
# executable files # executable files
# #
tyche: CFLAGS += ${RELEASE_CFLAGS}
tyche: LDFLAGS += ${RELEASE_LDFLAGS}
tyche: src/tyche.o libtyche.a tyche: src/tyche.o libtyche.a
$(CC) -o $@ $^ ${LIBS} $(CC) -o $@ $^ ${LDFLAGS}
tyche-test: CFLAGS += ${DEBUG_CFLAGS}
tyche-test: LDFLAGS += ${DEBUG_LDFLAGS}
tyche-test: src/tests.o libtyche.a tyche-test: src/tests.o libtyche.a
$(CC) -o $@ $^ ${LIBS} $(CC) -o $@ $^ ${LDFLAGS}
libtyche.a: lib/vm.o libtyche.a: lib/vm.o
ar rcs $@ $^ ar rcs $@ $^
libtyche.so.${VERSION}: LDFLAGS += ${RELEASE_LDFLAGS}
libtyche.so.${VERSION}: lib/vm.o libtyche.so.${VERSION}: lib/vm.o
$(CC) -shared -o $@ -Wl,-soname,libfoo.so.${VERSION_MAJOR} $^ $(CC) -shared -o $@ -Wl,-soname,libfoo.so.${VERSION_MAJOR} $^ ${LDFLAGS}
-include $(wildcard src/*.d lib/*.d)

22
config/WARNINGS Normal file
View File

@@ -0,0 +1,22 @@
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wmissing-prototypes
-Wcast-qual
-Wcast-align
-Wconversion
-Wsign-conversion
-Wdouble-promotion
-Wformat=2
-Wformat-security
-Wnull-dereference
-Wstrict-overflow=4
-Wundef
-Wswitch-enum
-Wswitch-default
-Wfloat-equal
-Wpointer-arith
-Wwrite-strings
-Wredundant-decls
-Wstack-protector

3
config/WARNINGS_CLANG Normal file
View File

@@ -0,0 +1,3 @@
-Wshadow-all
-Wcomma
-Wassign-enum

7
config/WARNINGS_GCC Normal file
View File

@@ -0,0 +1,7 @@
-Wlogical-op
-Wjump-misses-init
-Wduplicated-cond
-Wduplicated-branches
-Wtrampolines
-Walloc-zero
-Walloca

4
lib/tyche.h Normal file
View File

@@ -0,0 +1,4 @@
#ifndef TYCHE_TYCHE_H
#define TYCHE_TYCHE_H
#endif //TYCHE_TYCHE_H