Skip to content

update tcc-windows to mob:2024-12-30 #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: thirdparty-windows-amd64
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
# thirdparty-windows-amd64 (tcc64, tccwin64)

This repository contains a prebuilt [tcc compiler](https://repo.or.cz/tinycc.git),
imported from https://github.com/vlang/tccbin_win,
whose source code is cut at commit
[9eef339](https://repo.or.cz/tinycc.git/commit/9eef33993ade2d3b964d19b1081978ceae5d359d) (20200605),
from the mob branch.
from the mob branch.

It is a ***minimalistic*** C compiler, that is just enough to be V's
backend. It is small and fast, although it does not produce optimised
executables. For that, use MSVC, GCC or CLANG instead.

## Target OS
The tcc build here produces ***64-bit executables***, compatiable with ***64-bit Windows***.
The tcc build here produces ***64-bit executables***, compatiable with ***64-bit Windows***.

## Build from source
1. Make sure you have `MSVC` and `git` installed.
2. Run the `build.bat` from ***current directory***,
```sh
.\scripts\build.bat
```
3. If you want to build tcc with a special commit, run the `build.bat` with COMMIT=...,
```sh
.\scripts\build.bat COMMIT=68000c01ae5b90a4b9677f7725a286e9057e9767
```

## Note
1. tcc is enabled with `BACKTRACE` and `BCHECK` via patch `win32\build-tcc.bat` (see `scripts\build-tcc.bat.patch`);
2. `include\tcc` is removed, as we use a pre-compiled `lib\openlibm.o` (see https://github.com/JuliaMath/openlibm)


## What if V reports missing C header files?
In this case, please create a PR to help us improve it.
Please try finding the missing header files in
[this](http://download.savannah.gnu.org/releases/tinycc/winapi-full-for-0.9.27.zip)
official full version of the WINAPI headers for tcc,
official full version of the WINAPI headers for tcc,
or in the releases of [MinGW64](https://sourceforge.net/projects/mingw-w64/).

Most of the time, the ported headers should just work if you copy them inside the include/ folder,
Expand Down
1 change: 1 addition & 0 deletions build_on_date.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024/12/30 22:12
1 change: 1 addition & 0 deletions build_source_hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
68000c01ae5b90a4b9677f7725a286e9057e9767
1 change: 1 addition & 0 deletions build_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tcc version 0.9.28rc 2024-12-30_mob@68000c01* (x86_64 Windows)
Binary file removed i386-win32-tcc.exe
Binary file not shown.
12 changes: 8 additions & 4 deletions include/_mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@
#define __stdcall __attribute__((__stdcall__))
#define _X86_ 1
#define _M_IX86 300 /* Visual Studio */
#define WIN32 1
#define _USE_32BIT_TIME_T
#ifndef __MINGW_USE_VC2005_COMPAT /* time became 64, but not timeval.tv_sec */
# ifndef _USE_32BIT_TIME_T
# define _USE_32BIT_TIME_T
# endif
#endif
#endif

/* in stddef.h */
Expand Down Expand Up @@ -150,15 +153,16 @@ typedef struct localeinfo_struct _locale_tstruct,*_locale_t;
# define DUMMYSTRUCTNAME
#endif
#ifndef WINVER
# define WINVER 0x0502
# define WINVER 0x0600
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x502
# define _WIN32_WINNT 0x600
#endif

#define __C89_NAMELESS
#define __MINGW_EXTENSION
#define WINAPI_FAMILY_PARTITION(X) 1
#define MINGW_HAS_SECURE_API
#define WIN32 1

#endif /* __MINGW_H */
2 changes: 1 addition & 1 deletion include/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {

#ifndef _CRT_ERRNO_DEFINED
#define _CRT_ERRNO_DEFINED
_CRTIMP extern int *__cdecl _errno(void);
_CRTIMP int *__cdecl _errno(void);
#define errno (*_errno())

errno_t __cdecl _set_errno(int _Value);
Expand Down
24 changes: 21 additions & 3 deletions include/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,37 @@
#define LDBL_MAX_EXP 16384
#define LDBL_MAX 1.18973149535723176502e+4932L
#define LDBL_MAX_10_EXP 4932
#define DECIMAL_DIG 21

#elif defined __aarch64__ || defined __riscv
/*
* Use values from:
* gcc -dM -E -xc /dev/null | grep LDBL | sed -e "s/__//g"
*/
#define LDBL_MANT_DIG 113
#define LDBL_DIG 33
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
#define LDBL_MIN_EXP (-16381)
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
#define LDBL_MIN_10_EXP (-4931)
#define LDBL_MAX_EXP 16384
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
#define LDBL_MAX_10_EXP 4932
#define DECIMAL_DIG 36

#else

/* same as IEEE double */
#define LDBL_MANT_DIG 53
#define LDBL_DIG 15
#define LDBL_EPSILON 2.2204460492503131e-16
#define LDBL_EPSILON 2.2204460492503131e-16L
#define LDBL_MIN_EXP (-1021)
#define LDBL_MIN 2.2250738585072014e-308
#define LDBL_MIN 2.2250738585072014e-308L
#define LDBL_MIN_10_EXP (-307)
#define LDBL_MAX_EXP 1024
#define LDBL_MAX 1.7976931348623157e+308
#define LDBL_MAX 1.7976931348623157e+308L
#define LDBL_MAX_10_EXP 308
#define DECIMAL_DIG 17

#endif

Expand Down
5 changes: 5 additions & 0 deletions include/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
#define SCHAR_MAX 127
#define UCHAR_MAX 0xff

#ifndef __CHAR_UNSIGNED__
#define CHAR_MIN SCHAR_MIN
#define CHAR_MAX SCHAR_MAX
#else
#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#endif

#define MB_LEN_MAX 5
#define SHRT_MIN (-32768)
Expand Down
4 changes: 2 additions & 2 deletions include/malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ extern "C" {
void *__cdecl malloc(size_t _Size);
void *__cdecl realloc(void *_Memory,size_t _NewSize);
_CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size);
/* _CRTIMP void __cdecl _aligned_free(void *_Memory);
_CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); */
_CRTIMP void __cdecl _aligned_free(void *_Memory);
_CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment);
_CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset);
_CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment);
_CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment);
Expand Down
Loading