diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6624d606..af93edc4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: run: ./configure && make && make test -k test-x86_64-osx: - runs-on: macos-12 + runs-on: macos-13 timeout-minutes: 2 steps: - uses: actions/checkout@v4 diff --git a/libtcc.c b/libtcc.c index 209f9ee5..1af9628f 100644 --- a/libtcc.c +++ b/libtcc.c @@ -822,6 +822,7 @@ LIBTCCAPI TCCState *tcc_new(void) s->warn_implicit_function_declaration = 1; s->warn_discarded_qualifiers = 1; s->ms_extensions = 1; + s->unwind_tables = 1; #ifdef CHAR_IS_UNSIGNED s->char_is_unsigned = 1; @@ -1674,6 +1675,8 @@ static const FlagDef options_f[] = { { offsetof(TCCState, dollars_in_identifiers), 0, "dollars-in-identifiers" }, { offsetof(TCCState, test_coverage), 0, "test-coverage" }, { offsetof(TCCState, reverse_funcargs), 0, "reverse-funcargs" }, + { offsetof(TCCState, gnu89_inline), 0, "gnu89-inline" }, + { offsetof(TCCState, unwind_tables), 0, "asynchronous-unwind-tables" }, { 0, 0, NULL } }; diff --git a/tcc.c b/tcc.c index 2754828a..010f3b3e 100644 --- a/tcc.c +++ b/tcc.c @@ -116,6 +116,8 @@ static const char help2[] = " ms-extensions allow anonymous struct in struct\n" " dollars-in-identifiers allow '$' in C symbols\n" " reverse-funcargs evaluate function arguments right to left\n" + " gnu89-inline 'extern inline' is like 'static inline'\n" + " asynchronous-unwind-tables create eh_frame section [on]\n" " test-coverage create code coverage code\n" "-m... target specific options:\n" " ms-bitfields use MSVC bitfield layout\n" diff --git a/tcc.h b/tcc.h index d66a0fc9..7edf9238 100644 --- a/tcc.h +++ b/tcc.h @@ -777,6 +777,8 @@ struct TCCState { unsigned char dollars_in_identifiers; /* allows '$' char in identifiers */ unsigned char ms_bitfields; /* if true, emulate MS algorithm for aligning bitfields */ unsigned char reverse_funcargs; /* if true, evaluate last function arg first */ + unsigned char gnu89_inline; /* treat 'extern inline' like 'static inline' */ + unsigned char unwind_tables; /* create eh_frame section */ /* warning switches */ unsigned char warn_none; diff --git a/tccdbg.c b/tccdbg.c index f82d6bbe..f9fb62ee 100644 --- a/tccdbg.c +++ b/tccdbg.c @@ -716,6 +716,8 @@ ST_FUNC void tcc_eh_frame_start(TCCState *s1) { #if !(defined _WIN32 || defined __APPLE__ || defined TCC_TARGET_ARM || \ defined TARGETOS_BSD) + if (!s1->unwind_tables) + return; eh_frame_section = new_section(s1, ".eh_frame", SHT_PROGBITS, SHF_ALLOC); s1->eh_start = eh_frame_section->data_offset; diff --git a/tccgen.c b/tccgen.c index 8e7023ea..d42a8b40 100644 --- a/tccgen.c +++ b/tccgen.c @@ -8459,6 +8459,7 @@ static int decl(int l) CType type, btype; Sym *sym; AttributeDef ad, adbase; + ElfSym *esym; while (1) { @@ -8529,21 +8530,17 @@ static int decl(int l) func_vt = type; decl(VT_CMP); } -#if defined TCC_TARGET_MACHO || defined TARGETOS_ANDROID - if (sym->f.func_alwinl - && ((type.t & (VT_EXTERN | VT_INLINE)) - == (VT_EXTERN | VT_INLINE))) { + + if ((type.t & (VT_EXTERN|VT_INLINE)) == (VT_EXTERN|VT_INLINE)) { /* always_inline functions must be handled as if they don't generate multiple global defs, even if extern inline, i.e. GNU inline semantics for those. Rewrite them into static inline. */ - type.t &= ~VT_EXTERN; - type.t |= VT_STATIC; + if (tcc_state->gnu89_inline || sym->f.func_alwinl) + type.t = (type.t & ~VT_EXTERN) | VT_STATIC; + else + type.t &= ~VT_INLINE; /* always compile otherwise */ } -#endif - /* always compile 'extern inline' */ - if (type.t & VT_EXTERN) - type.t &= ~VT_INLINE; } else if (oldint) { tcc_warning("type defaults to int"); @@ -8682,7 +8679,7 @@ static int decl(int l) ) { /* external variable or function */ type.t |= VT_EXTERN; - sym = external_sym(v, &type, r, &ad); + external_sym(v, &type, r, &ad); } else { if (l == VT_CONST || (type.t & VT_STATIC)) r |= VT_CONST; @@ -8702,8 +8699,7 @@ static int decl(int l) We only support the case where the base is already defined, otherwise we would need deferring to emit the aliases until the end of the compile unit. */ - Sym *alias_target = sym_find(ad.alias_target); - ElfSym *esym = elfsym(alias_target); + esym = elfsym(sym_find(ad.alias_target)); if (!esym) tcc_error("unsupported forward __alias__ attribute"); put_extern_sym2(sym_find(v), esym->st_shndx,