Browse Source

tcc: re-enable correct option -r support

Forgot about it.  It allows to compile several
sources (and other .o's) to one single .o file;

    tcc -r -o all.o f1.c f2.c f3.S o4.o ...

Also:
- option -fold-struct-init-code removed, no effect anymore
- (tcc_)set_environment() moved to tcc.c
- win32/lib/(win)crt1 minor fix & add dependency
- debug line output for asm (tcc -c -g xxx.S) enabled
- configure/Makefiles: x86-64 -> x86_64 changes
- README: cleanup
grischka 2 years ago
parent
commit
5f33d313c8
18 changed files with 178 additions and 151 deletions
  1. 2 2
      Changelog
  2. 3 3
      Makefile
  3. 6 15
      README
  4. 5 5
      configure
  5. 5 2
      lib/Makefile
  6. 0 19
      libtcc.c
  7. 2 2
      tcc-doc.texi
  8. 27 25
      tcc.c
  9. 8 5
      tcc.h
  10. 7 12
      tccasm.c
  11. 86 53
      tccgen.c
  12. 2 2
      tests/Makefile
  13. 2 2
      tests/tests2/Makefile
  14. 1 3
      win32/Makefile
  15. 12 0
      win32/include/_mingw.h
  16. 4 1
      win32/lib/crt1.c
  17. 4 0
      win32/lib/user32.def
  18. 2 0
      win32/lib/wincrt1.c

+ 2 - 2
Changelog

@@ -16,14 +16,14 @@ Platforms:
 - vastly improved support for ARM hard float calling convention
    (Thomas Preud'homme, Daniel Glöckner)
 - provide a runtime library for ARM (Thomas Preud'homme)
-- many x86-64 ABI fixes incl. XMM register passing and tests (James Lyon)
+- many x86_64 ABI fixes incl. XMM register passing and tests (James Lyon)
 - ABI tests with native compiler using libtcc (James Lyon)
 - UNICODE startup code supports wmain and wWinMain (YX Hao)
 
 Features:
 - VLA (variable length array) improved (James Lyon, Pip Cet)
 - import functions by ordinal in .def files on windows (YX Hao)
-- x86/x86-64 assembler much improved (Michael Matz)
+- x86/x86_64 assembler much improved (Michael Matz)
 - simple dead code suppression (Edmund Grimley Evans, Michael Matz, grischka)
 - implement round/fmin/fmax etc. math on windows (Avi Halachmi)
 - #pragma once support (Sergey Korshunoff, Vlad Vissoultchev, ...)

+ 3 - 3
Makefile

@@ -56,7 +56,7 @@ LDFLAGS_P = $(LDFLAGS)
 
 CONFIG_$(ARCH) = yes
 NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
-NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64
+NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
 NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
 NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
 NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
@@ -95,7 +95,7 @@ ARM64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c
 C67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c
 
 ifdef CONFIG_WIN32
- ifeq ($(ARCH),x86-64)
+ ifeq ($(ARCH),x86_64)
   NATIVE_FILES=$(WIN64_FILES)
   PROGS_CROSS=$(WIN32_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
   LIBTCC1_CROSS=lib/i386-win32/libtcc1.a
@@ -110,7 +110,7 @@ NATIVE_FILES=$(I386_FILES)
 PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
 LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a
 
-else ifeq ($(ARCH),x86-64)
+else ifeq ($(ARCH),x86_64)
 NATIVE_FILES=$(X86_64_FILES)
 PROGS_CROSS=$(I386_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
 LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a

+ 6 - 15
README

@@ -28,28 +28,19 @@ Features:
 Documentation:
 -------------
 
-1) Installation on a i386/x86_64/arm Linux/OSX/FreeBSD host (for Windows read tcc-win32.txt)
-
-Note: For OSX and FreeBSD, gmake should be used instead of make.
+1) Installation on a i386/x86_64/arm Linux/OSX/FreeBSD host
 
    ./configure
    make
    make test
    make install
 
-Alternatively, out-of-tree builds are supported: you may use different
-directories to hold build objects, kept separate from your source tree:
-
-   mkdir _build
-   cd _build
-   ../configure
-   make
-   make test
-   make install
+   Notes: For OSX and FreeBSD, gmake should be used instead of make.
+   For Windows read tcc-win32.txt.
 
-Texi2html must be installed to compile the doc. 
-By default, tcc is installed in /usr/local/bin.
-./configure --help  shows configuration options.
+makeinfo must be installed to compile the doc.  By default, tcc is
+installed in /usr/local/bin.  ./configure --help  shows configuration
+options.
 
 
 2) Introduction

+ 5 - 5
configure

@@ -163,8 +163,8 @@ case "$cpu" in
   x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386)
     cpu="x86"
   ;;
-  x86_64|amd64)
-    cpu="x86-64"
+  x86_64|amd64|x86-64)
+    cpu="x86_64"
   ;;
   arm*)
     case "$cpu" in
