Files
poky/meta/recipes-devtools/gcc/libgfortran.inc
Chen Qi 9783baa9dd libgfortran: fix buildpath QA issue
The '-fdebug-prefix-map' options are used to map source files locations,
otherwise, DW_AT_comp_dir will contain buildpath.

The '-gno-record-gcc-switches' option is used to fix the buildpath introduced
by '-fintrinsic-modules-path' option, which is automatically added by fortran.
Here's some output from 'readelf --debug-dump libgfortran.so.5.0.0' when this
option is not added:
"""
<0><1a37d3>: Abbrev Number: 4 (DW_TAG_compile_unit)
   <1a37d4>   DW_AT_producer    : (indirect string, offset: 0xd653): GNU Fortran2008 14.2.0 -m64
                -march=core2 -mtune=core2 -msse3
                -mfpmath=sse -mshstk -g -O2 -O2 -fstack-protector-strong -fimplicit-none
                -fno-repack-arrays -fno-underscoring -fcf-protection=full
                -fallow-leading-underscore -fbuilding-libgfortran -fPIC
                -fintrinsic-modules-path /ala-lpggp72/qichen/Yocto/builds/build-poky/tmp/work/
                core2-64-poky-linux/libgfortran/14.2.0/recipe-sysroot-native/usr/bin/x86_64-poky-linux
                /../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/14.2.0/finclude
                -fpre-include=../../../../recipe-sysroot/usr/include/finclude/math-vector-fortran.h
"""

See https://gcc.gnu.org/pipermail/fortran/2024-October/061204.html for more
detailed information.

(From OE-Core rev: 660e00469f9c99fe733cc8b37f67438a96ff2e97)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
2025-01-24 07:59:39 -08:00

90 lines
2.9 KiB
PHP

require gcc-configure-common.inc
EXTRA_OECONF_PATHS = "\
--with-sysroot=/not/exist \
--with-build-sysroot=${STAGING_DIR_TARGET} \
"
# An arm hard float target like raspberrypi4 won't build
# as CFLAGS don't make it to the fortran compiler otherwise
# (the configure script sets FC to $GFORTRAN unconditionally)
export GFORTRAN = "${FC} -fcanon-prefix-map -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} -gno-record-gcc-switches"
do_configure () {
for target in libbacktrace libgfortran
do
rm -rf ${B}/${TARGET_SYS}/$target/
mkdir -p ${B}/${TARGET_SYS}/$target/
cd ${B}/${TARGET_SYS}/$target/
chmod a+x ${S}/$target/configure
relpath=${@os.path.relpath("${S}", "${B}/${TARGET_SYS}")}
../$relpath/$target/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_SYS}/$target/libtool
done
}
EXTRACONFFUNCS += "extract_stashed_builddir"
do_configure[depends] += "${COMPILERDEP}"
do_compile () {
for target in libbacktrace libgfortran
do
cd ${B}/${TARGET_SYS}/$target/
oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/$target/
done
}
do_install () {
cd ${B}/${TARGET_SYS}/libgfortran/
oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/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}
}
# avoid virtual/libc
INHIBIT_DEFAULT_DEPS = "1"
DEPENDS = "virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}compilerlibs"
BBCLASSEXTEND = "nativesdk"
PACKAGES = "\
${PN}-dbg \
libgfortran \
libgfortran-dev \
libgfortran-staticdev \
"
LICENSE:${PN} = "GPL-3.0-with-GCC-exception"
LICENSE:${PN}-dev = "GPL-3.0-with-GCC-exception"
LICENSE:${PN}-dbg = "GPL-3.0-with-GCC-exception"
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* \
${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude/ \
${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ \
"
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")
if "fortran" not in f:
raise bb.parse.SkipRecipe("libgfortran needs fortran support to be enabled in the compiler")
}