tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] x86_64-win32-tcc.exe built with tcc (32) crashes. Wor


From: avih
Subject: Re: [Tinycc-devel] x86_64-win32-tcc.exe built with tcc (32) crashes. Works if built with gcc (32)
Date: Fri, 14 Oct 2016 09:04:14 +0000 (UTC)

Thanks, I can confirm it now works.

Agreed that a shorter list of steps to reproduce would have been nicer, but I didn't know how to create one so my second best was to try to make it really reproducible with that long list.

I also got to that line (tccpe.c:1184) with printf debugging but forgot to mention that at my bug report. Regardless though, I wasn't able to figure out what was wrong with it and why/how it was different from xtcc built with gcc.

FWIW, it's now possible to start with tcc32 windows binaries, use it to build a tcc cross compiler to win64, use that to build native windows tcc64, use that to build cross compiler to win32, and use that to build native windows tcc32 - which are bit-identical to the original native windows tcc32 with which we started (assuming the original tcc32 was built with tcc).




On Thursday, October 13, 2016 8:24 PM, grischka <address@hidden> wrote:


Uhm, that is not exactly the 5 lines isolated bug test case we'd wish.

Thanks anyway.  Please retry.

FYI, the offending line was tccpe.c:1184

    *(DWORD*)(s->data + rel->r_offset) += addr - pe->imagebase;

and what happens here is that tcc is trying to create code for adding
PTR s->data and long long r_offset which, for 32bit targets, didn't
work well at all.

--- grischka

avih wrote:
> TL;DR:------
> When using native tcc (32) to build tcc cross compilers, the resulting tcc cross compiler to windows x86_64 crashes when trying to create an executable. However, if using gcc (32) to build tcc cross compilers, the resulting tcc cross compiler to windows x86_64 seems to work. Compile-only seems to work and create identical object files, and libtcc1.a is also identical between the two cross compilers.
>
> The long versions and steps to reproduce, from scratch if you need:
> Setup msys2, build env and tcc:
> -------------------------------
>
> 1. Download and install msys2 from http://msys2.github.io/ (I got msys2-x86_64-20160921.exe) - can be used for native 32 or 64 gcc
> 2. Possibly follow the instructions to self-update (you may need to kill a stray pacman.exe process after closing the terminal)
> 3. Install required tools: pacman -S --force git make diffutils texinfo mingw-w64-i686-gcc
>    * due to bug at the current installer, the first 32 and 64 installs require --force: https://github.com/Alexpux/MSYS2-packages/issues/689
>
> 4. Close the terminal and open the mingw 32 shell environment: double click mingw32.exe
>
> 5. Get tcc: cd /c/ && git clone git://repo.or.cz/tinycc.git
>
>
> Builds, tests and installs should complete successfully (assuming tcc was cloned to /c/tinycc):
> --------------------------------------------------------
>
> 6. Build (with gcc i686)/test/install native tcc 32 and cross compilers. Needs --cpu since `uname -m` reports x86_64 (on a 64 system):
>    cd /c/tinycc && mkdir with-gcc32 && cd with-gcc32 && ../configure --cpu=i386 --enable-cross --prefix=$(pwd)/dist && make && make test && make install
>
> 7. Build/test/install native tcc 32 and cross compilers again, now using the newly built tcc 32 (it's fast! yay!):
>    cd /c/tinycc && mkdir with-tcc32 && cd with-tcc32 && ../configure --cpu=i386 --enable-cross --prefix=$(pwd)/dist --cc=/c/tinycc/with-gcc32/dist/tcc.exe --ar=/c/tinycc/with-gcc32/dist/tiny_libmaker.exe && make && make test && make install
>
>
> The bug:
> --------
>
> 8. Create a test file: cd /c/tinycc && echo "int main(int argc, char **argv) { return argc - 1; }" > test.c
>
> 9. Build the test file with x86_64-win32-tcc.exe which was built using gcc: ./with-gcc32/dist/x86_64-win32-tcc.exe test.c
>    - The build succeeds and the resulting test.exe is functional, e.g. this prints 3: ./test.exe 1 2 3; echo $?
>
> 10 Same as above but using x86_64-win32-tcc.exe which was built using tcc: ./with-tcc32/dist/x86_64-win32-tcc.exe test.c
>    - crash/segmentation fault
>
>
> Notes:
> ------
>
> - Both compilers can run and report expected paths: ./with-{g|t}cc32/dist/x86_64-win32-tcc.exe -vv
> - The lib objects (which were compiled with the respective x86_64-win32-tcc.exe) and the resulting libtcc1.a are identical at ./with-{g|t}cc32/lib/x86_64-win32/ and at ./with-{g|t}cc32/dist/lib/64
> - Compile only (-c) of the test file works and creates identical test.o with both cross compilers.  - The one with gcc succeeds link: `./with-gcc32/dist/x86_64-win32-tcc.exe -o test.exe test.o`
>  - The one with tcc crashes: `./with-tcc32/dist/x86_64-win32-tcc.exe -o test.exe test.o`



reply via email to

[Prev in Thread] Current Thread [Next in Thread]