[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: |
Wed, 7 Jul 2021 09:12:42 +0200 |
Hi,
I've pushed two simple patches which, otherwise, break Windows build.
I hope it's enough.
C.
-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On
Behalf Of Christian Jullien
Sent: Wednesday, July 07, 2021 07:56
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] Linking system dylibs on macOS 11+
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");
-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On
Behalf Of Sushant Pandurangi
Sent: Wednesday, July 07, 2021 00:24
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] Linking system dylibs on macOS 11+
mob has just been updated to support linking system libs on macOS 11 and above.
Thanks a lot Christian for testing and Michael for green-lighting it.
`tcc -run` works on M1 without Rosetta, but results are not correct (tried a
couple of simple functions with a few local ints and basic calls to printf). It
either prints the wrong variable or unrelated values (different on each run).
Hello World works fine...
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Re: [Tinycc-devel] Linking system dylibs on macOS 11+, Christian JULLIEN, 2021/07/15