tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Problem after compiling tiny CC


From: Clive Tovero
Subject: [Tinycc-devel] Problem after compiling tiny CC
Date: Fri, 25 Jun 2021 15:47:30 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

# It would help if you could provide more information.  This is a log
# of commands I used to test a minimal example for your _first issue_ on
# Debian.  Can you get this to work?  How does your source and build
# differ? Tcc commit hash? Output from "uname -a"?

clive@akira:~/temp$ uname -a
Linux akira 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
clive@akira:~/temp$ git clone https://repo.or.cz/tinycc.git
Cloning into 'tinycc'...
[...]

clive@akira:~/temp$ cd tinycc && git log -1 | grep commit && cd ..
commit b5d4b908c4f69642944060e8a38b00d2b82ad053

clive@akira:~/temp$ cd tinycc && ./configure && make && cd ..
[...]

C compiler          gcc (8.3)
Target OS           Linux
CPU                 x86_64
Triplet             x86_64-linux-gnu

[...]

gcc -o tcc.o -c tcc.c -DCONFIG_TRIPLET="\"x86_64-linux-gnu\"" -DTCC_TARGET_X86_64 -DONE_SOURCE=0 -DTCC_GIT_HASH="\"b5d4b90\"" -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -Wno-format-truncation -I.

[...]

clive@akira:~/temp$ cat a.c
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
    void* handle = dlopen("./b.so", RTLD_NOW);
    if (! handle) { fprintf(stderr, "%s\n", dlerror()); exit(1); }
    dlerror();
    int (*b)(int) = (int (*)(int)) dlsym(handle, "b");
    if (! b) { fprintf(stderr, "%s\n", dlerror()); exit(1); }
    printf("b: %d\n", b(-1));
    dlclose(handle);

    return 0;
}
clive@akira:~/temp$ gcc -o a -ldl a.c
clive@akira:~/temp$ cat b.c
int b(int x) { return x + 1; }
clive@akira:~/temp$ tinycc/tcc -o b.so -shared b.c
clive@akira:~/temp$ ./a
b: 0
# ✓ Success



reply via email to

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