diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2014-06-28 21:51:24 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2014-06-28 21:52:30 +0200 |
commit | 7d9f958d550ee7ac394794738eaa35086a64545d (patch) | |
tree | c92855ba8ae7c86d89cd0d5d8d83acdd0755e86d | |
parent | dcd6c2ef08fc808fbb99fcc1ba326505b612360e (diff) |
enable shared libgcc for uClibc/glibc
unfortunately uClibc/glibc uses dlopen to access exception
handling code from libgcc_s.so.1. Pure static build is only
provided by musl.
-rw-r--r-- | package/glibc/Makefile | 7 | ||||
-rw-r--r-- | package/libgcc/Makefile | 42 | ||||
-rw-r--r-- | target/config/Config.in.toolchain | 4 | ||||
-rw-r--r-- | toolchain/gcc/Makefile | 21 | ||||
-rw-r--r-- | toolchain/uclibc/patches/xxx-disable-gcc_eh.patch | 14 | ||||
-rw-r--r-- | toolchain/uclibc/patches/xxx-remove-duplicate-symbols-arm.patch | 122 |
6 files changed, 80 insertions, 130 deletions
diff --git a/package/glibc/Makefile b/package/glibc/Makefile index 49f1db305..6b15d1219 100644 --- a/package/glibc/Makefile +++ b/package/glibc/Makefile @@ -38,6 +38,13 @@ ifneq ($(ADK_TARGET_USE_STATIC_LIBS),y) $(CP) $(STAGING_TARGET_DIR)/lib/$$file.so* $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH); \ $(CP) $(STAGING_TARGET_DIR)/lib/$$file-$(PKG_VERSION).so $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH); \ done +else + # libnss_* required at runtime even for static builds + ${INSTALL_DIR} ${IDIR_GLIBC}/$(ADK_TARGET_LIBC_PATH) + for file in libnss_dns libnss_files; do \ + $(CP) $(STAGING_TARGET_DIR)/lib/$$file.so* $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH); \ + $(CP) $(STAGING_TARGET_DIR)/lib/$$file-$(PKG_VERSION).so $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH); \ + done endif ${INSTALL_DIR} $(IDIR_GLIBC)/usr/bin $(CP) $(STAGING_TARGET_DIR)/usr/bin/getconf $(IDIR_GLIBC)/usr/bin diff --git a/package/libgcc/Makefile b/package/libgcc/Makefile new file mode 100644 index 000000000..13274d203 --- /dev/null +++ b/package/libgcc/Makefile @@ -0,0 +1,42 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include ${ADK_TOPDIR}/rules.mk + +ifeq ($(ADK_TARGET_LIB_GLIBC),y) +include ${ADK_TOPDIR}/toolchain/glibc/Makefile.inc +endif +ifeq ($(ADK_TARGET_LIB_UCLIBC),y) +include ${ADK_TOPDIR}/toolchain/uclibc/Makefile.inc +endif + +PKG_NAME:= libgcc +PKG_DESCR:= gcc library +PKG_SECTION:= base/libs +PKG_OPTS:= noremove + +PKG_DFLT_LIBGCC:= y if !(ADK_TOOLCHAIN_ONLY) +PKG_LIBC_DEPENDS:= uclibc glibc + + +NO_DISTFILES:= 1 + +include ${ADK_TOPDIR}/mk/package.mk + +$(eval $(call PKG_template,LIBGCC,libgcc,${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS})) + +CONFIG_STYLE:= manual +BUILD_STYLE:= manual +INSTALL_STYLE:= manual + +libgcc-install: + $(INSTALL_DIR) ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH) +ifeq ($(ADK_LINUX_SH),y) +ifeq ($(ADK_TARGET_LIB_GLIBC),) + ${CP} ${STAGING_TARGET_DIR}/lib/m4-nofpu/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH) +endif +else + ${CP} ${STAGING_TARGET_DIR}/lib/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH) +endif + +include ${ADK_TOPDIR}/mk/pkg-bottom.mk diff --git a/target/config/Config.in.toolchain b/target/config/Config.in.toolchain index 49850ef68..344638081 100644 --- a/target/config/Config.in.toolchain +++ b/target/config/Config.in.toolchain @@ -130,6 +130,8 @@ config ADK_TARGET_USE_STATIC_LIBS default n select BUSYBOX_STATIC help - Useful for debugging of dynamic linker problems. + Useful for debugging of dynamic linker problems. Be aware of the fact, that uClibc and glibc + still requires libgcc_so.so.1 for pthread_cancel. Glibc also requires libnss_*.so libraries + at runtime. Full static builds are only supported for musl libc. endmenu diff --git a/toolchain/gcc/Makefile b/toolchain/gcc/Makefile index c6f57f413..1c95a2f93 100644 --- a/toolchain/gcc/Makefile +++ b/toolchain/gcc/Makefile @@ -10,10 +10,6 @@ ifeq ($(ADK_TARGET_LIB_MUSL),y) TARGET_CXXFLAGS:= $(filter-out -fstack-protector-all,$(TARGET_CXXFLAGS)) endif -ifneq ($(ADK_LINUX_XTENSA),y) -GCC_FINAL_CONFOPTS+= --enable-cxx-flags='$(TARGET_CXXFLAGS)' -endif - GCC_CONFOPTS:= --prefix=$(TOOLCHAIN_DIR)/usr \ --with-bugurl="http://www.openadk.org/" \ --build=$(GNU_HOST_NAME) \ @@ -42,6 +38,18 @@ GCC_CONFOPTS:= --prefix=$(TOOLCHAIN_DIR)/usr \ --disable-nls GCC_FINAL_CONFOPTS:= + +ifneq ($(ADK_LINUX_XTENSA),y) +GCC_FINAL_CONFOPTS+= --enable-cxx-flags='$(TARGET_CXXFLAGS)' +endif + +# uClibc/glibc uses libgcc_s.so.1 for pthread_cancel with dlopen +ifeq (ADK_TARGET_LIB_MUSL),y) +GCC_FINAL_CONFOPTS+= --enable-shared='libstdc++' +else +GCC_FINAL_CONFOPTS+= --enable-shared='libstdc++,libgcc' +endif + ifeq ($(ADK_LINUX_SH)$(ADK_LINUX_X86_64)$(ADK_LINUX_X86),) GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib endif @@ -102,7 +110,7 @@ endif endif ifeq ($(ADK_CPU_ARM926EJ_S),y) -GCC_CONFOPTS+= --with-arch=armv5te --with-tune=arm1176jzf-s +GCC_CONFOPTS+= --with-arch=armv5te --with-tune=arm926ej-s endif ifeq ($(ADK_CPU_ARM1176JZF_S),y) @@ -205,8 +213,7 @@ $(GCC_BUILD_DIR_FINAL)/.configured: ${GCC_FINAL_CONFOPTS} \ --enable-languages=$(LANGUAGES) \ --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \ - --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \ - --enable-shared='libstdc++' + --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' touch $@ $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured diff --git a/toolchain/uclibc/patches/xxx-disable-gcc_eh.patch b/toolchain/uclibc/patches/xxx-disable-gcc_eh.patch new file mode 100644 index 000000000..a7f1a2db8 --- /dev/null +++ b/toolchain/uclibc/patches/xxx-disable-gcc_eh.patch @@ -0,0 +1,14 @@ +diff -Nur uClibc-0.9.33.2.orig/Rules.mak uClibc-0.9.33.2/Rules.mak +--- uClibc-0.9.33.2.orig/Rules.mak 2014-06-28 12:12:25.000000000 +0200 ++++ uClibc-0.9.33.2/Rules.mak 2014-06-28 12:14:15.000000000 +0200 +@@ -819,10 +819,7 @@ + LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y) + $(eval $(call cache-output-var,LIBGCC,$(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)) + $(eval $(call cache-output-var,LIBGCC_EH,$(CC) $(LIBGCC_CFLAGS) -print-file-name=libgcc_eh.a)) +-# with -O0 we (e.g. lockf) might end up with references to +-# _Unwind_Resume, so pull in gcc_eh in this case.. + LIBGCC_DIR:=$(dir $(LIBGCC)) +-LIBGCC += $(if $(DODEBUG),$(LIBGCC_EH)) + + # moved from libpthread/linuxthreads + ifeq ($(UCLIBC_CTOR_DTOR),y) diff --git a/toolchain/uclibc/patches/xxx-remove-duplicate-symbols-arm.patch b/toolchain/uclibc/patches/xxx-remove-duplicate-symbols-arm.patch deleted file mode 100644 index 69f338f6e..000000000 --- a/toolchain/uclibc/patches/xxx-remove-duplicate-symbols-arm.patch +++ /dev/null @@ -1,122 +0,0 @@ -diff -Nur uClibc-0.9.33.2.orig/libc/sysdeps/linux/arm/Makefile.arch uClibc-0.9.33.2/libc/sysdeps/linux/arm/Makefile.arch ---- uClibc-0.9.33.2.orig/libc/sysdeps/linux/arm/Makefile.arch 2014-05-23 15:42:33.000000000 +0200 -+++ uClibc-0.9.33.2/libc/sysdeps/linux/arm/Makefile.arch 2014-05-23 15:53:57.000000000 +0200 -@@ -40,5 +40,4 @@ - aeabi_lcsts.os \ - aeabi_math.os \ - aeabi_sighandlers.os \ -- aeabi_unwind_cpp_pr1.o \ - ) -diff -Nur uClibc-0.9.33.2.orig/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c uClibc-0.9.33.2/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c ---- uClibc-0.9.33.2.orig/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c 2014-05-23 15:42:33.000000000 +0200 -+++ uClibc-0.9.33.2/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c 2014-05-23 20:40:14.000000000 +0200 -@@ -97,6 +97,7 @@ - } - } - -+/* - void - _Unwind_Resume (struct _Unwind_Exception *exc) - { -@@ -107,6 +108,7 @@ - PTR_DEMANGLE (resume); - resume (exc); - } -+*/ - - _Unwind_Reason_Code - __gcc_personality_v0 (int version, _Unwind_Action actions, -@@ -129,6 +131,7 @@ - return personality (version, actions, exception_class, ue_header, context); - } - -+/* - _Unwind_Reason_Code - _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, - void *stop_argument) -@@ -153,3 +156,4 @@ - PTR_DEMANGLE (getcfa); - return getcfa (context); - } -+*/ -diff -Nur uClibc-0.9.33.2.orig/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c uClibc-0.9.33.2/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c ---- uClibc-0.9.33.2.orig/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c 2014-05-23 15:42:33.000000000 +0200 -+++ uClibc-0.9.33.2/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c 2014-05-23 21:08:02.000000000 +0200 -@@ -47,62 +47,6 @@ - libgcc_s_resume = resume; - libgcc_s_personality = personality; - } --#ifdef __thumb__ --void --_Unwind_Resume (struct _Unwind_Exception *exc) --{ -- if (__builtin_expect (libgcc_s_resume == NULL, 0)) -- init (); -- libgcc_s_resume (exc); --} --#else --/* It's vitally important that _Unwind_Resume not have a stack frame; the -- ARM unwinder relies on register state at entrance. So we write this in -- assembly. */ -- --__asm__ ( --" .globl _Unwind_Resume\n" --" .type _Unwind_Resume, %function\n" --"_Unwind_Resume:\n" --" " CFI_SECTIONS (.debug_frame) "\n" --" " CFI_STARTPROC "\n" --" stmfd sp!, {r4, r5, r6, lr}\n" --" " CFI_ADJUST_CFA_OFFSET (16)" \n" --" " CFI_REL_OFFSET (r4, 0) "\n" --" " CFI_REL_OFFSET (r5, 4) "\n" --" " CFI_REL_OFFSET (r6, 8) "\n" --" " CFI_REL_OFFSET (lr, 12) "\n" --" " CFI_REMEMBER_STATE "\n" --" ldr r4, 1f\n" --" ldr r5, 2f\n" --"3: add r4, pc, r4\n" --" ldr r3, [r4, r5]\n" --" mov r6, r0\n" --" cmp r3, #0\n" --" beq 4f\n" --"5: mov r0, r6\n" --" ldmfd sp!, {r4, r5, r6, lr}\n" --" " CFI_ADJUST_CFA_OFFSET (-16) "\n" --" " CFI_RESTORE (r4) "\n" --" " CFI_RESTORE (r5) "\n" --" " CFI_RESTORE (r6) "\n" --" " CFI_RESTORE (lr) "\n" --" bx r3\n" --" " CFI_RESTORE_STATE "\n" --"4: bl init\n" --" ldr r3, [r4, r5]\n" --" b 5b\n" --" " CFI_ENDPROC "\n" --" .align 2\n" --#ifdef __thumb2__ --"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 4\n" --#else --"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8\n" --#endif --"2: .word libgcc_s_resume(GOTOFF)\n" --" .size _Unwind_Resume, .-_Unwind_Resume\n" --); --#endif - - _Unwind_Reason_Code - __gcc_personality_v0 (_Unwind_State state, -diff -Nur uClibc-0.9.33.2.orig/Rules.mak uClibc-0.9.33.2/Rules.mak ---- uClibc-0.9.33.2.orig/Rules.mak 2014-05-23 15:42:33.000000000 +0200 -+++ uClibc-0.9.33.2/Rules.mak 2014-05-23 20:13:43.000000000 +0200 -@@ -818,11 +818,7 @@ - - LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y) - $(eval $(call cache-output-var,LIBGCC,$(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)) --$(eval $(call cache-output-var,LIBGCC_EH,$(CC) $(LIBGCC_CFLAGS) -print-file-name=libgcc_eh.a)) --# with -O0 we (e.g. lockf) might end up with references to --# _Unwind_Resume, so pull in gcc_eh in this case.. - LIBGCC_DIR:=$(dir $(LIBGCC)) --LIBGCC += $(if $(DODEBUG),$(LIBGCC_EH)) - - # moved from libpthread/linuxthreads - ifeq ($(UCLIBC_CTOR_DTOR),y) |