tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Mach-O (i.e. MacOS) support


From: Christian Jullien
Subject: Re: [Tinycc-devel] Mach-O (i.e. MacOS) support
Date: Sun, 21 Jun 2020 06:56:01 +0200

Hello Matz,

Amazing!! I'm glad to be the first to tell you it works ROOTB including all
tests. (I'll do more tests with OpenLisp but I'm confident)
I think you can drop 32bit support as Apple no longer supports 32bit
binaries on latest OS version.

I tested this port on

- MacBook Air 2011 running High-Sierra
jullien@jacquet:~/tinycc $ uname -a
Darwin jacquet.local 17.7.0 Darwin Kernel Version 17.7.0: Wed May 27
17:00:02 PDT 2020; root:xnu-4570.71.80.1~1/RELEASE_X86_64 x86_64
jullien@jacquet:~/tinycc $ clang -v
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
jullien@jacquet:~/tinycc $ file tcc
tcc: Mach-O 64-bit executable x86_64

- MacBook Pro 2012 running Catalina (fully up to date)
jullien@byas tinycc % uname -a
Darwin byas.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44
PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
jullien@byas tinycc % clang -v
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.5.0
jullien@byas tinycc % file tcc
tcc: Mach-O 64-bit executable x86_64

I only get the following warning when running the tests suite:

------------ memtest ------------
In file included from ../tcc.c:23:
In file included from ../libtcc.c:22:
../tccpp.c:1439:33: warning: adding 'int' to a string does not append to the
      string [-Wstring-plus-int]
    fprintf(s->ppfp, "\n[%s]\n" + !(s->dflag & 32), p), fflush(s->ppfp);
                     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../tccpp.c:1439:33: note: use array indexing to silence this warning
    fprintf(s->ppfp, "\n[%s]\n" + !(s->dflag & 32), p), fflush(s->ppfp);
                                ^
                     &          [                 ]
../tccpp.c:3823:20: warning: adding 'int' to a string does not append to the
      string [-Wstring-plus-int]
        fprintf(fp, " %s" + s, get_tok_str(t, &cval)), s = 1;
                    ~~~~~~^~~
../tccpp.c:3823:20: note: use array indexing to silence this warning
        fprintf(fp, " %s" + s, get_tok_str(t, &cval)), s = 1;
                          ^
                    &     [  ]
In file included from ../tcc.c:23:
In file included from ../libtcc.c:24:
../tccelf.c:1421:36: warning: adding 'int' to a string does not append to
the
      string [-Wstring-plus-int]
    set_local_sym(s1, "___rt_info" + !s1->leading_underscore, s, o);
                      ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
../tccelf.c:1421:36: note: use array indexing to silence this warning
    set_local_sym(s1, "___rt_info" + !s1->leading_underscore, s, o);
                                   ^
                      &            [                        ]
In file included from ../tcc.c:23:
In file included from ../libtcc.c:25:
../tccrun.c:148:36: warning: adding 'int' to a string does not append to the
      string [-Wstring-plus-int]
        tcc_add_symbol(s1, "_exit" + !s1->leading_underscore, rt_exit);
                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
../tccrun.c:148:36: note: use array indexing to silence this warning
        tcc_add_symbol(s1, "_exit" + !s1->leading_underscore, rt_exit);
                                   ^
                           &       [                        ]
4 warnings generated.
OK

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org]
On Behalf Of Michael Matz
Sent: Saturday, June 20, 2020 23:47
To: jullien@eligis.com; tinycc-devel@nongnu.org
Cc: Karl Yerkes
Subject: [Tinycc-devel] Mach-O (i.e. MacOS) support

Hello,

On Tue, 16 Jun 2020, Christian Jullien wrote:

> Hi, it looks new and I?ve not tested this solution but it may help to 
> finally get a native tcc port on macOS. Image is around 200Gb

I've just pushed my macos port to mob.  It's lightly tested but seems to
work reasonably well, the testsuite is clean.  I.e. you can now create
proper Mach-O executable files, link against system .dylibs and such.  I
didn't bother implementing a Mach-O object file reader, so the support is
similar to Windows: you need to use TCC to compile C files into .o files
(which are ELF files), and then TCC to link those, which generates Mach-O
executables.

Generating shared libraries isn't implemented, neither are 32bit objects. 
The generated executables should be runnable with relatively old MacOS
versions (dyld needs to support LC_MAIN, so 10.8 should be enough) but I've
developed and checked this only on 10.14 (Mojave).

You need at least the command line tools installed for system headers, but
you don't need to unpack them into /usr/include (modern MacOS deprecated
that one), the configure step tries to figure out the correct SDK directory
by using xcrun (which is then hardcoded into TCC as search path for now).

For emulation I started with
https://github.com/foxlet/macOS-Simple-KVM.git (I didn't want to start with
docker and prefer plain qemu) and used the image fetcher from
https://github.com/kholia/OSX-KVM.git .

So, people with a real Mac: try it and give feedback ;-)


Ciao,
Michael.




reply via email to

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