Commit Graph

147 Commits (9ba76ac834608f76b734674048a7cc4334051e32)

Author SHA1 Message Date
Christian Jullien 6d559d651f Add -O2 when compiling tcc on Windows. Not sure this flag is really used by tcc. 2017-06-10 06:35:11 +02:00
U-NELSON\jullien 3e4b7693bf force i386-win32-tcc.exe to be a 32bit binary. Run tests in both 32/64 bits on Windows. 2017-06-05 08:18:11 +02:00
U-NELSON\jullien 2a348896dd Add more common tests to be run from win32/Makefile 2017-06-04 09:27:48 +02:00
Christian Jullien 0cc4e570bc Windows test Makefile target also test pp tests. 2017-05-28 07:12:57 +02:00
Christian Jullien f12851e388 Add -static to be in sync with Windows bat. 2017-04-27 07:01:46 +02:00
grischka 7acf9aa862 final adjustments for release
- configure/Makefiles: minor adjustments

- build-tcc.bat: add -static to gcc options
  (avoids libgcc_s*.dll dependency with some mingw versions)

- tccpe.c/tcctools.c: eliminate MAX_PATH
  (not available for cross compilers)

- tccasm.c: use uint64_t/strtoull in unary()
  (unsigned long sometimes is only uint32_t, as always on windows)

- tccgen.c: Revert (f077d16c) "tccgen: gen_cast: cast FLOAT to DOUBLE"
  Was a rather experimental, tentative commit, not really necessary
  and somewhat ugly too.

- cleanup recent osx support:
  - Makefile/libtcc.c: cleanup copy&paste code
  - tccpp.c: restore deleted function
2017-04-25 21:01:54 +02:00
grischka 536ed76d5a tccgen/win32: let __declspec(dllimport) imply extern
Also, retain storage qualifiers in type_decl, in particular
also for function pointers.  This allows to get rid of this
very early hack in decl()
    type.t |= (btype.t & VT_STATIC); /* Retain "static". */
