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: Michael Matz
Subject: Re: [Tinycc-devel] Linking system dylibs on macOS 11+
Date: Tue, 13 Jul 2021 16:32:39 +0200 (CEST)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,


On Wed, 7 Jul 2021, Sushant Pandurangi wrote:

Thanks for the Windows patches and the long double fix.
To clarify about tcc -run, I'm not using --cpu=x86-64 at all, I am on a
fresh M1 and Rosetta is not even installed. Here, `tcc -run` starts running
main() and very simple stuff (like Hello World) works already.

On the other hand in a cross-compiler config, I wonder if tcc -run can work
at all -- not unless Rosetta can do in-memory translation of the JIT'd
x86-64 code.

The 2 warnings at tccmacho.c:265/285 -- those are not from my code, did they
show up only after my patch? I wonder why. I'm not familiar with that
function and probably not the best person to make a fix.

Pre-existing and false positive. The best way to fix them is to disable -Wstringop-truncation for that file.


Ciao,
Michael.


To Herman, thanks a lot for catching the memcheck issues.

Regards,
Sushant

      Date: Wed, 7 Jul 2021 07:55:41 +0200
      From: "Christian Jullien" <eligis@orange.fr>
      To: <tinycc-devel@nongnu.org>
      Subject: Re: [Tinycc-devel] Linking system dylibs on macOS 11+
      Message-ID: <000301d772f4$b88cf070$29a6d150$@orange.fr>
      Content-Type: text/plain; charset="utf-8"

      Hello Sushant,

      Your pushed patch works at 99%.

      --- The details:

      there are few warnings:

      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);
           |     ^~~~~~~

      --- More annoying.

      BUG1: tcc -run fails because it is not supported by
      cross-compiler. IMHO, on macOS --cpu should not be considered as
      cross-compiler
      ------------ hello-run ------------
      tcc: error: -run is not available in a cross compiler
      If I remove this test:
      #ifndef TCC_IS_NATIVE
                 tcc_error("-run is not available in a cross
      compiler");
      #endif

      It fails with
      ------------ libtest ------------
      dyld: lazy symbol binding failed: Symbol not found:
      _tcc_relocate
       Referenced from: /Users/jullien/tinycc/tests/./libtcc_test
       Expected in: flat namespace

      dyld: Symbol not found: _tcc_relocate
       Referenced from: /Users/jullien/tinycc/tests/./libtcc_test
       Expected in: flat namespace

      BUG2: When compiled tcc with ./configure --cpu=x86_64
      Generated code is considered as a cross-compiler.
      Then, when I use a long double in my code, it reaches
      tccgen.c(8087): tcc_error("can't cross compile long double
      constants");

      In this specific case, both double and long double are 8 bytes
      but LDOUBLE_SIZE == 16

      I tried this patch which seems to solve this issues.
      Maintainers, is it the right patch? Do you allow me to push it
      on mod?
      If you prefer, I can surround it with #ifdef TCC_TARGET_MACHO

      jullien@mobley:~/tinycc $ git diff
      diff --git a/tccgen.c b/tccgen.c
      index c36032a..425a001 100644
      --- a/tccgen.c
      +++ b/tccgen.c
      @@ -8088,10 +8088,10 @@ static void init_putv(init_params *p,
      CType *type, unsigned long c)
      #endif
                      /* For other platforms it should work natively,
      but may not work
                         for cross compilers */
      -                if (sizeof(long double) == LDOUBLE_SIZE)
      -                    memcpy(ptr, &vtop->c.ld, LDOUBLE_SIZE);
      -                else if (sizeof(double) == LDOUBLE_SIZE)
      -                    memcpy(ptr, &vtop->c.ld, LDOUBLE_SIZE);
      +                if (sizeof(long double) <= LDOUBLE_SIZE)
      +                    memcpy(ptr, &vtop->c.ld, sizeof(long
      double));
      +                else if (sizeof(double) <= LDOUBLE_SIZE)
      +                    memcpy(ptr, &vtop->c.ld, sizeof(double));
      #ifndef TCC_CROSS_TEST
                      else
                          tcc_error("can't cross compile long double
      constants");





reply via email to

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