@@ -332,7 +332,7 @@ if test -z "$cross_prefix" ; then
       fi
 
       if test -z "$triplet"; then
-        if test $cpu = "x86-64" -o $cpu = "aarch64" ; then
+        if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
           if test -f "/usr/lib64/crti.o" ; then
             tcc_lddir="lib64"
           fi
@@ -453,8 +453,8 @@ echo "#define GCC_MINOR $gcc_minor" >> $TMPH
 
 if test "$cpu" = "x86" ; then
   echo "ARCH=i386" >> config.mak
-elif test "$cpu" = "x86-64" ; then
-  echo "ARCH=x86-64" >> config.mak
+elif test "$cpu" = "x86_64" ; then
+  echo "ARCH=x86_64" >> config.mak
 elif test "$cpu" = "armv4l" ; then
   echo "ARCH=arm" >> config.mak
   echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH

+ 5 - 2
lib/Makefile

@@ -9,14 +9,14 @@ VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
 ifndef TARGET
  # we're building the native libtcc1.a
  ifdef CONFIG_WIN32
-  ifeq ($(ARCH),x86-64)
+  ifeq ($(ARCH),x86_64)
    TARGET = x86_64-win32
   else
    TARGET = i386-win32
   endif
  else ifeq ($(ARCH),i386)
   TARGET = i386
- else ifeq ($(ARCH),x86-64)
+ else ifeq ($(ARCH),x86_64)
   TARGET = x86_64
  else ifeq ($(ARCH),arm)
   TARGET = arm
@@ -83,6 +83,9 @@ $(DIR)/%.o : %.c
 $(DIR)/%.o : %.S
 	$(XCC) -c $< -o $@ $(TGT) $(XFLAGS)
 
+$(DIR)/crt1w.o : crt1.c
+$(DIR)/wincrt1w.o : wincrt1.c
+
 $(OBJ) : $(DIR)/exists
 
 %/exists :

+ 0 - 19
libtcc.c

@@ -1572,7 +1572,6 @@ static const FlagDef options_f[] = {
     { offsetof(TCCState, nocommon), FD_INVERT, "common" },
     { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
     { offsetof(TCCState, ms_extensions), 0, "ms-extensions" },
-    { offsetof(TCCState, old_struct_init_code), 0, "old-struct-init-code" },
     { offsetof(TCCState, dollars_in_identifiers), 0, "dollars-in-identifiers" },
     { 0, 0, NULL }
 };
@@ -1984,21 +1983,3 @@ PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time)
     fprintf(stderr, "* %d bytes memory used\n", mem_max_size);
 #endif
 }