which was to fix the case of
    int main() { static int (*foo)(); ...

Also:
- missing __declspec(dllimport) is an error now
- except if the symbol is "_imp__symbol"
- demonstrate export/import of data in the dll example (while
  'extern' isn't strictly required with dllimport anymore)
- new function 'patch_storage()' replaces 'weaken_symbol()'
  and 'apply_visibility()'
- new function 'update_storage()' applies storage attributes
  to Elf symbols.
- put_extern_sym/2 accepts new pseudo section SECTION_COMMON
- add -Wl,-export-all-symbols as alias for -rdynamic
- add -Wl,-subsystem=windows for mingw compatibility
- redefinition of 'sym' error for initialized global data
2017-04-04 08:34:52 +02:00
grischka bb93064d78 makefile: unify cross with native builds
supports building cross compilers on the fly without need
for configure --enable-cross

   $ make cross          # all compilers
   $ make cross-TARGET   # only TARGET-compiler & its libtcc1.a

with TARGET one from
   i386 x86_64 i386-win32 x86_64-win32 arm arm64 arm-wince c67

Type 'make help' for more information
2017-02-25 12:51:04 +01:00
Christian Jullien 669f61117d Cygwin Makefile was to aggresive to remove entire lib/ 2017-02-24 22:51:10 +01:00
Christian Jullien 2e0a8f9b37 Update Cygwin Makefile for new libtcc1-xx.a layout 2017-02-24 22:39:06 +01:00
grischka 569255e6c4 cross-compilers: allow individual configuration
since configure supports only native configuration
a file 'cross-tcc.mak' needs to be created manually.
It is included in the Makefile if present.

# ----------------------------------------------------
# Example config-cross.mak:
#
# windows -> i386-linux cross-compiler
# (it expects the linux files in <prefix>/i386-linux)

ROOT-i386 = {B}/i386-linux
CRT-i386 = $(ROOT-i386)/usr/lib
LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib
INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include
DEF-i386 += -D__linux__

# ----------------------------------------------------

Also:
- use libtcc1-<target>.a instead of directories
- add dummy arm assembler
- remove include dependencies from armeabi.c/lib-arm64.c
- tccelf/ld_add_file: add SYSROOT (when defined) to absolute
  filenames coming from ld-scripts
2017-02-23 08:41:57 +01:00
grischka 5f33d313c8 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
2017-02-20 18:58:08 +01:00
Christian Jullien 399237850d Update cygwin Makefile after recent Windows source changes 2017-02-18 14:53:31 +01:00
grischka 2d3b9559bf tcctools.c: integrate tiny_libmaker/_impdef
usage:
    tcc -ar [rcsv] lib files...
    tcc -impdef lib.dll [-v] [-o lib.def]

also:
- support more files with -c: tcc -c f1.c f2.c ...
- fix a bug which caused tcc f1.c f2.S to produce no asm
- allow tcc -ar @listfile too
- change prototype: _void_ tcc_set_options(...)
- apply -Wl,-whole-archive when a librariy is given
  as libxxx.a also (not just for -lxxx)
2017-02-18 09:55:34 +01:00
grischka 096125d963 win32: adjust new unicode support
- lib/Makefile: add (win)crt1_w.o

- crt1.c/_runtmain: return to tcc & only use for UNICODE
  (because it might be not 100% reliable with for example
  wildcards (tcc *.c -run ...)

- tccrun.c/tccpe.c: load -run startup_code only if called
  from tcc_run(). Otherwise main may not be defined.  See
  libtcc_test.c

- tests2/Makefile: pass extra options in FLAGS to allow
  overriding TCC

Also:
- tccpe.c: support weak attribute.  (I first tried to solve
  the problem above by using it but then didn't)
2017-02-18 09:51:23 +01:00
Christian Jullien 9bd04fa000 Makefile for Windows native tcc handles recent UNICODE support 2017-02-18 08:00:58 +01:00
YX Hao 86e3cd0c5a Add support for Unicode entries 'wmain' and 'wWinMain' on Windows
'-run' suported. argvs are converted.
But don't use compliled Unicode CLI exe-file to get inputs interactively in other codepage!
Please add other compliling supports than 'build-tcc.bat' (Who is good at them).
2017-02-17 21:09:26 +08:00
Christian Jullien f33801e25e Add entry to run tests2 tests 2017-02-17 08:05:38 +01:00
Christian Jullien d61985b37a tiny_impldef.exe was not built by Makefile 2017-02-16 07:01:44 +01:00
Vlad Vissoultchev 67fe371f84 win32: build-tcc.bat: figure out correct bitness of cl.exe 2017-02-14 11:45:35 +02:00
Christian Jullien 5550e4336f Improve cygwin Makefile that now support TARGET=32/64 to force final version for 32/64 platform 2017-02-14 05:51:45 +01:00
grischka 43d9a7de9b updates & cleanups (tcc-doc/Changelog/TODO ...)
- tcc-doc.texi: commandline option info update
- Changelog/TODO: update
- tests/tcctest.py: removed
- tests/Makefile: weaktest fixed
- tests/tests2: some files renamed and/or converted to unix LF
- configure/Makefile: --enable-static option (no dll on win32)
- win32/build-tcc.bat: msvc support
- win32/tcc-win32.txt: build info update
- win32/vs2015/: VS solution removed
- win32/include/tcc/tcc_libm.h: #include statement fixed
- tcc.c: -include <file> option help info
- .gitignore: cleanup
2017-02-13 19:03:29 +01:00
Christian Jullien 9817204d8a Detect native version from default gcc target. 2017-02-12 17:06:27 +01:00
Christian Jullien 417a1ed384 Add Makefile to build native tcc 32/64 on Windows using cygwin 2017-02-12 12:14:27 +01:00
Vlad Vissoultchev 910a6bc859 Add pre-build step in VS2015 projects to generate config.h from VERSION 2017-02-09 13:31:12 +02:00
grischka aa0a45be05 win32: build-tcc.bat: add some options
In particular:

-c <compiler> : Allow using tcc to compile itself
-i <dir>      : Create installation in dir

Summary:

usage: build-tcc.bat [ options ... ]
options:
  -c prog              use prog (gcc or tcc) to compile tcc
  -c "prog options"    use prog with options to compile tcc
  -t 32/64             force 32/64 bit default target
  -v "version"         set tcc version
  -i dir               install tcc into dir
  -d                   create tcc-doc.html too (needs makeinfo)
2017-02-08 19:53:49 +01:00
grischka e596b871a9 win32: include/winapi: remove more files
Also: use _assert, older msvcrt does not have _wassert
2017-02-08 19:53:02 +01:00
grischka bfd1c08d6c tccrun/win64: cleanup runtime function table
- call RtlDeleteFunctionTable
  (important for multiple compilations)

- the RUNTIME_FUNCTION* is now at the beginning of the
  runtime memory.  Therefor when tcc_relocate is called
  with user memory, this should be done manually before
  it is free'd:
      RtlDeleteFunctionTable(*(void**)user_mem);
      [ free(user_mem); ]

- x86_64-gen.c: expand char/short return values to int
2016-10-19 19:21:27 +02:00
grischka 0be098929a tccpp_new/delete and other cleanups 2016-10-17 23:24:01 +02:00
grischka f350487e1e win32/64: msys2 support
Support ./configure && make under msys2 (a new msys fork)
on win32 and win64.

Get rid of CONFIG_WIN64 make-var. (On windows, WIN32 in
general is used for both 32 and 64 bit platforms)

Also:
- cleanup win32/build-tcc.bat
- adjust win32/(doc/)tcc-win32.tx
2016-10-02 01:39:07 +02:00
grischka 0a624782df build: revert Makefiles to 0.9.26 state (mostly)
Except
- that libtcc1.a is now installed in subdirs i386/ etc.
- the support for arm and arm64
- some of the "Darwin" fixes
- tests are mosly unchanged

Also
- removed the "legacy links for cross compilers" (was total mess)
- removed "out-of-tree" build support (was broken anyway)
2016-10-01 21:06:33 +02:00
grischka 8637c1d0ad Remove misc. files
- from win32/include/winapi: various .h

  The winapi header set cannot be complete no matter what.  So
  lets have just the minimal set necessary to compile the examples.

- remove CMake support (hard to keep up to date)
- some other files

Also, drop useless changes in win32/lib/(win)crt1.c
2016-10-01 20:27:41 +02:00
Jean-Claude Beaudoin 889ee28ed5 Rein in unintended external functions on Windows. 2016-09-27 01:43:40 -04:00
Avi Halachmi (:avih) 1751588435 tiny_libmaker: fix a comment 2016-06-19 22:19:06 +03:00
Avi Halachmi (:avih) 3f21d81073 win32: _mingw.h: add definition for _TRUNCATE from newer _mingw.h 2016-06-19 14:44:31 +03:00
Avi Halachmi (:avih) ab8422c8e7 win32: malloc.h: use alloca instead of (missing) _alloca
_alloca is not part of msvcrt (and therefore not found if used), and tcc has
an internal implementation for alloca for x86[_64] since d778bde7 - initally
as _alloca and later changed to alloca. Use it instead.
2016-06-19 14:44:18 +03:00
Avi Halachmi (:avih) b67951bed4 win32: wchar.h: don't redifine WCHAR_MIN[/MAX] (after stdint.h) 2016-06-19 14:44:07 +03:00
Avi Halachmi (:avih) 100f94be99 tiny_libmaker: more robust arguments interpretation
- Syntax is now much closer to gnu ar, but still supports whatever was
  supported before, with the following exceptions (which gnu ar has too):
  - lib is now mandatory (was optional and defaulted to ar_test.a before).
  - Path cannot start with '-' (but ./-myfile.o is OK).
- Unlike gnu ar, modes are still optional (as before).
- Now supports also (like gnu ar):
  - First argument as options doesn't have to start with '-', later options do.
  - Now supports mode v (verbose) with same output format as gnu ar.
  - Any names for lib/objs (were limited to .a/.o - broke cmake on windows).
  - Now explicitly fail on options which would be destructive for the user.
  - Now doesn't get confused by options between file arguments.
- Still ignores other unknown options - as before.
- Now doesn't read out-of-bounds if an option is one char.

- As a result, cmake for windows can now use tiny_libmaker as ar, and
  configure can also detect tiny_libmaker as a valid ar (both couldn't before).

Ignoring all options could previously cause to misinterpret the mode in a
destructive way, e.g. if the user wanted to do something with an existing
archive (such as p - print, or x - extract, etc), then it would instead just
delete (re-create) the archive.

Modes which can be destructive if ignored now explicitly fail. These include
[habdioptxN]. Note that 'h' can be ignored, but this way we also implicitly
print the usage for -h/--help.

The .a/.o name limitations previously resulted in complete failure on some
cases, such as cmake on windows which uses <filename>.obj and <libname>.lib .

Fixed: e.g. 'tiny_libmaker r x.a x.o' was reading out of bounds [-1] for 'r'.
2016-06-19 14:43:46 +03:00
grischka d48662d496 tccgen: scopes levels for local symbols (update 1)
Catch top level redeclarations too.

Also fix mistakes in tcctest.c and the tcc sources (win32)
showing up now.
2016-05-05 20:04:00 +02:00
Vlad Vissoultchev 98ffeaa0c5 win32: Better VS2015 solution and project files
These include all header and source files from source directory
2016-04-13 11:10:13 +03:00
seyko a1a5c81e6c win32: Add missing header files for nginx compilation
From: Vlad Vissoultchev
    Date: Tue, 12 Apr 2016 21:02:43 +0300
    Subject: win32: Add missing header files for nginx compilation

    The new ones are hoisted from mingw-w64 as most other headers under
    `win32/include/winapi`
2016-04-13 06:51:59 +03:00
seyko 52d194a1e6 VS2015 solution and project files
From: Vlad Vissoultchev
    Date: Mon, 11 Apr 2016 01:32:28 +0300
    Subject: Add VS2015 solution and project files to `win32/vs2015`
             directory

    This allows release/debug builds for both x86 and x64 targets. Some
    warnings had to be suppressed.

    Output libtcc.dll and tcc.exe are copied to parent `win32` directory
    w/ a post-build action.
2016-04-13 06:29:24 +03:00
Vlad Vissoultchev 5175b1ad87 Use proper ifdef for x64 check in winnt.h 2016-03-14 18:07:38 +02:00
Vlad Vissoultchev 712eca44d5 Revert spawnvp param cast and use `no-incompatible-pointer-types` in build-tcc.bat 2016-03-14 18:06:42 +02:00
Vlad Vissoultchev d715ebdae0 Add x64 SEH decls. Add exports to kernel32.def 2016-03-13 04:23:15 +02:00
Vlad Vissoultchev 95aac21130 Move WIN32_LEAN_AND_MEAN to windows.h (silence redeclarations) 2016-03-13 04:21:23 +02:00
Vlad Vissoultchev 2dc7161453 Win32 build script handles `x64` and `debug` params 2016-03-13 04:19:32 +02:00
Avi Halachmi (:avih) 9d33388b29 win: libm: add implementation for round/fmin/fmax and variants
round and fmin/fmax are relatively commonly used functions but were not
implemented anywhere in the tcc Windows distribution package. Newer mingw(64)
math.h stil doesn't include these implementations.

Add C implementations for these functions and place it as inline functions at
win32/include/tcc/tcc_libm.h - which is already included from math.h .

The code is mostly taken from musl-libc rs-1.0 (MIT) [*],

musl-libc: http://git.musl-libc.org/cgit/musl/tree/src/math?h=rs-1.0
license:   http://git.musl-libc.org/cgit/musl/tree/COPYRIGHT?h=rs-1.0

Potential enhancements:
- Check how many useful libm implementations are still missing and consider
  adding them (some of them already work via the MS runtime).
- Consider putting libm implementations in an actual libm.a file, or add a dummy
  one such that build processes which try to link with libm will not fail.
2015-11-07 22:31:57 +02:00
Avi Halachmi (:avih) 9c52ba48b3 win: math.h: fix fpclassify/signbit/etc - use C instead of broken asm
The asm code cannot currently be used with tcc since tcc doesn't support 't'
constraint.

Use inline C implementation instead, place it win32/include/tcc/tcc_libm.h, and
include it from win32/include/math.h.

Since fpclassify now works, it also fixes few other macros which depend on it.
Implicitly fixed: isfinite, isinf, isnan, isnormal.

The implementations were taken from musl-libc rs-1.0 (MIT license).

musl-libc: http://git.musl-libc.org/cgit/musl/tree/src/math?h=rs-1.0
license:   http://git.musl-libc.org/cgit/musl/tree/COPYRIGHT?h=rs-1.0
2015-11-07 22:18:46 +02:00
Avi Halachmi (:avih) 6e261a107c win: math.h: isnan: use macro, similar to others (still broken)
It was broken due to tcc not able to compile asm with 't' constraint, and it's
still broken because fpclassify on which it now depends has the same issue. Next
commit will fix this.
2015-11-07 22:17:21 +02:00