[meta-lsi] [PATCH 01/15] gcc: Fix fortran compiling error when building SDK

Cristian Bercaru cristian.bercaru at windriver.com
Wed May 13 04:19:35 PDT 2015


From: Daniel Dragomir <daniel.dragomir at windriver.com>

With fortran support added, building the SDK will fail due to missing
libquadmath library.
fatal error: quadmath_weak.h: No such file or directory

Backporting and adapting upstream OE-core commit from 1.6 daisy branch:

(From OE-Core rev: cae2315266b704614fe1d7bdeef004ef67a01e8d)

gcc 4.8 fortran presents some challenges:
  * libquadmath headers need to be in the libexec include dir. It turns out
    to be easiest just to manually do this in gcc-cross.
  * libgfortran configure needs libquadmath to be compiled. This means
    a separate recipe is needed (the alternative is gross hacks)

Since libgfortran isn't a gcc-runtime component anymore and have a separate
receipe, added it to DEPENDS for lsi-image-large and removed from RUNTIMETARGET
variable.

Also, when configuring libgfortran, syslinks are created for the gcc
libraries but have wrong target path and the symlinks are not valid.
Corrected libgcc symlinks.

Signed-off-by: Daniel Dragomir <daniel.dragomir at windriver.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 recipes-core/images/lsi-image-large.bb        |    2 +
 recipes-devtools/gcc/gcc-cross_4.8.bbappend   |    6 ++
 recipes-devtools/gcc/gcc-runtime_4.8.bbappend |    1 -
 recipes-devtools/gcc/libgfortran_4.8.bb       |   85 +++++++++++++++++++++++++
 4 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100644 recipes-devtools/gcc/gcc-cross_4.8.bbappend
 delete mode 100644 recipes-devtools/gcc/gcc-runtime_4.8.bbappend
 create mode 100644 recipes-devtools/gcc/libgfortran_4.8.bb

diff --git a/recipes-core/images/lsi-image-large.bb b/recipes-core/images/lsi-image-large.bb
index 9dbeee0..dd03a5f 100644
--- a/recipes-core/images/lsi-image-large.bb
+++ b/recipes-core/images/lsi-image-large.bb
@@ -1,5 +1,7 @@
 require recipes-core/images/core-image-minimal-dev.bb
 
+DEPENDS += "libgfortran"
+
 IMAGE_INSTALL = " \
 run-postinsts \
 udev-utils \
diff --git a/recipes-devtools/gcc/gcc-cross_4.8.bbappend b/recipes-devtools/gcc/gcc-cross_4.8.bbappend
new file mode 100644
index 0000000..652c034
--- /dev/null
+++ b/recipes-devtools/gcc/gcc-cross_4.8.bbappend
@@ -0,0 +1,6 @@
+do_install_append () {
+	# libquadmath headers need to  be available in the gcc libexec dir
+#	install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
+#	cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
+#	cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
+}
diff --git a/recipes-devtools/gcc/gcc-runtime_4.8.bbappend b/recipes-devtools/gcc/gcc-runtime_4.8.bbappend
deleted file mode 100644
index 06ef0e4..0000000
--- a/recipes-devtools/gcc/gcc-runtime_4.8.bbappend
+++ /dev/null
@@ -1 +0,0 @@
-RUNTIMETARGET += "libgfortran"
diff --git a/recipes-devtools/gcc/libgfortran_4.8.bb b/recipes-devtools/gcc/libgfortran_4.8.bb
new file mode 100644
index 0000000..3d503e2
--- /dev/null
+++ b/recipes-devtools/gcc/libgfortran_4.8.bb
@@ -0,0 +1,85 @@
+FILESEXTRAPATHS_prepend := "${@base_set_filespath([bb.utils.which(BBPATH, 'recipes-devtools/gcc/gcc-${PV}', direction=True)], d)}" 
+
+require recipes-devtools/gcc/gcc-${PV}.inc
+require recipes-devtools/gcc/gcc-configure-common.inc
+
+EXTRA_OECONF_PATHS = "\
+    --with-sysroot=${STAGING_DIR_TARGET} \
+    --with-build-sysroot=${STAGING_DIR_TARGET} \
+"
+
+do_configure () {
+	mtarget=`echo ${MULTIMACH_TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+	target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+	cp -fpPR ${STAGING_INCDIR_NATIVE}/gcc-build-internal-$mtarget/* ${B}
+	
+	echo "Configuring libgfortran"
+	rm -rf ${B}/$target/libgfortran/
+	mkdir -p ${B}/$target/libgfortran/
+	cd ${B}/$target/libgfortran/
+	chmod a+x ${S}/libgfortran/configure
+	${S}/libgfortran/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
+	# Easiest way to stop bad RPATHs getting into the library since we have a
+	# broken libtool here
+	sed -i -e 's/hardcode_into_libs=yes/hardcode_into_libs=no/' ${B}/$target/libgfortran/libtool
+
+	# Correct invalid libgcc symlinks with wrong target path.
+	cd ${B}/$target/libgcc
+	for d in enable-execute-stack.c gthr-default.h md-unwind-support.h sfp-machine.h unwind.h; do
+		if [ ! -e "$d" ]; then
+			ln -f -s ./../$(readlink $d) $d
+		fi
+	done
+}
+
+do_compile () {
+	target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+	cd ${B}/$target/libgfortran/
+	oe_runmake MULTIBUILDTOP=${B}/$target/libgfortran/
+}
+
+do_install () {
+	target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+	cd ${B}/$target/libgfortran/
+	oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/$target/libgfortran/ install
+	if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude ]; then
+		rmdir --ignore-fail-on-non-empty -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
+	fi
+	if [ -d ${D}${infodir} ]; then
+		rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
+	fi
+	chown -R root:root ${D}
+}
+
+INHIBIT_DEFAULT_DEPS = "1"
+DEPENDS = "gcc-runtime"
+
+BBCLASSEXTEND = "nativesdk"
+
+PACKAGES = "\
+    ${PN}-dbg \
+    libgfortran \
+    libgfortran-dev \
+    libgfortran-staticdev \
+"
+FILES_${PN} = "${libdir}/libgfortran.so.*"
+FILES_${PN}-dev = "\
+    ${libdir}/libgfortran*.so \
+    ${libdir}/libgfortran.spec \
+    ${libdir}/libgfortran.la \
+    ${libdir}/gcc/${TARGET_SYS}/${BINV}/libgfortranbegin.* \
+    ${libdir}/gcc/${TARGET_SYS}/${BINV}/libcaf_single* \
+"
+FILES_${PN}-staticdev = "${libdir}/libgfortran.a"
+
+INSANE_SKIP_${MLPREFIX}libgfortran-dev = "staticdev"
+
+do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
+do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
+do_package_write_rpm[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
+
+python __anonymous () {
+    f = d.getVar("FORTRAN", True)
+    if "fortran" not in f:
+        raise bb.parse.SkipPackage("libgfortran needs fortran support to be enabled in the compiler")
+}
-- 
1.7.9.5



More information about the meta-lsi mailing list