-
-PUB_FUNC void tcc_set_environment(TCCState *s)
-{
-    char * path;
-
-    path = getenv("C_INCLUDE_PATH");
-    if(path != NULL) {
-        tcc_add_include_path(s, path);
-    }
-    path = getenv("CPATH");
-    if(path != NULL) {
-        tcc_add_include_path(s, path);
-    }
-    path = getenv("LIBRARY_PATH");
-    if(path != NULL) {
-        tcc_add_library_path(s, path);
-    }
-}

+ 2 - 2
tcc-doc.texi

@@ -387,10 +387,10 @@ gcc's algorithm.
 Select the float ABI. Possible values: @code{softfp} and @code{hard}
 
 @item -mno-sse
-Do not use sse registers on x86-64
+Do not use sse registers on x86_64
 
 @item -m32, -m64
-Pass command line to the i386/x86-64 cross compiler.
+Pass command line to the i386/x86_64 cross compiler.
 
 @end table
 

+ 27 - 25
tcc.c

@@ -104,9 +104,8 @@ static const char help2[] =
     "  signed-char                   default char is signed\n"
     "  common                        use common section instead of bss\n"
     "  leading-underscore            decorate extern symbols\n"
-    "  ms-extensions                 allow struct w/o identifier\n"
+    "  ms-extensions                 allow anonymous struct in struct\n"
     "  dollars-in-identifiers        allow '$' in C symbols\n"
-    "  old-struct-init-code          some hack for parsing initializers\n"
     "-m... target specific options:\n"
     "  ms-bitfields                  use MSVC bitfield layout\n"
 #ifdef TCC_TARGET_ARM
@@ -151,32 +150,18 @@ static const char version[] =
         "C67"
 #elif defined TCC_TARGET_ARM
         "ARM"
-# ifdef TCC_ARM_HARDFLOAT
-        " Hard Float"
-# endif
 #elif defined TCC_TARGET_ARM64
         "AArch64"
-# ifdef TCC_ARM_HARDFLOAT
+#endif
+#ifdef TCC_ARM_HARDFLOAT
         " Hard Float"
-# endif
 #endif
 #ifdef TCC_TARGET_PE
         " Windows"
-#elif defined(__APPLE__)
-        /* Current Apple OS name as of 2016 */
-        " macOS"
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
         " FreeBSD"
-#elif defined(__DragonFly__)
-        " DragonFly BSD"
-#elif defined(__NetBSD__)
-        " NetBSD"
-#elif defined(__OpenBSD__)
-        " OpenBSD"
-#elif defined(__linux__)
-        " Linux"
 #else
-        " Unidentified system"
+        " Linux"
 #endif
     ")\n"
     ;
@@ -201,6 +186,24 @@ static void print_search_dirs(TCCState *s)
 #endif
 }
 
+static void set_environment(TCCState *s)
+{
+    char * path;
+
+    path = getenv("C_INCLUDE_PATH");
+    if(path != NULL) {
+        tcc_add_include_path(s, path);
+    }
+    path = getenv("CPATH");
+    if(path != NULL) {
+        tcc_add_include_path(s, path);
+    }
+    path = getenv("LIBRARY_PATH");
+    if(path != NULL) {
+        tcc_add_library_path(s, path);
+    }
+}
+
 static char *default_outputfile(TCCState *s, const char *first_file)
 {
     char buf[1024];
@@ -265,9 +268,6 @@ redo:
 #endif
         if (opt == OPT_V)
             return 0;
-
-        tcc_set_environment(s);
-
         if (opt == OPT_PRINT_DIRS) {
             /* initialize search dirs */
             tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
@@ -287,8 +287,8 @@ redo:
                 if (!s->ppfp)
                     tcc_error("could not write '%s'", s->outfile);
             }
-        } else if (s->output_type == TCC_OUTPUT_OBJ) {
-            if (s->nb_libraries != 0 && !s->option_r)
+        } else if (s->output_type == TCC_OUTPUT_OBJ && !s->option_r) {
+            if (s->nb_libraries)
                 tcc_error("cannot specify libraries with -c");
             if (n > 1 && s->outfile)
                 tcc_error("cannot specify output file with -c many files");
@@ -301,6 +301,7 @@ redo:
             start_time = getclock_ms();
     }
 
