via some heavy-handed hackery in the ASM symbol handling in case C symbols get a leading underscore (but ASM symbols do not). But this is now like clang and GCC on Darwin work: asm symbols are undecorated, C symbols get a _ prepended, so to connect both some trickery is involved for the ASM symbols that don't have a _ prepended. They must be included in the C symbol table (because that's what we use to lookup also ASM labels), but they also must not disturb the normal C symbol (which don't have the _ prepended), so they need some mangling. A bit unsatisfying, but well. So, add asm-c-connect-test to the working ones for Darwin as well.
Showing the changes to tests (5 of 8 files). Show all
Unified · Split
| @@ -46,7 +46,7 @@ ifeq ($(ARCH),riscv64) · 45 unmodified lines | |||
| 46 | endif | 46 | endif |
| 47 | endif | 47 | endif |
| 48 | ifdef CONFIG_OSX # some don't work yet | 48 | ifdef CONFIG_OSX # some don't work yet |
| 49 | TESTS := $(filter-out memtest dlltest asm-c-connect-test, $(TESTS)) | 49 | TESTS := $(filter-out memtest dlltest, $(TESTS)) |
| 50 | endif | 50 | endif |
| 51 | ifeq (,$(filter arm64 i386 x86_64,$(ARCH))) | 51 | ifeq (,$(filter arm64 i386 x86_64,$(ARCH))) |
| 52 | TESTS := $(filter-out vla_test-run,$(TESTS)) | 52 | TESTS := $(filter-out vla_test-run,$(TESTS)) |
| @@ -2,11 +2,20 @@ · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | #if defined _WIN32 && !defined __TINYC__ | 3 | #if defined _WIN32 && !defined __TINYC__ |
| 4 | # define _ "_" | 4 | # define _ "_" |
| 5 | #elif defined __APPLE__ | ||
| 6 | # define _ "_" | ||
| 5 | #else | 7 | #else |
| 6 | # define _ | 8 | # define _ |
| 7 | #endif | 9 | #endif |
| 8 | 10 | ||
| 9 | static int x1_c(void) | 11 | #ifdef __clang__ |
| 12 | /* clang needs some help tp not throw functions away even at -O0 */ | ||
| 13 | #define __USED __attribute__((__used__)) | ||
| 14 | #else | ||
| 15 | #define __USED | ||
| 16 | #endif | ||
| 17 | |||
| 18 | static int __USED x1_c (void) | ||
| 10 | { | 19 | { |
| 11 | printf(" x1"); | 20 | printf(" x1"); |
| 12 | return 1; | 21 | return 1; |
| @@ -37,7 +46,7 @@ int main(int argc, char *argv[]) · 24 unmodified lines | |||
| 37 | } | 46 | } |
| 38 | 47 | ||
| 39 | static | 48 | static |
| 40 | int x2(void) | 49 | int __USED x2(void) |
| 41 | { | 50 | { |
| 42 | printf(" x2"); | 51 | printf(" x2"); |
| 43 | return 2; | 52 | return 2; |
| @@ -2,10 +2,19 @@ · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | #if defined _WIN32 && !defined __TINYC__ | 3 | #if defined _WIN32 && !defined __TINYC__ |
| 4 | # define _ "_" | 4 | # define _ "_" |
| 5 | #elif defined __APPLE__ | ||
| 6 | # define _ "_" | ||
| 5 | #else | 7 | #else |
| 6 | # define _ | 8 | # define _ |
| 7 | #endif | 9 | #endif |
| 8 | 10 | ||
| 11 | #ifdef __clang__ | ||
| 12 | /* clang needs some help tp not throw functions away even at -O0 */ | ||
| 13 | #define __USED __attribute__((__used__)) | ||
| 14 | #else | ||
| 15 | #define __USED | ||
| 16 | #endif | ||
| 17 | |||
| 9 | int x3(void) | 18 | int x3(void) |
| 10 | { | 19 | { |
| 11 | printf(" x3"); | 20 | printf(" x3"); |
| @@ -30,7 +39,7 @@ void callx5_again(void) · 18 unmodified lines | |||
| 30 | asm("call "_"x6"); | 39 | asm("call "_"x6"); |
| 31 | } | 40 | } |
| 32 | 41 | ||
| 33 | static void x6() | 42 | static void __USED x6() |
| 34 | { | 43 | { |
| 35 | printf(" x6-2"); | 44 | printf(" x6-2"); |
| 36 | } | 45 | } |
| @@ -3650,7 +3650,7 @@ void test_asm_call(void) · 3649 unmodified lines | |||
| 3650 | asm volatile ("push %%rdi; push %%rdi; mov %0, %%rdi;" | 3650 | asm volatile ("push %%rdi; push %%rdi; mov %0, %%rdi;" |
| 3651 | #if 1 && !defined(__TINYC__) && (defined(__PIC__) || defined(__PIE__)) && !defined(__APPLE__) | 3651 | #if 1 && !defined(__TINYC__) && (defined(__PIC__) || defined(__PIE__)) && !defined(__APPLE__) |
| 3652 | "call getenv@plt;" | 3652 | "call getenv@plt;" |
| 3653 | #elif defined(__APPLE__) && !defined(__TINYC__) | 3653 | #elif defined(__APPLE__) |
| 3654 | "call _getenv;" | 3654 | "call _getenv;" |
| 3655 | #else | 3655 | #else |
| 3656 | "call getenv;" | 3656 | "call getenv;" |
| @@ -1,6 +1,11 @@ | |||
| 1 | #ifdef __APPLE__ | ||
| 2 | #define _ "_" | ||
| 3 | #else | ||
| 4 | #define _ | ||
| 5 | #endif | ||
| 1 | extern int printf (const char *, ...); | 6 | extern int printf (const char *, ...); |
| 2 | extern void vide(void); | 7 | extern void vide(void); |
| 3 | __asm__("vide: ret"); | 8 | __asm__(_"vide: ret"); |
| 4 | 9 | ||
| 5 | int main() { | 10 | int main() { |
| 6 | vide(); | 11 | vide(); |