From 9f7e17e9fd0cc59c4d2042cd1f9d03eb8c13c6ad Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Tue, 18 Nov 2014 21:13:54 +0300 Subject: [PATCH] Removing musl libc usage. Linking to libgcc (for __aeabi_* routines on ARM target). --- Makefile | 14 ++------- Makefile.mk | 35 ++++------------------- src/config.h | 6 +--- src/globals.h | 1 + src/libruntime/jerry-libc.c | 21 +++++++++++--- src/libruntime/target/linux/jerry-start.S | 2 -- 6 files changed, 27 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index ac7816a9a..5b85c632c 100644 --- a/Makefile +++ b/Makefile @@ -45,10 +45,8 @@ export TARGET_RELEASE_MODES = release export TARGET_PC_SYSTEMS = linux export TARGET_MCU_SYSTEMS = $(addprefix stm32f,3 4) -export TARGET_PC_MODS = musl sanitize valgrind cp cp_minimal mem_stats \ - musl-valgrind \ - valgrind-cp \ - musl-cp_minimal musl-mem_stats musl-cp_minimal-mem_stats \ +export TARGET_PC_MODS = sanitize valgrind cp cp_minimal mem_stats \ + cp-valgrind export TARGET_MCU_MODS = cp_minimal @@ -87,14 +85,8 @@ all: precommit PRECOMMIT_CHECK_TARGETS_NO_VALGRIND_LIST= debug.linux.check \ release.linux.check PRECOMMIT_CHECK_TARGETS_VALGRIND_LIST= debug.linux-valgrind.check \ - release.linux-musl-valgrind.check \ - debug.linux-valgrind-cp.check - - # debug.linux-musl-valgrind.check \ release.linux-valgrind.check \ - release.linux.check \ - debug.linux-sanitize.check \ - release.linux-sanitize.check \ + release.linux-cp-valgrind.check push: ./tools/push.sh @ ./tools/push.sh diff --git a/Makefile.mk b/Makefile.mk index 98d362875..e602a3997 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -150,16 +150,6 @@ ifeq ($(OPTION_OVERRIDE_DISABLE_OPTIMIZE),enable) OPTION_OPTIMIZE = disable endif -ifeq ($(filter musl,$(TARGET_MODS)), musl) - ifeq ($(OPTION_MCU),enable) - $(error MCU target doesn\'t support LIBC_MUSL) - endif - - OPTION_LIBC := musl -else - OPTION_LIBC := raw -endif - # CompactProfile mode ifeq ($(OPTION_MCU),enable) OPTION_COMPACT_PROFILE := enable @@ -180,10 +170,6 @@ else endif ifeq ($(filter sanitize,$(TARGET_MODS)), sanitize) - ifeq ($(OPTION_LIBC),musl) - $(error ASAN and LIBC_MUSL are mutually exclusive) - endif - OPTION_SANITIZE := enable else OPTION_SANITIZE := disable @@ -249,9 +235,8 @@ CFLAGS_CORTEXM4 ?= -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb \ # Common # -CFLAGS_COMMON ?= $(INCLUDES) -std=c99 - -LDFLAGS ?= +CFLAGS_COMMON ?= $(INCLUDES) -std=c99 -nostdlib +LDFLAGS ?= -lgcc ifeq ($(OPTION_OPTIMIZE),enable) CFLAGS_COMMON += $(CFLAGS_OPTIMIZE) @@ -341,19 +326,9 @@ INCLUDES_JERRY = \ -I src/libcoreint \ -I src/libintstructs -# libc -ifeq ($(OPTION_LIBC),musl) - CC := musl-$(CC) - DEFINES_JERRY += -DLIBC_MUSL - CFLAGS_COMMON += -static -else - DEFINES_JERRY += -DLIBC_RAW - CFLAGS_COMMON += -nostdlib - - ifeq ($(OPTION_SANITIZE),enable) - CFLAGS_COMMON += -fsanitize=address - LDFLAGS += -lasan - endif +ifeq ($(OPTION_SANITIZE),enable) + CFLAGS_COMMON += -fsanitize=address + LDFLAGS += -lasan endif ifeq ($(OPTION_NDEBUG),enable) diff --git a/src/config.h b/src/config.h index 36c192e60..d4929cd48 100644 --- a/src/config.h +++ b/src/config.h @@ -19,11 +19,7 @@ /** * Limit of data (system heap, engine's data except engine's own heap) */ -#ifdef LIBC_RAW -# define CONFIG_MEM_DATA_LIMIT_MINUS_HEAP_SIZE 1024 -#else /* !LIBC_RAW */ -# define CONFIG_MEM_DATA_LIMIT_MINUS_HEAP_SIZE 16384 -#endif /* !LIBC_RAW */ +#define CONFIG_MEM_DATA_LIMIT_MINUS_HEAP_SIZE 1024 /** * Limit of stack size diff --git a/src/globals.h b/src/globals.h index 23efec0fc..f80610474 100644 --- a/src/globals.h +++ b/src/globals.h @@ -31,6 +31,7 @@ typedef signed long ssize_t; * Attributes */ #define __unused __attribute__((unused)) +#define __used __attribute__((used)) #define __packed __attribute__((packed)) #define __noreturn __attribute__((noreturn)) #define __noinline __attribute__((noinline)) diff --git a/src/libruntime/jerry-libc.c b/src/libruntime/jerry-libc.c index 3aae9f9b5..d3cb84f39 100644 --- a/src/libruntime/jerry-libc.c +++ b/src/libruntime/jerry-libc.c @@ -19,9 +19,6 @@ #include "jerry-libc.h" -FIXME(#ifndef LIBC_MUSL should be removed from here when own libc will be implemented) - -#ifndef LIBC_MUSL /** * memcpy alias to __memcpy (for compiler usage) */ @@ -85,7 +82,23 @@ CALL_PRAGMA(GCC pop_options) CALL_PRAGMA(GCC diagnostic pop) #endif /* __GNUC__ */ -#endif /* LIBC_MUSL */ +/** + * Unreachable stubs for routines that are never called, + * but referenced from third-party libraries. + */ +#define JRT_UNREACHABLE_STUB_FOR(...) \ + extern __VA_ARGS__; \ + __used __VA_ARGS__ \ + { \ + JERRY_UNREACHABLE (); \ + } + +JRT_UNREACHABLE_STUB_FOR(int raise (int sig_no __unused)) +#ifdef __TARGET_HOST_ARMv7 +JRT_UNREACHABLE_STUB_FOR(void __aeabi_unwind_cpp_pr0 (void)) +#endif /* __TARGET_HOST_ARMv7 */ + +#undef JRT_UNREACHABLE_STUB_FOR /** * memset diff --git a/src/libruntime/target/linux/jerry-start.S b/src/libruntime/target/linux/jerry-start.S index e5ebd093e..e06471aba 100644 --- a/src/libruntime/target/linux/jerry-start.S +++ b/src/libruntime/target/linux/jerry-start.S @@ -8,9 +8,7 @@ # error "!__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7" #endif /* !__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 */ -#ifdef LIBC_RAW .global _start _start: _START .end _start -#endif /* LIBC_RAW */