+    set_environment(s);
     if (s->output_type == 0)
         s->output_type = TCC_OUTPUT_EXE;
     tcc_set_output_type(s, s->output_type);
@@ -323,7 +324,8 @@ redo:
         }
         s->filetype = 0;
         s->alacarte_link = 1;
-        if (ret || --n == 0 || s->output_type == TCC_OUTPUT_OBJ)
+        if (ret || --n == 0
+            || (s->output_type == TCC_OUTPUT_OBJ && !s->option_r))
             break;
     }
 

+ 8 - 5
tcc.h

@@ -615,9 +615,7 @@ struct TCCState {
     /* C language options */
     int char_is_unsigned;
     int leading_underscore;
-    int ms_extensions;		/* allow nested named struct w/o identifier behave like unnamed */
-    int old_struct_init_code;	/* use old algorithm to init array in struct when there is no '{' used.
-				   Liuux 2.4.26 can't find initrd when compiled with a new algorithm */
+    int ms_extensions;	/* allow nested named struct w/o identifier behave like unnamed */
     int dollars_in_identifiers;	/* allows '$' char in indentifiers */
     int ms_bitfields; /* if true, emulate MS algorithm for aligning bitfields */
 
@@ -1147,10 +1145,8 @@ ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);
 
 ST_FUNC void tcc_add_pragma_libs(TCCState *s1);
 PUB_FUNC int tcc_add_library_err(TCCState *s, const char *f);
-
 PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time);
 PUB_FUNC int tcc_parse_args(TCCState *s, int *argc, char ***argv, int optind);
-PUB_FUNC void tcc_set_environment(TCCState *s);
 #ifdef _WIN32
 ST_FUNC char *normalize_slashes(char *path);
 #endif
@@ -1276,8 +1272,15 @@ ST_DATA int func_vc;
 ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */
 ST_DATA const char *funcname;
 
+ST_FUNC void tcc_debug_start(TCCState *s1);
+ST_FUNC void tcc_debug_end(TCCState *s1);
+ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym);
+ST_FUNC void tcc_debug_funcend(TCCState *s1, int size);
+ST_FUNC void tcc_debug_line(TCCState *s1);
+
 ST_FUNC void tccgen_start(TCCState *s1);
 ST_FUNC void tccgen_end(TCCState *s1);
+
 ST_FUNC void free_inline_functions(TCCState *s);
 ST_FUNC void check_vstack(void);
 

+ 7 - 12
tccasm.c

@@ -926,10 +926,13 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess, int global)
     set_idnum('.', IS_ID);
     if (do_preprocess)
         parse_flags |= PARSE_FLAG_PREPROCESS;
-    next();
     for(;;) {
+        next();
         if (tok == TOK_EOF)
             break;
+        /* generate line number info */
+        if (global && s1->do_debug)
+            tcc_debug_line(s1);
         parse_flags |= PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */
     redo:
         if (tok == '#') {
@@ -981,15 +984,12 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess, int global)
             }
         }
         /* end of line */
-        if (tok != ';' && tok != TOK_LINEFEED){
+        if (tok != ';' && tok != TOK_LINEFEED)
             expect("end of line");
-        }
         parse_flags &= ~PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */
-        next();
     }
 
     asm_free_labels(s1);
-
     return 0;
 }
 
@@ -1001,24 +1001,19 @@ ST_FUNC int tcc_assemble(TCCState *s1, int do_preprocess)
 
     define_start = define_stack;
     preprocess_start(s1);
+    tcc_debug_start(s1);
 
     /* default section is text */
     cur_text_section = text_section;
     ind = cur_text_section->data_offset;
     nocode_wanted = 0;
 
