From a00571abd3f0cba014aa8b942b5b242df1ff24de Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Aug 2025 19:28:19 -0400 Subject: Fix some compatibility issues, including #embed and `alignof` and some Makefile comment parsing issues. --- .gitignore | 2 ++ Makefile | 7 +++++-- src/naming.c | 2 +- src/stdlib/pointers.h | 2 +- src/tomo.c | 10 +++------- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index c1cb5b41..71fa5258 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ /lib/*/*.so /lib/*/*.a +/src/changes.md.h + .build /build/bin /build/lib diff --git a/Makefile b/Makefile index 27318e7e..bc8a056c 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ OSFLAGS != case $(OS) in *BSD|Darwin) echo '-D_BSD_SOURCE';; Linux) echo '-D_GNU EXTRA= G=-ggdb O=-O3 -TOMO_VERSION=$(shell awk '/^## / {print $$2; exit}' CHANGES.md) +TOMO_VERSION=$(shell awk '/^\#\# / {print $$2; exit}' CHANGES.md) GIT_VERSION=$(shell git log -1 --pretty=format:"%as_%h") CFLAGS=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO) \ -DTOMO_PREFIX='"$(PREFIX)"' -DSUDO='"$(SUDO)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' \ @@ -141,10 +141,13 @@ config.mk: configure.sh @$(CC) $(CFLAGS) -c $< -o $@ # Specifically src/tomo.c needs to recompile if CHANGES.md changes: -src/tomo.o: src/tomo.c src/ast.h src/environment.h src/types.h config.mk CHANGES.md +src/tomo.o: src/tomo.c src/ast.h src/environment.h src/types.h config.mk src/changes.md.h @echo $(CC) $(CFLAGS_PLACEHOLDER) -c $< -o $@ @$(CC) $(CFLAGS) -c $< -o $@ +src/changes.md.h: CHANGES.md + xxd -i $< > $@ + %: %.tm ./local-tomo -e $< diff --git a/src/naming.c b/src/naming.c index abe87569..ba5098fd 100644 --- a/src/naming.c +++ b/src/naming.c @@ -12,7 +12,7 @@ static const char *c_keywords[] = { // Maintain sorted order: "_Alignas", "_Alignof", "_Atomic", "_BitInt", "_Bool", "_Complex", "_Decimal128", "_Decimal32", "_Decimal64", "_Generic", "_Imaginary", "_Noreturn", "_Static_assert", "_Thread_local", - "alignas", "alignof", "auto", "bool", "break", "case", "char", "const", "constexpr", "continue", "default", "do", "double", + "alignas", "__alignof__", "auto", "bool", "break", "case", "char", "const", "constexpr", "continue", "default", "do", "double", "else", "enum", "extern", "false", "float", "for", "goto", "if", "inline", "int", "long", "nullptr", "register", "restrict", "return", "short", "signed", "sizeof", "static", "static_assert", "struct", "switch", "thread_local", "true", "typedef", "typeof", "typeof_unqual", "union", "unsigned", "void", "volatile", "while", diff --git a/src/stdlib/pointers.h b/src/stdlib/pointers.h index b818452e..001dc5ce 100644 --- a/src/stdlib/pointers.h +++ b/src/stdlib/pointers.h @@ -18,7 +18,7 @@ void Pointer$deserialize(FILE *in, void *outval, List_t *pointers, const TypeInf #define Null(t) (t*)NULL #define POINTER_TYPE(_sigil, _pointed) (&(TypeInfo_t){\ - .size=sizeof(void*), .align=alignof(void*), .tag=PointerInfo, .PointerInfo.sigil=_sigil, .PointerInfo.pointed=_pointed}) + .size=sizeof(void*), .align=__alignof__(void*), .tag=PointerInfo, .PointerInfo.sigil=_sigil, .PointerInfo.pointed=_pointed}) #define Pointer$metamethods { \ .as_text=Pointer$as_text, \ diff --git a/src/tomo.c b/src/tomo.c index e8012f9e..4cad76a0 100644 --- a/src/tomo.c +++ b/src/tomo.c @@ -13,6 +13,7 @@ #endif #include "ast.h" +#include "changes.md.h" #include "compile.h" #include "modules.h" #include "naming.h" @@ -97,11 +98,6 @@ static Text_t config_summary, // of that directory. as_owner = Text(""); -static const char changelog[] = { -#embed "../CHANGES.md" - , 0 -}; - static void transpile_header(env_t *base_env, Path_t path); static void transpile_code(env_t *base_env, Path_t path); static void compile_object_file(Path_t path); @@ -230,7 +226,7 @@ int main(int argc, char *argv[]) } if (show_changelog) { - print_inline(changelog); + print_inline(string_slice(CHANGES_md, CHANGES_md_len)); return 0; } @@ -693,7 +689,7 @@ void build_file_dependency_graph(Path_t path, Table_t *to_compile, Table_t *to_l time_t latest_included_modification_time(Path_t path) { static Table_t c_modification_times = {}; - const TypeInfo_t time_info = {.size=sizeof(time_t), .align=alignof(time_t), .tag=OpaqueInfo}; + const TypeInfo_t time_info = {.size=sizeof(time_t), .align=__alignof__(time_t), .tag=OpaqueInfo}; time_t *cached_latest = Table$get(c_modification_times, &path, Table$info(&Path$info, &time_info)); if (cached_latest) return *cached_latest; -- cgit v1.2.3