Skip to contentSkip to conversation

gcc-cross: Fix linker and fortran symlinks

PATCH In review Khem Raj 2 participants 3 messages Jul 11, 2017

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 gcc-cross: Fix linker and fortran symlinks

If we used -fuse-ld gcc option, then it does not work ending in

collect2: fatal error: cannot find 'ld' compilation terminated.

This is because we are not creating proper symlinks for BFD and Gold linker in gcc installation

Secondly, we end up with dangling fortran compiler symlinks if fortran is not enabled when confguring gcc, therefore create these symlinks only when fortran support is enabled in gcc

---
 meta/recipes-devtools/gcc/gcc-cross.inc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/recipes-devtools/gcc/gcc-cross.inc +6 -4
index b08bc197ba..1e184a60db 100644
@@ -161,17 +161,19 @@ do_install () {
 
 	install -d ${D}${target_base_libdir}
 	install -d ${D}${target_libdir}
-    
+
 	# Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
 	# gfortran is fully backwards compatible. This is a safe and practical solution. 
-	ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
+	if [ -n "${@d.getVar('FORTRAN')}" ]; then
+		ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
+		fortsymlinks="g77 gfortran"
+	fi
 
-	
 	# Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
 	# found. These need to be relative paths so they work in different locations.
 	dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
 	install -d $dest
-	for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
+	for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip gcc cpp $fortsymlinks; do
 		ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
 		ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
 	done
Signature · 1 line
2.13.2
#1 lore raw

Shouldn't the symlink be created in ${D}${STAGING_DIR_NATIVE} as suggested in:
http://lists.openembedded.org/pipermail/openembedded-core/2014-April/091480.html

Quoted 69 lines · Khem Raj

If we used -fuse-ld gcc option, then it does not work ending in

collect2: fatal error: cannot find 'ld'

compilation terminated.

This is because we are not creating proper symlinks for BFD and Gold linker in gcc installation

Secondly, we end up with dangling fortran compiler symlinks if fortran is not enabled when confguring gcc, therefore create these symlinks only when fortran support is enabled in gcc

---
 meta/recipes-devtools/gcc/gcc-cross.inc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/recipes-devtools/gcc/gcc-cross.inc +1 -1
index b08bc197ba..1e184a60db 100644
@@ -161,17 +161,19 @@ do_install () {
 
        install -d ${D}${target_base_libdir}
        install -d ${D}${target_libdir}
-
+
        # Link gfortran to g77 to satisfy not-so-smart configure or hard

coded g77

        # gfortran is fully backwards compatible. This is a safe and
practical solution.
-       ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran
${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
meta/recipes-devtools/gcc/gcc-cross.inc +2 -0
+       if [ -n "${@d.getVar('FORTRAN')}" ]; then
+               ln -sf ${STAGING_DIR_NATIVE}${prefix_

native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_ native}/bin/${TARGET_PREFIX}g77 || true

meta/recipes-devtools/gcc/gcc-cross.inc +2 -1
+               fortsymlinks="g77 gfortran"
+       fi
 
-
        # Insert symlinks into libexec so when tools without a prefix are

searched for, the correct ones are

        # found. These need to be relative paths so they work in different
locations.
        dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
        install -d $dest
-       for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp
gfortran; do
+       for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip
gcc cpp $fortsymlinks; do
                ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
                ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t
${dest}${TARGET_PREFIX}$t
        done
--
2.13.2

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#2 lore raw
Quoted 3 lines · Martin Jansa

Shouldn't the symlink be created in ${D}${STAGING_DIR_NATIVE} as suggested in:
http://lists.openembedded.org/pipermail/openembedded-core/2014-April/091480.html

unrelated to this change but I agree, probably we can get by creating relative symlink in ${D}${STAGING_DIR_NATIVE}${prefix_native}/bin

Quoted 72 lines · Khem Raj
Quoted 68 lines

If we used -fuse-ld gcc option, then it does not work ending in

collect2: fatal error: cannot find 'ld'
compilation terminated.

This is because we are not creating proper symlinks for BFD and Gold linker in gcc installation

Secondly, we end up with dangling fortran compiler symlinks if fortran is not enabled when confguring gcc, therefore create these symlinks only when fortran support is enabled in gcc

---
 meta/recipes-devtools/gcc/gcc-cross.inc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/recipes-devtools/gcc/gcc-cross.inc +1 -1
index b08bc197ba..1e184a60db 100644
@@ -161,17 +161,19 @@ do_install () {
 
        install -d ${D}${target_base_libdir}
        install -d ${D}${target_libdir}
-
+
        # Link gfortran to g77 to satisfy not-so-smart configure or hard

coded g77

        # gfortran is fully backwards compatible. This is a safe and
practical solution.
-       ln -sf
${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran
${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
meta/recipes-devtools/gcc/gcc-cross.inc +2 -0
+       if [ -n "${@d.getVar('FORTRAN')}" ]; then
+               ln -sf

${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true

meta/recipes-devtools/gcc/gcc-cross.inc +2 -1
+               fortsymlinks="g77 gfortran"
+       fi
 
-
        # Insert symlinks into libexec so when tools without a prefix are

searched for, the correct ones are

        # found. These need to be relative paths so they work in different
locations.
        dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
        install -d $dest
-       for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp
gfortran; do
+       for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip
gcc cpp $fortsymlinks; do
                ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
                ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t
${dest}${TARGET_PREFIX}$t
        done
--
2.13.2

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core