-    /* an elf symbol of type STT_FILE must be put so that STB_LOCAL
-       symbols can be safely used */
-    put_elf_sym(symtab_section, 0, 0,
-                ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0,
-                SHN_ABS, file->filename);
-
     ret = tcc_assemble_internal(s1, do_preprocess, 1);
 
     cur_text_section->data_offset = ind;
 
+    tcc_debug_end(s1);
     free_defines(define_start); 
-
     return ret;
 }
 

+ 86 - 53
tccgen.c

@@ -140,27 +140,9 @@ void pv (const char *lbl, int a, int b)
 #endif
 
 /* ------------------------------------------------------------------------- */
-ST_FUNC void tccgen_start(TCCState *s1)
+/* start of translation unit info */
+ST_FUNC void tcc_debug_start(TCCState *s1)
 {
-    cur_text_section = NULL;
-    funcname = "";
-    anon_sym = SYM_FIRST_ANOM;
-    section_sym = 0;
-    const_wanted = 0;
-    nocode_wanted = 1;
-
-    /* define some often used types */
-    int_type.t = VT_INT;
-    char_pointer_type.t = VT_BYTE;
-    mk_pointer(&char_pointer_type);
-#if PTR_SIZE == 4
-    size_type.t = VT_INT;
-#else
-    size_type.t = VT_LLONG;
-#endif
-    func_old_type.t = VT_FUNC;
-    func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
-
     if (s1->do_debug) {
         char buf[512];
 
@@ -177,12 +159,91 @@ ST_FUNC void tccgen_start(TCCState *s1)
                     text_section->data_offset, text_section, section_sym);
         put_stabs_r(file->filename, N_SO, 0, 0,
                     text_section->data_offset, text_section, section_sym);
+        last_ind = 0;
+        last_line_num = 0;
     }
+
     /* an elf symbol of type STT_FILE must be put so that STB_LOCAL
        symbols can be safely used */
     put_elf_sym(symtab_section, 0, 0,
                 ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0,
                 SHN_ABS, file->filename);
+}
+
+/* put end of translation unit info */
+ST_FUNC void tcc_debug_end(TCCState *s1)
+{
+    if (!s1->do_debug)
+        return;
+    put_stabs_r(NULL, N_SO, 0, 0,
+        text_section->data_offset, text_section, section_sym);
+
+}
+
+/* generate line number info */
+ST_FUNC void tcc_debug_line(TCCState *s1)
+{
+    if (!s1->do_debug)
+        return;
+    if ((last_line_num != file->line_num || last_ind != ind)) {
+        put_stabn(N_SLINE, 0, file->line_num, ind - func_ind);
+        last_ind = ind;
+        last_line_num = file->line_num;
+    }
+}
+
+/* put function symbol */
+ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym)
+{
+    char buf[512];
+
+    if (!s1->do_debug)
+        return;
+
+    /* stabs info */
+    /* XXX: we put here a dummy type */
+    snprintf(buf, sizeof(buf), "%s:%c1",
+             funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
+    put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
+                cur_text_section, sym->c);
+    /* //gr gdb wants a line at the function */
+    put_stabn(N_SLINE, 0, file->line_num, 0);
+
+    last_ind = 0;
+    last_line_num = 0;
+}
+
+/* put function size */
+ST_FUNC void tcc_debug_funcend(TCCState *s1, int size)
+{
+    if (!s1->do_debug)
+        return;
+    put_stabn(N_FUN, 0, 0, size);
+}
+
+/* ------------------------------------------------------------------------- */
+ST_FUNC void tccgen_start(TCCState *s1)
+{
+    cur_text_section = NULL;
+    funcname = "";
+    anon_sym = SYM_FIRST_ANOM;
+    section_sym = 0;
+    const_wanted = 0;
+    nocode_wanted = 1;
+
+    /* define some often used types */
+    int_type.t = VT_INT;
+    char_pointer_type.t = VT_BYTE;
+    mk_pointer(&char_pointer_type);
+#if PTR_SIZE == 4
+    size_type.t = VT_INT;
+#else
+    size_type.t = VT_LLONG;
+#endif
+    func_old_type.t = VT_FUNC;
+    func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
+
+    tcc_debug_start(s1);
 
 #ifdef TCC_TARGET_ARM
     arm_init(s1);
@@ -194,10 +255,7 @@ ST_FUNC void tccgen_end(TCCState *s1)
     gen_inline_functions(s1);
     check_vstack();
     /* end of translation unit info */
-    if (s1->do_debug) {
-        put_stabs_r(NULL, N_SO, 0, 0,
-                    text_section->data_offset, text_section, section_sym);
-    }
+    tcc_debug_end(s1);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -5567,12 +5625,8 @@ static void block(int *bsym, int *csym, int is_expr)
     Sym *s;
 
     /* generate line number info */
-    if (tcc_state->do_debug &&
-        (last_line_num != file->line_num || last_ind != ind)) {
-        put_stabn(N_SLINE, 0, file->line_num, ind - func_ind);
-        last_ind = ind;
-        last_line_num = file->line_num;
-    }
+    if (tcc_state->do_debug)
+        tcc_debug_line(tcc_state);
 
     if (is_expr) {
         /* default return value is (void) */
@@ -6741,22 +6795,6 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
     }
 }
 
