tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Linking system dylibs on macOS 11+


From: Christian Jullien
Subject: Re: [Tinycc-devel] Linking system dylibs on macOS 11+
Date: Mon, 5 Jul 2021 06:55:39 +0200

Hello Sushant,

 

Good things first, trying your fork, it works on both macOS Catalina and High Sierra x64 (it only reports new warnings, see at the end of this post)..

Even better, tcc (compiled natively for x64 on Catalina) and then copied to Big Sur M1 WORKS when translated by Rosetta!!!

Your patch is clearly the right direction to support Big Sur M1.

 

Now, bad news. When compiled natively for arm64 I still get for hello world:

jullien@mobley:~/tinycc $ ./tcc -B. ../hello.c -o hello

FIXME: handle reloc type 9 at 1052 [0x134e06d62] to 1050

 

A more complex example gives me this other error

 

jullien@mobley:~/tinycc $ ./tcc -B. ../openlisp/etc/cspy.c -o foo

tcc: error: R_AARCH64_(JUMP|CALL)26 relocation failed (val=1000027f6, addr=1000010a0)

 

Perhaps Herman can help us with relocation errors. He fixed many of them when porting tcc on different BSD systems.

As far I understand they are related to elf sections and/or CPU instructions. See arm64-link.c

 

Here are the new warnings to fix:

 

 

libtcc.c: In function 'tcc_add_file_internal':

libtcc.c:1036:32: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

1036 |                 char* soname = filename;

      |                                ^~~~~~~~

libtcc.c:1039:28: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

1039 |                     soname = macho_tbd_soname(filename);

      |                            ^

libtcc.c:1041:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

1041 |                 void* dl = dlopen(soname, RTLD_GLOBAL | RTLD_LAZY);

      |                 ^~~~

 

And

 

tccmacho.c: In function 'macho_tbd_soname':

tccmacho.c:872:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  872 |     struct stat sb;

      |     ^~~~~~

tccmacho.c:874:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  874 |     char* data = "" 0, sb.st_size+1);

      |     ^~~~

tccmacho.c:876:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  876 |     char* pos = data;

      |     ^~~~

tccmacho.c:884:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  884 |     char* ret = tcc_mallocz(strlen(soname)+1);

      |     ^~~~

tccmacho.c: In function 'macho_load_tbd':

tccmacho.c:897:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  897 |     char* data = "" 0, sb.st_size+1);

      |     ^~~~

tccmacho.c:899:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  899 |     char* pos = data;

      |     ^~~~

tccmacho.c:913:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  913 |         int cont = 1;

      |         ^~~

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:194,

                 from tcc.h:35,

                 from tccmacho.c:18:

tccmacho.c: In function 'add_segment':

tccmacho.c:265:5: warning: '__builtin_strncpy' specified bound 16 equals destination size [-Wstringop-truncation]

  265 |     strncpy(sc->segname, name, 16);

      |     ^~~~~~~

In function 'add_section',

    inlined from 'collect_sections' at tccmacho.c:649:22,

    inlined from 'macho_output_file' at tccmacho.c:812:9:

tccmacho.c:285:5: warning: '__builtin_strncpy' specified bound 16 equals destination size [-Wstringop-truncation]

  285 |     strncpy(sec->sectname, name, 16);

      |     ^~~~~~~

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On Behalf Of Sushant Pandurangi
Sent: Sunday, July 04, 2021 22:23
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] Linking system dylibs on macOS 11+

 

Hi Christian,

 

Unfortunately I don't see why the patch failed. I've never had the "handle reloc type" error. Let's try another way, here is a link to my fork, the branch is osx11-dyld. You can have a look at the log and clone and test directly. 

 

https://github.com/sushpa/tinycc

 

In the meantime it is updated to work with `tcc -run` as well. Still x86-64 only.

 

Thanks a lot for the cfarm link, I might look into M1 later this week or next if I can get an account there.

 

Regards,

Sushant


reply via email to

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