GithubHelp home page GithubHelp logo

alien-tinycc's People

Contributors

cakirke avatar plicease avatar run4flat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pipcet cakirke calid

alien-tinycc's Issues

XS::TCC 0.03 can't find Alien::TinyCC's libtcc.a on Windows.

Hi

Now, XS::TCC 0.03 uses Alien::TinyCC for a tcc copy instead of shipping sources.

I got the following error when building it on windows.

dmake.exe:  Error: -- `\strawberry-perl-5.16-32bit\perl\site\lib\auto\share\dist\Alien-TinyCC\libtcc.a' not found, and can't be made

On linux, libtcc.a is in ..../auto/share/dist/Alien-TinyCC/lib directory.
but on windows, libtcc1.a is in ....\auto\share\dist\Alien-TinyCC\lib directory and libtcc.a is in ....\auto\share\dist\Alien-TinyCC\libtcc directory.

Why the directory structures are different between linux and windows?

shared version of libtcc.a (libtcc.so)

I think it would be interesting to do some FFI / tcc integration (see FFI::Raw), unfortunately the libtcc that this Alien module generates is static only. I was able to get a dynamic version of the library thus:

% ar xf .../perl5/auto/share/dist/Alien-TinyCC/lib/libtcc.a
% .../perl5/auto/share/dist/Alien-TinyCC/bin/tcc -shared -o libtcc.so *.o

and then use libtcc.so from a FFI::Raw script.

My experience with Alien::Base has shown that you don't want to use alien built dynamic libraries when creating .so files for XS modules, so perhaps the libtcc.so could be installed in a separate dynamic directory, so that it could be used by FFI but ignored by XS (this is what we do in Alien::Base when the alien_isolate_dynamic option is used).

Architecture-dependent install locations

Presently, on non-Windows builds, the compiler gets installed directly by tcc's makefile, using a pre-calculated prefix. This is bad for two reasons. First, the prefix is not architecture dependent. Second, the files are not noted in packlists or any other such mechanisms. To solve this, consider using ExtUtils::InstallPaths and/or ExtUtils::Install.

Build fail on Windows.

Hi,

Bundled tcc build script(src\win32\build-tcc.bat) for windows has some problem with 32/64bit strawberry perl's gcc.

The architecture name in strawberryperl-bundled gcc are
"i686-w64-mingw32-gcc" for 32bit and "x86_64-w64-mingw32-gcc" for 64bit.
They are different from build-tcc.bat
And architecture should be selected by following perl's architecture (We can use 32bit perl on 64bit OS)

The following is my patch for it.

--- build-tcc.bat.org   Wed Aug 21 19:14:17 2013
+++ build-tcc.bat   Wed Aug 21 22:38:04 2013
@@ -5,8 +5,8 @@
 @set /p VERSION= < ..\VERSION
 echo>..\config.h #define TCC_VERSION "%VERSION%"

-@if _%PROCESSOR_ARCHITEW6432%_==_AMD64_ goto x86_64
-@if _%PROCESSOR_ARCHITECTURE%_==_AMD64_ goto x86_64
+@FOR /F "delims=" %%i IN ('perl -MConfig -e "$_=$Config{archname}; m/^MSWin32-(.*?)-/; print $1"') DO set TMP_PERLARCH=%%i
+@if %TMP_PERLARCH%==x64 goto x86_64

 @set target=-DTCC_TARGET_PE -DTCC_TARGET_I386
 @set CC=gcc -Os -s -fno-strict-aliasing
@@ -16,7 +16,7 @@
 :x86_64
 @set target=-DTCC_TARGET_PE -DTCC_TARGET_X86_64
 @rem mingw 64 has an ICE with -Os
-@set CC=x86_64-pc-mingw32-gcc -O0 -s -fno-strict-aliasing
+@set CC=gcc -O0 -s -fno-strict-aliasing
 @set P=64
 @goto tools

Generating stand alone executable on FreeBSD

  1. compiling an executable on FreeBSD kernel produces an exe that seg faults, I am guessing in the boot strap code somewhere since even a trivial program int main() { return 0; } shows this behavior.
  2. reproduced this on both FreeBSD 10 64bit and Debian kFreeBSD so I do not believe the userland is the issue. I also get the same results from a Alien::TinyCC build.
  3. compiling code into the same process and executing it via the API works fine (tested via Alien::TinyCC and FFI::TinyCC), this is probably the more useful use case for me, so an explicit "this is not supported" would be considered acceptable to me (though obviously a fix would be better :)
  4. Just as an aside, starting with FreeBSD 10, clang is used instead of gcc as the bundled compiler, so perhaps consider using cc as the default compiler on FreeBSD (cc is gcc on 9 and clang on 10). cc might be the more appropriate default on other platforms as well.
freebsd64% ./configure --cc=clang
Binary  directory   /usr/local/bin
TinyCC directory    /usr/local/lib/tcc
Library directory   /usr/local/lib
Include directory   /usr/local/include
Manual directory    /usr/local/share/man
Info directory      /usr/local/share/info
Doc directory       /usr/local/share/doc/tcc
Target root prefix
Source path      /home/ollisg/dev/tinycc
C compiler       clang
Target OS        FreeBSD
CPU              x86-64
Big Endian       no
gprof enabled    no
cross compilers  no
use libgcc       no
Creating config.mak and config.h
freebsd64% gmake
gmake: Circular Makefile <- Makefile dependency dropped.
clang -o tcc.o -c tcc.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
clang -o libtcc.o -c libtcc.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
clang -o tccpp.o -c tccpp.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
tccpp.c:1312:7: warning: assigning to 'const unsigned char *' from 'const char *' converts between pointers to
      integer types with different sign [-Wpointer-sign]
    s = filename;
      ^ ~~~~~~~~
tccpp.c:2292:6: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
                                        p1, len, tcc_state->symtab_callback_data, 0);
                                        ^~
tccpp.c:2295:37: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
            ts = tok_alloc_new(pts, p1, len);
                                    ^~
tccpp.c:194:60: note: passing argument to parameter 'str' here
static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len)
                                                           ^
3 warnings generated.
clang -o tccgen.o -c tccgen.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
clang -o tccelf.o -c tccelf.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
tccelf.c:60:12: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types
      with different sign [-Wpointer-sign]
    strtab = s->link->data;
           ^ ~~~~~~~~~~~~~
tccelf.c:75:26: warning: passing 'char *' to parameter of type 'const unsigned char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
            h = elf_hash(strtab + sym->st_name) % nb_buckets;
                         ^~~~~~~~~~~~~~~~~~~~~
tccelf.c:38:52: note: passing argument to parameter 'name' here
static unsigned long elf_hash(const unsigned char *name)
                                                   ^
tccelf.c:117:26: warning: passing 'const char *' to parameter of type 'const unsigned char *' converts between
      pointers to integer types with different sign [-Wpointer-sign]
            h = elf_hash(name) % nbuckets;
                         ^~~~
tccelf.c:38:52: note: passing argument to parameter 'name' here
static unsigned long elf_hash(const unsigned char *name)
                                                   ^
tccelf.c:147:18: warning: passing 'const char *' to parameter of type 'const unsigned char *' converts between
      pointers to integer types with different sign [-Wpointer-sign]
    h = elf_hash(name) % nbuckets;
                 ^~~~
tccelf.c:38:52: note: passing argument to parameter 'name' here
static unsigned long elf_hash(const unsigned char *name)
                                                   ^
tccelf.c:151:15: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
        name1 = s->link->data + sym->st_name;
              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:434:18: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
            name = strtab_section->data + sym->st_name;
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:438:22: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
                name = symtab_section->link->data + sym->st_name;
                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1037:14: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
        name = symtab_section->link->data + sym->st_name;
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1628:30: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
                        name = symtab_section->link->data + sym->st_name;
                             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1664:53: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types
      with different sign [-Wpointer-sign]
                                            dynname = s1->dynsymtab_section->link->data
                                                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1694:30: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
                        name = symtab_section->link->data + sym->st_name;
                             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1712:30: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
                        name = s1->dynsymtab_section->link->data + esym->st_name;
                             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1756:34: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
                            name = symtab_section->link->data + sym->st_name;
                                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:1968:37: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
                        if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h:80:25: note: passing argument to parameter here
int      strcmp(const char *, const char *) __pure;
                            ^
tccelf.c:1972:37: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
                        if (!strcmp(strsec->data + s->sh_name, ".rel.bss")) { // rel_size == 0) {
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h:80:25: note: passing argument to parameter here
int      strcmp(const char *, const char *) __pure;
                            ^
tccelf.c:2432:17: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types
      with different sign [-Wpointer-sign]
        sh_name = strsec + sh->sh_name;
                ^ ~~~~~~~~~~~~~~~~~~~~
tccelf.c:2553:26: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types
      with different sign [-Wpointer-sign]
                    name = strtab + sym->st_name;
                         ^ ~~~~~~~~~~~~~~~~~~~~~
tccelf.c:2569:14: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types
      with different sign [-Wpointer-sign]
        name = strtab + sym->st_name;
             ^ ~~~~~~~~~~~~~~~~~~~~~
tccelf.c:2673:14: warning: assigning to 'const char *' from 'const uint8_t *' (aka 'const unsigned char *')
      converts between pointers to integer types with different sign [-Wpointer-sign]
    ar_names = ar_index + nsyms * 4;
             ^ ~~~~~~~~~~~~~~~~~~~~
tccelf.c:2810:20: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
            soname = dynstr + dt->d_un.d_val;
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~
tccelf.c:2839:14: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
        name = dynstr + sym->st_name;
             ^ ~~~~~~~~~~~~~~~~~~~~~
tccelf.c:2848:18: warning: assigning to 'const char *' from 'unsigned char *' converts between pointers to integer
      types with different sign [-Wpointer-sign]
            name = dynstr + dt->d_un.d_val;
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~
22 warnings generated.
clang -o tccasm.o -c tccasm.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
tccasm.c:541:72: warning: data argument not used by format string [-Wformat-extra-args]
            sprintf(sname, (n?".%s%d":".%s"), get_tok_str(tok1, NULL), n);
                                      ~~~~~                            ^
1 warning generated.
clang -o tccrun.o -c tccrun.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
tccrun.c:228:5: warning: implicit declaration of function '__clear_cache' is invalid in C99
      [-Wimplicit-function-declaration]
    __clear_cache(ptr, ptr + length);
    ^
tccrun.c:257:18: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types
      with different sign [-Wpointer-sign]
        stab_str = stabstr_section->data;
                 ^ ~~~~~~~~~~~~~~~~~~~~~
tccrun.c:350:29: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
                            strtab_section->data + sym->st_name);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./tcc.h:1031:61: note: passing argument to parameter 's' here
PUB_FUNC char *pstrcpy(char *buf, int buf_size, const char *s);
                                                            ^
3 warnings generated.
clang -o x86_64-gen.o -c x86_64-gen.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
clang -o i386-asm.o -c i386-asm.c -DTCC_TARGET_X86_64 -I.  -Wall -g -O2 -fheinous-gnu-extensions
ar rcs libtcc.a libtcc.o tccpp.o tccgen.o tccelf.o tccasm.o tccrun.o x86_64-gen.o i386-asm.o
clang -o tcc tcc.o libtcc.a -lm -I.  -Wall -g -O2 -fheinous-gnu-extensions
clang: warning: argument unused during compilation: '-fheinous-gnu-extensions'
gmake -C lib native
gmake[1]: Entering directory `/usr/home/ollisg/dev/tinycc/lib'
mkdir -p x86_64
clang -c libtcc1.c -o x86_64/libtcc1.o -I..  -Wall -g -O2 -fheinous-gnu-extensions -DTCC_TARGET_X86_64
clang -c alloca86_64.S -o x86_64/alloca86_64.o -I..  -Wall -g -O2 -fheinous-gnu-extensions -DTCC_TARGET_X86_64
ar rcs ../libtcc1.a x86_64/libtcc1.o x86_64/alloca86_64.o
gmake[1]: Leaving directory `/usr/home/ollisg/dev/tinycc/lib'
./texi2pod.pl tcc-doc.texi tcc.pod
pod2man --section=1 --center="Tiny C Compiler" --release=`cat ./VERSION` tcc.pod > tcc.1
makeinfo --no-split --html --number-sections -o tcc-doc.html tcc-doc.texi
makeinfo tcc-doc.texi
freebsd64% gmake test
gmake: Circular Makefile <- Makefile dependency dropped.
gmake -C tests test
gmake[1]: Entering directory `/usr/home/ollisg/dev/tinycc/tests'
------------ hello-exe ------------
../tcc -B.. -I.. -I.. -I../include ../examples/ex1.c -o hello || (../tcc -vv; exit 1) && ./hello
gmake[1]: *** [hello-exe] Bus error (core dumped)
gmake[1]: Leaving directory `/usr/home/ollisg/dev/tinycc/tests'
gmake: *** [test] Error 2

t/30-tcc-test-suite.t fails on some linux systems

On my Ubuntu 18.04 smoker the test suite fails:

In file included from src/tests/tests2/32_led.c:31:
In file included from /usr/include/stdlib.h:394:
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:205:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:53: error: stray '\' in program

#   Failed test 'tcc test src/tests/tests2/32_led.c'
#   at t/30-tcc-test-suite.t line 79.
#          got: ''
#     expected: '     _   _       _       _
#   |  _|  _| |_| |_  |_    |
#   | |_   _|   |  _| |_|   |'
# Looks like you failed 1 test of 52.
t/30-tcc-test-suite.t .. 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/52 subtests 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.