-static void put_func_debug(Sym *sym)
-{
-    char buf[512];
-
-    /* stabs info */
-    /* XXX: we put here a dummy type */
-    snprintf(buf, sizeof(buf), "%s:%c1", 
-             funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
-    put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
-                cur_text_section, sym->c);
-    /* //gr gdb wants a line at the function */
-    put_stabn(N_SLINE, 0, file->line_num, 0); 
-    last_ind = 0;
-    last_line_num = 0;
-}
-
 /* parse an old style function declaration list */
 /* XXX: check multiple parameter */
 static void func_decl_list(Sym *func_sym)
@@ -6820,15 +6858,12 @@ static void gen_function(Sym *sym)
     vla_sp_loc = -1;
     vla_sp_root_loc = -1;
     /* put debug symbol */
-    if (tcc_state->do_debug)
-        put_func_debug(sym);
-
+    tcc_debug_funcstart(tcc_state, sym);
     /* push a dummy symbol to enable local sym storage */
     sym_push2(&local_stack, SYM_FIELD, 0, 0);
     local_scope = 1; /* for function parameters */
     gfunc_prolog(&sym->type);
     local_scope = 0;
-
     rsym = 0;
     block(NULL, NULL, 0);
     nocode_wanted = 0;
@@ -6847,9 +6882,7 @@ static void gen_function(Sym *sym)
     if (sym->type.t & VT_WEAK)
         weaken_symbol(sym);
     apply_visibility(sym, &sym->type);
-    if (tcc_state->do_debug) {
-        put_stabn(N_FUN, 0, 0, ind - func_ind);
-    }
+    tcc_debug_funcend(tcc_state, ind - func_ind);
     /* It's better to crash than to generate wrong code */
     cur_text_section = NULL;
     funcname = ""; /* for safety */

+ 2 - 2
tests/Makefile

@@ -36,13 +36,13 @@ endif
 ifeq ($(TARGETOS),Darwin)
  TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS))
 endif
-ifeq (,$(filter arm64 i386 x86-64,$(ARCH)))
+ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))
  TESTS := $(filter-out vla_test-run,$(TESTS))
 endif
 ifeq ($(CONFIG_arm_eabi),yes)
  TESTS := $(filter-out test3,$(TESTS))
 endif
-ifeq (,$(filter i386 x86-64,$(ARCH)))
+ifeq (,$(filter i386 x86_64,$(ARCH)))
  TESTS := $(filter-out dlltest,$(TESTS))
 endif
 

