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
7373 NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
7474 NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
7575 NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
76+NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
7677 NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
7778 NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
7879 NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
configure+2−0
@@ -352,6 +352,8 @@ if test -z "$cross_prefix" ; then · 351 unmodified lines
352352
353353 if test -f "/lib/ld-uClibc.so.0" ; then
354354 confvars="$confvars uClibc"
355+ elif test -f "/lib/ld-musl-$cpu.so.1"; then
356+ confvars="$confvars musl"
355357 fi
356358 fi
357359 else
include/stdarg.h+4−0
@@ -16,7 +16,11 @@ typedef struct { · 15 unmodified lines
1616 char *reg_save_area;
1717 } __va_list_struct;
1818
19+/* Avoid conflicting definition for va_list on musl libc */
20+#ifndef __DEFINED_va_list
1921 typedef __va_list_struct va_list[1];
22+#define __DEFINED_va_list
23+#endif
2024
2125 void __va_start(__va_list_struct *ap, void *fp);
2226 void *__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
3030 BCHECK_O =
3131 endif
3232
33+ifeq ($(CONFIG_musl),yes)
34+ BCHECK_O =
35+endif
36+
3337 I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
3438 X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
3539 ARM_O = libtcc1.o armeabi.o alloca-arm.o
lib/bcheck.c+1−1
@@ -48,7 +48,7 @@ · 47 unmodified lines
4848 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
4949 || defined(__DragonFly__) || defined(__dietlibc__) \
5050 || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(__NetBSD__) \
51− || defined(_WIN32) || defined(TCC_UCLIBC)
51+ || defined(_WIN32) || defined(TCC_UCLIBC) || defined(TCC_MUSL)
5252 //#warning Bound checking does not support malloc (etc.) in this environment.
5353 #undef CONFIG_TCC_MALLOC_HOOKS
5454 #undef HAVE_MEMALIGN
libtcc.c+4−0
@@ -851,6 +851,10 @@ LIBTCCAPI TCCState *tcc_new(void) · 850 unmodified lines
851851 tcc_define_symbol(s, "__ILP32__", NULL);
852852 #endif
853853
854+#if defined(TCC_MUSL)
855+ tcc_define_symbol(s, "__builtin_va_list", "void *");
856+#endif /* TCC_MUSL */
857+
854858 #ifdef TCC_TARGET_PE
855859 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
856860 tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short");
tcc.h+16−4
@@ -136,7 +136,7 @@ · 135 unmodified lines
136136
137137 #if !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
138138 !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_C67) && \
139− !defined(CONFIG_USE_LIBGCC)
139+ !defined(CONFIG_USE_LIBGCC) && !defined(TCC_MUSL)
140140 #define CONFIG_TCC_BCHECK /* enable bound checking code */
141141 #endif
142142
@@ -239,11 +239,23 @@ · 96 unmodified lines
239239 # elif defined(TCC_UCLIBC)
240240 # define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0" /* is there a uClibc for x86_64 ? */
241241 # 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
243247 # 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
245253 # 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
247259 # endif
248260 #endif
249261
tccelf.c+1−1
@@ -1718,7 +1718,7 @@ static int final_sections_reloc(TCCState *s1) · 1717 unmodified lines
17181718 /* XXX: ignore sections with allocated relocations ? */
17191719 for(i = 1; i < s1->nb_sections; i++) {
17201720 s = s1->sections[i];
1721−#ifdef TCC_TARGET_I386
1721+#if defined(TCC_TARGET_I386) || defined(TCC_MUSL)
17221722 if (s->reloc && s != s1->got && (s->sh_flags & SHF_ALLOC)) //gr
17231723 /* On X86 gdb 7.3 works in any case but gdb 6.6 will crash if SHF_ALLOC
17241724 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