diff --git a/.gitignore b/.gitignore index d3e7928c..3bff153f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ c2str tags TAGS tcc.1 -tcc.pod +*.pod tcc-doc.html tcc-doc.info diff --git a/Makefile b/Makefile index 15ece52a..6c688aba 100644 --- a/Makefile +++ b/Makefile @@ -8,12 +8,6 @@ ifndef TOP INCLUDED = no endif -# Uncomment the next two commands to allow debug this Makefile -# When enabled, GNU make will no longer execute commands directly. -# All build commands will be executed using the shell. This needs more time -#OLD_SHELL := $(SHELL) -#SHELL = $(info Building $* $(if $<, (from $<))$(if $?, ($? newer)))$(OLD_SHELL) - ifeq ($(findstring $(MAKECMDGOALS),clean distclean),) include $(TOP)/config.mak endif @@ -244,7 +238,7 @@ endif # convert "include/tccdefs.h" to "tccdefs_.h" %_.h : include/%.h conftest.c - $S$(CC) -DC2STR $(filter %.c,$^) -o c2str$(EXESUF) && ./c2str$(EXESUF) $< $@ + $S$(CC) -DC2STR $(filter %.c,$^) -o c2str.exe && ./c2str.exe $< $@ # target specific object rule $(X)%.o : %.c $(LIBTCC_INC) @@ -261,7 +255,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC) # Cross Tiny C Compilers # (the TCCDEFS_H dependency is only necessary for parallel makes, # ala 'make -j x86_64-tcc i386-tcc tcc', which would create multiple -# c2str and tccdefs_.h files in parallel, leading to access errors. +# c2str.exe and tccdefs_.h files in parallel, leading to access errors. # This forces it to be made only once. Make normally tracks multiple paths # to the same goals and only remakes it once, but that doesn't work over # sub-makes like in this target) @@ -332,6 +326,8 @@ tcc.1 : tcc-doc.pod %.pod : %.texi $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@) +doc : $(TCCDOCS) + # -------------------------------------------------------------------------- # install @@ -410,10 +406,6 @@ tags : ; ctags $(TAGFILES) # cannot have both tags and TAGS on windows ETAGS : ; etags $(TAGFILES) -# documentation -doc: tcc-doc.html tcc-doc.info tcc.1 - - # create release tarball from *current* git branch (including tcc-doc.html # and converting two files to CRLF) TCC-VERSION = tcc-$(VERSION) @@ -443,15 +435,16 @@ testspp.%: @$(MAKE) -C tests/pp $@ clean: - @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod tags ETAGS + @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tags ETAGS *.pod @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h @$(MAKE) -s -C lib $@ @$(MAKE) -s -C tests $@ distclean: clean - @rm -fv config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html + @rm -fv config.h config.mak config.texi + @rm -fv $(TCCDOCS) -.PHONY: all clean test tar tags ETAGS distclean install uninstall FORCE +.PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE help: @echo "make" diff --git a/arm-asm.c b/arm-asm.c index a4f974f6..a6dec4c3 100644 --- a/arm-asm.c +++ b/arm-asm.c @@ -77,21 +77,6 @@ static int asm_parse_vfp_regvar(int t, int double_precision) return -1; } -__attribute__((unused)) -static int asm_parse_vfp_status_regvar(int t) -{ - switch (t) { - case TOK_ASM_fpsid: - return 0; - case TOK_ASM_fpscr: - return 1; - case TOK_ASM_fpexc: - return 8; - default: - return -1; - } -} - /* Parse a text containing operand and store the result in OP */ static void parse_operand(TCCState *s1, Operand *op) { @@ -2240,6 +2225,20 @@ static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { asm_emit_coprocessor_opcode(condition_code_of_token(token), coprocessor, opcode1, ops[0].reg, (ops[1].type == OP_IM8) ? ops[1].e.v : ops[1].reg, (ops[2].type == OP_IM8) ? ops[2].e.v : ops[2].reg, opcode2, 0); } +static int asm_parse_vfp_status_regvar(int t) +{ + switch (t) { + case TOK_ASM_fpsid: + return 0; + case TOK_ASM_fpscr: + return 1; + case TOK_ASM_fpexc: + return 8; + default: + return -1; + } +} + static void asm_floating_point_status_register_opcode(TCCState* s1, int token) { uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT; diff --git a/arm-link.c b/arm-link.c index 47f60c80..604bf0c9 100644 --- a/arm-link.c +++ b/arm-link.c @@ -28,6 +28,7 @@ enum float_abi { #include "tcc.h" +#ifdef NEED_RELOC_TYPE /* Returns 1 for a code relocation, 0 for a data relocation. For unknown relocations, returns -1. */ int code_reloc (int reloc_type) @@ -107,7 +108,7 @@ int gotplt_entry_type (int reloc_type) return -1; } -#ifndef TCC_TARGET_PE +#ifdef NEED_BUILD_GOT ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) { Section *plt = s1->plt; @@ -177,6 +178,7 @@ ST_FUNC void relocate_plt(TCCState *s1) } } #endif +#endif void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val) { diff --git a/arm64-link.c b/arm64-link.c index 2d1628ff..d6c1b315 100644 --- a/arm64-link.c +++ b/arm64-link.c @@ -22,6 +22,7 @@ #include "tcc.h" +#ifdef NEED_RELOC_TYPE /* Returns 1 for a code relocation, 0 for a data relocation. For unknown relocations, returns -1. */ int code_reloc (int reloc_type) @@ -91,7 +92,7 @@ int gotplt_entry_type (int reloc_type) return -1; } -__attribute__((unused)) +#ifdef NEED_BUILD_GOT ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) { Section *plt = s1->plt; @@ -111,7 +112,6 @@ ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_ /* relocate the PLT: compute addresses and offsets in the PLT now that final address for PLT and GOT are known (see fill_program_header) */ -__attribute__((unused)) ST_FUNC void relocate_plt(TCCState *s1) { uint8_t *p, *p_end; @@ -166,6 +166,8 @@ ST_FUNC void relocate_plt(TCCState *s1) } } } +#endif +#endif void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val) { diff --git a/configure b/configure index 4af3f433..e71bd9cc 100755 --- a/configure +++ b/configure @@ -27,8 +27,7 @@ mandir="" infodir="" sysroot="" cross_prefix="" -test -z "$CC" && CC="gcc" -test -z "$cc" && cc="$CC" +cc="gcc" ar="ar" bigendian="no" mingw32="no" @@ -46,7 +45,7 @@ confvars= suggest="yes" gcc_major=0 gcc_minor=0 -cc_name="$cc" +cc_name="gcc" ar_set= darwin= cpu= @@ -408,6 +407,7 @@ if test "$cc_name" != "tcc"; then OPT1="-Wdeclaration-after-statement -fno-strict-aliasing" # we want -Wno- but gcc does not always reject unknown -Wno- options OPT2="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation" + OPT2="$OPT2 -Wstringop-truncation" if test "$cc_name" = "clang"; then OPT1="$OPT1 -fheinous-gnu-extensions" OPT2="$OPT2 -Wstring-plus-int" diff --git a/i386-asm.c b/i386-asm.c index aca6c97e..ebdfe036 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -833,6 +833,7 @@ again: goto next; alltypes |= ops[i].type; } + (void)alltypes; /* maybe unused */ /* all is matching ! */ break; next: ; diff --git a/i386-link.c b/i386-link.c index 72a0884b..b53c50a2 100644 --- a/i386-link.c +++ b/i386-link.c @@ -23,7 +23,7 @@ #include "tcc.h" -#ifndef ELF_OBJ_ONLY +#ifdef NEED_RELOC_TYPE /* Returns 1 for a code relocation, 0 for a data relocation. For unknown relocations, returns -1. */ int code_reloc (int reloc_type) @@ -92,6 +92,7 @@ int gotplt_entry_type (int reloc_type) return -1; } +#ifdef NEED_BUILD_GOT ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) { Section *plt = s1->plt; @@ -169,6 +170,7 @@ ST_FUNC void relocate_plt(TCCState *s1) } } #endif +#endif void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val) { diff --git a/libtcc.c b/libtcc.c index e7335922..2cceb6ff 100644 --- a/libtcc.c +++ b/libtcc.c @@ -836,6 +836,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) tcc_free(s1->tcc_lib_path); tcc_free(s1->soname); tcc_free(s1->rpath); + tcc_free(s1->elf_entryname); tcc_free(s1->init_symbol); tcc_free(s1->fini_symbol); tcc_free(s1->outfile); @@ -1567,23 +1568,6 @@ static const TCCOption tcc_options[] = { { NULL, 0, 0 }, }; -typedef struct stdvalue { - uint32_t cversion; - const char * name; -} stdvalue; - -/* accepted values for the -std= option */ -static const stdvalue std_values[] = { - { 199901, "c99" }, - { 201112, "c11" }, - { 201710, "c17" }, - { 202000, "c2x" }, - { 199901, "gnu99" }, - { 201112, "gnu11" }, - { 201710, "gnu17" }, - { 202000, "gnu2x" } -}; - typedef struct FlagDef { uint16_t offset; uint16_t flags; @@ -1837,9 +1821,6 @@ reparse: break; #endif case TCC_OPTION_g: - /* Use "-g" as alias for "-g1". Use "-g0" to disable debug */ - /* Other common used values: "-g0", "-g1", "-g2" and "-g3" */ - /* no failure with unsupported options */ s->do_debug = 1; s->dwarf = DWARF_VERSION; if (*optarg == 'd') { @@ -1847,8 +1828,6 @@ reparse: if (!strncmp(optarg,"dwarf-",6)) s->dwarf = atoi(optarg + 6); } - else if (isnum(*optarg)) - s->do_debug = atoi(optarg); break; case TCC_OPTION_c: x = TCC_OUTPUT_OBJ; @@ -1873,21 +1852,8 @@ reparse: s->static_link = 1; break; case TCC_OPTION_std: - x = 0; - if (*optarg == '=') { - do { - if (strcmp(std_values[x].name, &optarg[1]) == 0) { - x = std_values[x].cversion; - } - else - ++x; - } while (x < (sizeof(std_values)/sizeof(stdvalue))); - } - if (x > (sizeof(std_values)/sizeof(stdvalue))) - s->cversion = x; - else - goto unsupported_option; - + if (strcmp(optarg, "=c11") == 0) + s->cversion = 201112; break; case TCC_OPTION_shared: x = TCC_OUTPUT_DLL; @@ -2018,11 +1984,7 @@ reparse: s->filetype = x | (s->filetype & ~AFF_TYPE_MASK); break; case TCC_OPTION_O: - /* Use "-O" as alias for "-O1". */ - /* Other common used values: "-O0", "-O1", "-O2", "-O3" and "-Os" */ - /* no failure with unsupported options */ - x = *optarg; - s->optimize = isnum(x) ? atoi(optarg) : (x) ? x : 1; + s->optimize = atoi(optarg); break; case TCC_OPTION_print_search_dirs: x = OPT_PRINT_DIRS; diff --git a/tcc-doc.texi b/tcc-doc.texi index 83f05166..411cdd56 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -349,7 +349,7 @@ Turn on/off linking of all objects in archives. Debugger options: @table @option -@item -g[x] +@item -g Generate run time stab debug information so that you get clear run time error messages: @code{ test.c:68: in function 'test5()': dereferencing invalid pointer} instead of the laconic @code{Segmentation diff --git a/tcc.c b/tcc.c index 693eb216..2569e2a4 100644 --- a/tcc.c +++ b/tcc.c @@ -58,7 +58,7 @@ static const char help[] = " -soname set name for shared library to be used at runtime\n" " -Wl,-opt[=val] set linker option (see tcc -hh)\n" "Debugger options:\n" - " -g[x] generate stab runtime debug info\n" + " -g generate stab runtime debug info\n" " -gdwarf[-x] generate dwarf runtime debug info\n" #ifdef CONFIG_TCC_BCHECK " -b compile with built-in memory and bounds checker (implies -g)\n" diff --git a/tcc.h b/tcc.h index 03e83343..4910821f 100644 --- a/tcc.h +++ b/tcc.h @@ -258,9 +258,7 @@ extern long double strtold (const char *__nptr, char **__endptr); /* path to find crt1.o, crti.o and crtn.o */ #ifndef CONFIG_TCC_CRTPREFIX -# define CONFIG_TCC_CRTPREFIX \ - ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ - ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" +# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) #endif #ifndef CONFIG_USR_INCLUDE @@ -277,8 +275,6 @@ extern long double strtold (const char *__nptr, char **__endptr); # define CONFIG_TCC_SYSINCLUDEPATHS \ "{B}/include" \ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \ - ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/include" \ - ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/include" \ ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE) # endif #endif @@ -290,8 +286,6 @@ extern long double strtold (const char *__nptr, char **__endptr); # else # define CONFIG_TCC_LIBPATHS \ ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ - ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" \ - ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/lib" \ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) # endif @@ -826,7 +820,7 @@ struct TCCState { char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */ char *soname; /* as specified on the command line (-soname) */ char *rpath; /* as specified on the command line (-Wl,-rpath=) */ - + char *elf_entryname; /* "_start" unless set */ char *init_symbol; /* symbols to call at load-time (not used currently) */ char *fini_symbol; /* symbols to call at unload-time (not used currently) */ @@ -975,8 +969,6 @@ struct TCCState { Section *verneed_section; #endif - char *elf_entryname; - #ifdef TCC_IS_NATIVE const char *runtime_main; void **runtime_mem; @@ -1545,9 +1537,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, int fd, unsigned long file_offset ST_FUNC int tcc_load_archive(TCCState *s1, int fd, int alacarte); ST_FUNC void add_array(TCCState *s1, const char *sec, int c); -#if !defined(ELF_OBJ_ONLY) || (defined(TCC_TARGET_MACHO) && defined TCC_IS_NATIVE) -ST_FUNC void build_got_entries(TCCState *s1); -#endif ST_FUNC struct sym_attr *get_sym_attr(TCCState *s1, int index, int alloc); ST_FUNC addr_t get_sym_addr(TCCState *s, const char *name, int err, int forc); ST_FUNC void list_elf_symbols(TCCState *s, void *ctx, @@ -1570,6 +1559,9 @@ ST_FUNC void tcc_add_runtime(TCCState *s1); /* ------------ xxx-link.c ------------ */ +#if !defined ELF_OBJ_ONLY || defined TCC_TARGET_MACHO +ST_FUNC int code_reloc (int reloc_type); +ST_FUNC int gotplt_entry_type (int reloc_type); /* Whether to generate a GOT/PLT entry and when. NO_GOTPLT_ENTRY is first so that unknown relocation don't create a GOT or PLT entry */ enum gotplt_entry { @@ -1578,15 +1570,17 @@ enum gotplt_entry { AUTO_GOTPLT_ENTRY, /* generate if sym is UNDEF */ ALWAYS_GOTPLT_ENTRY /* always generate (eg. PLTOFF relocs) */ }; +#define NEED_RELOC_TYPE -#if !defined(ELF_OBJ_ONLY) || defined(TCC_TARGET_MACHO) -ST_FUNC int code_reloc (int reloc_type); -ST_FUNC int gotplt_entry_type (int reloc_type); -#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE +#if !defined TCC_TARGET_MACHO || defined TCC_IS_NATIVE ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr); ST_FUNC void relocate_plt(TCCState *s1); +ST_FUNC void build_got_entries(TCCState *s1); /* in tccelf.c */ +#define NEED_BUILD_GOT + #endif #endif + ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val); /* ------------ xxx-gen.c ------------ */ diff --git a/tccelf.c b/tccelf.c index d3ec823c..980aacfa 100644 --- a/tccelf.c +++ b/tccelf.c @@ -671,7 +671,7 @@ version_add (TCCState *s1) } dt_verneednum = nb_entries; } -#endif +#endif /* ndef ELF_OBJ_ONLY */ /* add an elf symbol : check if it is already defined and patch it. Return symbol index. NOTE that sh_num can be SHN_UNDEF. */ @@ -1121,7 +1121,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) } #endif -#if !defined(ELF_OBJ_ONLY) || (defined(TCC_TARGET_MACHO) && defined TCC_IS_NATIVE) +#ifdef NEED_BUILD_GOT static void build_got(TCCState *s1) { /* if no got, then create it */ @@ -1354,7 +1354,7 @@ redo: s1->plt->reloc->sh_info = s1->got->sh_num; } -#endif +#endif /* def NEED_BUILD_GOT */ ST_FUNC int set_global_sym(TCCState *s1, const char *name, Section *sec, addr_t offs) { @@ -1506,7 +1506,7 @@ ST_FUNC void tcc_add_btstub(TCCState *s1) cstr_free(&cstr); set_local_sym(s1, &"___rt_info"[!s1->leading_underscore], s, o); } -#endif +#endif /* def CONFIG_TCC_BACKTRACE */ static void tcc_tcov_add_file(TCCState *s1, const char *filename) { @@ -1615,7 +1615,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) #endif } } -#endif +#endif /* ndef TCC_TARGET_PE */ /* add various standard linker symbols (must be done after the sections are filled (for example after allocating common @@ -1688,7 +1688,6 @@ ST_FUNC void resolve_common_syms(TCCState *s1) } #ifndef ELF_OBJ_ONLY - ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel) { int sym_index = ELFW(R_SYM) (rel->r_info); @@ -3771,7 +3770,7 @@ static int ld_add_file(TCCState *s1, const char filename[]) static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) { - char filename[1024], libname[1016]; + char filename[1024], libname[1024]; int t, group, nblibs = 0, ret = 0; char **libs = NULL; diff --git a/tccgen.c b/tccgen.c index c78f1b29..4ca8fdc4 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1380,7 +1380,7 @@ static void tcc_debug_fix_anon(CType *t) if ((t->t & VT_BTYPE) == VT_STRUCT && t->ref->c != -1) for (i = 0; i < n_debug_anon_hash; i++) if (t->ref == debug_anon_hash[i].type) { - Sym sym = { .type = *t }; + Sym sym = {0}; sym .type = *t ; debug_type = tcc_get_dwarf_info(s1, &sym); for (j = 0; j < debug_anon_hash[i].n_debug_type; j++) @@ -1628,8 +1628,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) debug_type = tcc_debug_find(t, 1); if (debug_type == -1) { int pos_sib, pos_type; - CType ct = { VT_INT | (type & VT_UNSIGNED) , NULL }; - Sym sym = { .type = ct }; + Sym sym = {0}; sym .type.t = VT_INT | (type & VT_UNSIGNED) ; pos_type = tcc_get_dwarf_info(s1, &sym); debug_type = tcc_debug_add(t, 1); @@ -1705,8 +1704,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) } else if (type == (VT_PTR | VT_ARRAY)) { int sib_pos, sub_type; - CType ct = { VT_INT | VT_UNSIGNED , NULL }; - Sym sym = { .type = ct }; + Sym sym = {0}; sym .type.t = VT_INT | VT_UNSIGNED ; sub_type = tcc_get_dwarf_info(s1, &sym); i = dwarf_info_section->data_offset; diff --git a/tccmacho.c b/tccmacho.c index 8f5a7181..8e86b75f 100644 --- a/tccmacho.c +++ b/tccmacho.c @@ -262,8 +262,7 @@ static void * add_lc(struct macho *mo, uint32_t cmd, uint32_t cmdsize) static struct segment_command_64 * add_segment(struct macho *mo, const char *name) { struct segment_command_64 *sc = add_lc(mo, LC_SEGMENT_64, sizeof(*sc)); - strncpy(sc->segname, name, 16-1); - sc->segname[16-1] = '\0'; + strncpy(sc->segname, name, 16); mo->seg2lc[mo->nseg++] = mo->nlc - 1; return sc; } @@ -283,8 +282,7 @@ static int add_section(struct macho *mo, struct segment_command_64 **_seg, const seg = tcc_realloc(seg, sizeof(*seg) + seg->nsects * sizeof(*sec)); sec = (struct section_64*)((char*)seg + sizeof(*seg)) + ret; memset(sec, 0, sizeof(*sec)); - strncpy(sec->sectname, name, 16-1); - sec->sectname[16-1] = '\0'; + strncpy(sec->sectname, name, 16); strncpy(sec->segname, seg->segname, 16); *_seg = seg; return ret; diff --git a/tccpp.c b/tccpp.c index 2ff5d5e9..1f46c4a2 100644 --- a/tccpp.c +++ b/tccpp.c @@ -2038,10 +2038,14 @@ include_done: if (tok == TOK_STR) { if (file->true_filename == file->filename) file->true_filename = tcc_strdup(file->filename); - /* prepend directory from real file */ - pstrcpy(buf, sizeof buf, file->true_filename); - *tcc_basename(buf) = 0; - pstrcat(buf, sizeof buf, (char *)tokc.str.data); + q = (char *)tokc.str.data; + buf[0] = 0; + if (!IS_ABSPATH(q)) { + /* prepend directory from real file */ + pstrcpy(buf, sizeof buf, file->true_filename); + *tcc_basename(buf) = 0; + } + pstrcat(buf, sizeof buf, q); tcc_debug_putfile(s1, buf); } else if (parse_flags & PARSE_FLAG_ASM_FILE) break; @@ -3733,8 +3737,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) putdef(cs, "__CHAR_UNSIGNED__"); if (s1->optimize > 0) putdef(cs, "__OPTIMIZE__"); - if (s1->optimize == 's') - putdef(cs, "__OPTIMIZE_SIZE__"); if (s1->option_pthread) putdef(cs, "_REENTRANT"); if (s1->leading_underscore) diff --git a/tests/Makefile b/tests/Makefile index 8cc2e36c..aec40544 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,7 +5,7 @@ TOP = .. include $(TOP)/Makefile VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP) -CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS) +CFLAGS := $(filter-out -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS) # what tests to run TESTS = \ diff --git a/x86_64-link.c b/x86_64-link.c index 282443ff..cfd5db5d 100644 --- a/x86_64-link.c +++ b/x86_64-link.c @@ -23,7 +23,7 @@ #include "tcc.h" -#if !defined(ELF_OBJ_ONLY) || defined(TCC_TARGET_MACHO) +#ifdef NEED_RELOC_TYPE /* Returns 1 for a code relocation, 0 for a data relocation. For unknown relocations, returns -1. */ int code_reloc (int reloc_type) @@ -109,7 +109,7 @@ int gotplt_entry_type (int reloc_type) return -1; } -#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE +#ifdef NEED_BUILD_GOT ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) { Section *plt = s1->plt;