History

Add support of musl-libc

The port is functional. Bound checking is not supported yet.

Marc Vertes committed 9 years ago

Commit 0ac29b51 parent 328b8268 files · +33 −6Browse files

Unified · Split

8 files
  1. Makefile +1 −0
  2. configure +2 −0
  3. include/stdarg.h +4 −0
  4. lib/Makefile +4 −0
  5. lib/bcheck.c +1 −1
  6. libtcc.c +4 −0
  7. tcc.h +16 −4
  8. tccelf.c +1 −1
Makefile+1−0
@@ -73,6 +73,7 @@ NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386 · 72 unmodified lines
73NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_6473NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
74NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE74NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
75NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC75NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
76NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
76NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM77NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
77NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT78NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
78NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI79NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
configure+2−0
@@ -352,6 +352,8 @@ if test -z "$cross_prefix" ; then · 351 unmodified lines
352 352
353 if test -f "/lib/ld-uClibc.so.0" ; then353 if test -f "/lib/ld-uClibc.so.0" ; then
354 confvars="$confvars uClibc"354 confvars="$confvars uClibc"
355 elif test -f "/lib/ld-musl-$cpu.so.1"; then
356 confvars="$confvars musl"
355 fi357 fi
356 fi358 fi
357else359else
include/stdarg.h+4−0
@@ -16,7 +16,11 @@ typedef struct { · 15 unmodified lines
16 char *reg_save_area;16 char *reg_save_area;
17} __va_list_struct;17} __va_list_struct;
18 18
19/* Avoid conflicting definition for va_list on musl libc */
20#ifndef __DEFINED_va_list
19typedef __va_list_struct va_list[1];21typedef __va_list_struct va_list[1];
22#define __DEFINED_va_list
23#endif
20 24
21void __va_start(__va_list_struct *ap, void *fp);25void __va_start(__va_list_struct *ap, void *fp);
22void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align);26void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align);
lib/Makefile+4−0
@@ -30,6 +30,10 @@ ifeq ($(TARGETOS),Darwin) · 29 unmodified lines
30 BCHECK_O =30 BCHECK_O =
31endif31endif
32 32
33ifeq ($(CONFIG_musl),yes)
34 BCHECK_O =
35endif
36
33I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)37I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
34X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)38X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
35ARM_O = libtcc1.o armeabi.o alloca-arm.o39ARM_O = libtcc1.o armeabi.o alloca-arm.o
lib/bcheck.c+1−1
@@ -48,7 +48,7 @@ · 47 unmodified lines
48#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \48#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
49 || defined(__DragonFly__) || defined(__dietlibc__) \49 || defined(__DragonFly__) || defined(__dietlibc__) \
50 || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(__NetBSD__) \50 || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(__NetBSD__) \
51 || defined(_WIN32) || defined(TCC_UCLIBC)51 || defined(_WIN32) || defined(TCC_UCLIBC) || defined(TCC_MUSL)
52//#warning Bound checking does not support malloc (etc.) in this environment.52//#warning Bound checking does not support malloc (etc.) in this environment.
53#undef CONFIG_TCC_MALLOC_HOOKS53#undef CONFIG_TCC_MALLOC_HOOKS
54#undef HAVE_MEMALIGN54#undef HAVE_MEMALIGN
libtcc.c+4−0
@@ -851,6 +851,10 @@ LIBTCCAPI TCCState *tcc_new(void) · 850 unmodified lines
851 tcc_define_symbol(s, "__ILP32__", NULL);851 tcc_define_symbol(s, "__ILP32__", NULL);
852#endif852#endif
853 853
854#if defined(TCC_MUSL)
855 tcc_define_symbol(s, "__builtin_va_list", "void *");
856#endif /* TCC_MUSL */
857
854#ifdef TCC_TARGET_PE858#ifdef TCC_TARGET_PE
855 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");859 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
856 tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short");860 tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short");
tcc.h+16−4
@@ -136,7 +136,7 @@ · 135 unmodified lines
136 136
137#if !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \137#if !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
138 !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_C67) && \138 !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_C67) && \
139 !defined(CONFIG_USE_LIBGCC)139 !defined(CONFIG_USE_LIBGCC) && !defined(TCC_MUSL)
140#define CONFIG_TCC_BCHECK /* enable bound checking code */140#define CONFIG_TCC_BCHECK /* enable bound checking code */
141#endif141#endif
142 142
@@ -239,11 +239,23 @@ · 96 unmodified lines
239# elif defined(TCC_UCLIBC)239# elif defined(TCC_UCLIBC)
240# define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0" /* is there a uClibc for x86_64 ? */240# define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0" /* is there a uClibc for x86_64 ? */
241# elif defined TCC_TARGET_ARM64241# elif defined TCC_TARGET_ARM64
242# define CONFIG_TCC_ELFINTERP "/lib/ld-linux-aarch64.so.1"242# if defined(TCC_MUSL)
243# define CONFIG_TCC_ELFINTERP "/lib/ld-musl-aarch64.so.1"
244# else
245# define CONFIG_TCC_ELFINTERP "/lib/ld-linux-aarch64.so.1"
246# endif
243# elif defined(TCC_TARGET_X86_64)247# elif defined(TCC_TARGET_X86_64)
244# define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"248# if defined(TCC_MUSL)
249# define CONFIG_TCC_ELFINTERP "/lib/ld-musl-x86_64.so.1"
250# else
251# define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
252# endif
245# elif !defined(TCC_ARM_EABI)253# elif !defined(TCC_ARM_EABI)
246# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"254# if defined(TCC_MUSL)
255# define CONFIG_TCC_ELFINTERP "/lib/ld-musl-arm.so.1"
256# else
257# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
258# endif
247# endif259# endif
248#endif260#endif
249 261
tccelf.c+1−1
@@ -1718,7 +1718,7 @@ static int final_sections_reloc(TCCState *s1) · 1717 unmodified lines
1718 /* XXX: ignore sections with allocated relocations ? */1718 /* XXX: ignore sections with allocated relocations ? */
1719 for(i = 1; i < s1->nb_sections; i++) {1719 for(i = 1; i < s1->nb_sections; i++) {
1720 s = s1->sections[i];1720 s = s1->sections[i];
1721#ifdef TCC_TARGET_I3861721#if defined(TCC_TARGET_I386) || defined(TCC_MUSL)
1722 if (s->reloc && s != s1->got && (s->sh_flags & SHF_ALLOC)) //gr1722 if (s->reloc && s != s1->got && (s->sh_flags & SHF_ALLOC)) //gr
1723 /* On X86 gdb 7.3 works in any case but gdb 6.6 will crash if SHF_ALLOC1723 /* On X86 gdb 7.3 works in any case but gdb 6.6 will crash if SHF_ALLOC
1724 checking is removed */1724 checking is removed */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t