+ 2 - 2
tests/tests2/Makefile

@@ -22,10 +22,10 @@ endif
 ifeq ($(TARGETOS),Darwin)
  SKIP += 40_stdio.test
 endif
-ifeq ($(ARCH),x86-64)
+ifeq ($(ARCH),x86_64)
  SKIP += 73_arm64.test
 endif
-ifeq (,$(filter i386 x86-64,$(ARCH)))
+ifeq (,$(filter i386 x86_64,$(ARCH)))
  SKIP += 85_asm-outside-function.test
 endif
 

+ 1 - 3
win32/Makefile

@@ -24,11 +24,9 @@ TARGET	= $(CPU)
 ifeq ($(TARGET), 64)
 TFLAGS	= -m$(TARGET) -DTCC_TARGET_X86_64
 TARCH	= x86_64
-CARCH	= x86-64
 else
 TFLAGS	= -m$(TARGET) -DTCC_TARGET_I386
 TARCH	= i386
-CARCH	= i386
 endif
 
 all: pre bootstrap libs rebuild
@@ -36,7 +34,7 @@ all: pre bootstrap libs rebuild
 	@ls -ls *.exe
 
 pre:
-	@echo ARCH=$(CARCH) 1> ../config.mak
+	@echo ARCH=$(TARCH) 1> ../config.mak
 	@echo TARGETOS=Windows  1>> ../config.mak
 	@echo CONFIG_WIN32=yes 1>> ../config.mak
 	@echo TOPSRC=$$\(TOP\) 1>> ../config.mak

+ 12 - 0
win32/include/_mingw.h

@@ -139,6 +139,18 @@ typedef struct localeinfo_struct _locale_tstruct,*_locale_t;
 #define NOSERVICE 1
 #define NOMCX 1
 #define NOIME 1
+#define __INTRIN_H_
+#ifndef DUMMYUNIONNAME
+#  define DUMMYUNIONNAME
+#  define DUMMYUNIONNAME1
+#  define DUMMYUNIONNAME2
+#  define DUMMYUNIONNAME3
+#  define DUMMYUNIONNAME4
+#  define DUMMYUNIONNAME5
+#endif
+#ifndef DUMMYSTRUCTNAME
+#  define DUMMYSTRUCTNAME
+#endif
 #ifndef WINVER
 # define WINVER 0x0502
 #endif

+ 4 - 1
win32/lib/crt1.c

@@ -73,15 +73,18 @@ int _runtmain(int argc, /* as tcc passed in */ char **argv)
     _startupinfo start_info = {0};
 
     __tgetmainargs(&wargc, &wargv, &wenv, _dowildcard, &start_info);
+    /* may be wrong when tcc has received wildcards (*.c) */
     if (argc < wargc)
         wargv += wargc - argc;
+    else
+        argc = wargc;
 #define argv wargv
 #endif
 
 #ifdef __i386
     _controlfp(_PC_53, _MCW_PC);
 #endif
-    return _tmain(argc, argv, NULL);
+    return _tmain(argc, argv, _tenviron);
 }
 
 // =============================================

+ 4 - 0
win32/lib/user32.def

@@ -336,6 +336,10 @@ GetWindow
 GetWindowContextHelpId
 GetWindowDC
 GetWindowInfo
+GetWindowLongPtrA
+GetWindowLongPtrW
+SetWindowLongPtrA
+SetWindowLongPtrW
 GetWindowLongA
 GetWindowLongW
 GetWindowModuleFileNameA

+ 2 - 0
win32/lib/wincrt1.c

@@ -80,6 +80,8 @@ int _runtwinmain(int argc, /* as tcc passed in */ char **argv)
     __tgetmainargs(&wargc, &wargv, &wenv, 0, &start_info);
     if (argc < wargc)
         wargv += wargc - argc;
+    else
+        argc = wargc;
 #define argv wargv
 #endif