Skip to contentSkip to conversation

system: update lib64/32 symlink creation for mips64n32 and gcc >= 5.1.0

PATCH Superseded Thomas De Schampheleire 2 participants 5 messages Dec 16, 2019 – Dec 17, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 system: update lib64/32 symlink creation for mips64n32 and gcc >= 5.1.0

From: Thomas De Schampheleire <[email protected]>

In gcc 5.1.0, a change was introduced which causes internal search paths inside the sysroot to be relative to 'lib64' rather than 'lib'. See [1] [2] and [3]. As Buildroot only creates a lib32->lib symlink for mips64n32, these internal paths could not be found, leading to compilation errors.

For example for dtc:

     LD convert-dtsv0
    /opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
    /opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:236: convert-dtsv0] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Leaving directory '/opt/buildroot/output/build/dtc-1.4.7'
    make: *** [package/pkg-generic.mk:241: /opt/buildroot/output/build/dtc-1.4.7/.stamp_built] Error 2

In this case, crt1.o was searched for in following locations:

    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Fix this problem by creating both 'lib32' as 'lib64' symlinks in case of mips64n32.

[1] https://github.com/gcc-mirror/gcc/commit/257ccd463a4f25495b252a3bdf989d057c54678d
[2] https://gcc.gnu.org/ml/gcc-patches/2014-10/msg03377.html
[3] https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00539.html

---
 system/system.mk | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Note: problem was discovered and tested on the Marvell Octeon gcc 7.x-based toolchain.

system/system.mk +11 -2
index 8db87cb129..8fe2c138b0 100644
@@ -56,9 +56,18 @@ define SYSTEM_RSYNC
 endef
 
 # Make a symlink lib32->lib or lib64->lib as appropriate.
-# MIPS64/n32 requires lib32 even though it's a 64-bit arch.
+# MIPS64/n32 requires lib32 even though it's a 64-bit arch. However, since gcc
+# 5.1.0 internal compiler paths in sysroot are relative to lib64, so we must
+# create both.
 # $(1): base dir (either staging or target)
-ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
+ifeq ($(BR2_MIPS_NABI32),y)
+define SYSTEM_LIB_SYMLINK
+	ln -snf lib $(1)/lib64
+	ln -snf lib $(1)/usr/lib64
+	ln -snf lib $(1)/lib32
+	ln -snf lib $(1)/usr/lib32
+endef
+else ifeq ($(BR2_ARCH_IS_64),y)
 define SYSTEM_LIB_SYMLINK
 	ln -snf lib $(1)/lib64
 	ln -snf lib $(1)/usr/lib64
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/1 system: update lib64/32 symlink creation for mips64n32 and gcc >= 5.1.0

Quoted 20 lines · On Mon, 16 Dec 2019 16:22:23 +0100 Thomas De Schampheleire…

From: Thomas De Schampheleire <[email protected]>

In gcc 5.1.0, a change was introduced which causes internal search paths inside the sysroot to be relative to 'lib64' rather than 'lib'. See [1] [2] and [3]. As Buildroot only creates a lib32->lib symlink for mips64n32, these internal paths could not be found, leading to compilation errors.

For example for dtc:

     LD convert-dtsv0
    /opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
    /opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:236: convert-dtsv0] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Leaving directory '/opt/buildroot/output/build/dtc-1.4.7'
    make: *** [package/pkg-generic.mk:241: /opt/buildroot/output/build/dtc-1.4.7/.stamp_built] Error 2

In this case, crt1.o was searched for in following locations:

Quoted 8 lines
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
    16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

So it is in fact search in ../lib32-fp/ relatively to lib64/

Quoted 4 lines

16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory) 16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory) 16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory) 16073 access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

And then in lib64/ itself.

Which means the lib32 symbolic link is in fact useless ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 system: update lib64/32 symlink creation for mips64n32 and gcc >= 5.1.0

Quoted 65 lines · On Mon, Dec 16, 2019, 16:26 Thomas Petazzoni <[email protected]>…
Quoted 4 lines · On Mon, 16 Dec 2019 16:22:23 +0100 Thomas De Schampheleire…

From: Thomas De Schampheleire <[email protected]>

In gcc 5.1.0, a change was introduced which causes internal search paths inside the sysroot to be relative to 'lib64' rather than 'lib'. See [1]

[2]

Quoted 7 lines

and [3]. As Buildroot only creates a lib32->lib symlink for mips64n32, these internal paths could not be found, leading to compilation errors.

For example for dtc:

LD convert-dtsv0

/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/bin/ld:
cannot find crt1.o: No such file or directory

Quoted 1 line

/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/bin/ld:
cannot find crti.o: No such file or directory

Quoted 5 lines
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:236: convert-dtsv0] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Leaving directory '/opt/buildroot/output/build/dtc-1.4.7'
    make: *** [package/pkg-generic.mk:241:

/opt/buildroot/output/build/dtc-1.4.7/.stamp_built] Error 2

Quoted 4 lines

In this case, crt1.o was searched for in following locations:

    16073

access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/mips64-octeon-linux-gnu/7.3.0/../../../../mips64-octeon-linux-gnu/lib/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/n32/octeon3/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/../lib32-fp/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

So it is in fact search in ../lib32-fp/ relatively to lib64/

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 8 lines
Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

And then in lib64/ itself.

Which means the lib32 symbolic link is in fact useless ?

In this case this was Octeon3 which has hardfloat and uses lib32-fp instead of lib32. But the problem should be analogous for Octeon2 (no hardfloat, with libdir lib32).

Also, we need to remain compatible with old and new compilers, so I'm a bit afraid to change more than the above...

Best regards,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20191216/4fe126f5/attachment.html>

#3 lore raw

PATCH 1/1 system: update lib64/32 symlink creation for mips64n32 and gcc >= 5.1.0

Hello,

Quoted 13 lines · On Mon, 16 Dec 2019 18:34:53 +0100 Thomas De Schampheleire…
Quoted 13 lines
Quoted 1 line
    16073  

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073  

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073  

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073  

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 8 lines
Quoted 4 lines

And then in lib64/ itself.

Which means the lib32 symbolic link is in fact useless ?

In this case this was Octeon3 which has hardfloat and uses lib32-fp instead of lib32. But the problem should be analogous for Octeon2 (no hardfloat, with libdir lib32).

Right, but it means that this lib32/ symlink doesn't work for all toolchains, some toolchains would need a lib32-fp/ symlink... but by luck they also look under lib64/, even if the user-space is 32-bit.

I'm not suggesting we need to change anything to the patch itself, only perhaps to the comments and/or commit log, just to clarify the issue.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 system: update lib64/32 symlink creation for mips64n32 and gcc >= 5.1.0

Hi Thomas,

El lun., 16 dic. 2019 a las 21:00, Thomas Petazzoni (<[email protected]>) escribi?:

Quoted 24 lines

Hello,

Quoted 18 lines · On Mon, 16 Dec 2019 18:34:53 +0100 Thomas De Schampheleire…
Quoted 17 lines
Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/mips64-octeon-linux-gnu/7.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

Quoted 1 line
    16073

access("/opt/buildroot/output/host/mips64-buildroot-linux-gnu/sysroot/usr/lib64/crt1.o", R_OK) = -1 ENOENT (No such file or directory)

And then in lib64/ itself.

Which means the lib32 symbolic link is in fact useless ?

Quoted 7 lines
Quoted 3 lines

In this case this was Octeon3 which has hardfloat and uses lib32-fp instead of lib32. But the problem should be analogous for Octeon2 (no hardfloat, with libdir lib32).

Right, but it means that this lib32/ symlink doesn't work for all toolchains, some toolchains would need a lib32-fp/ symlink... but by luck they also look under lib64/, even if the user-space is 32-bit.

For the mentioned Octeon toolchain, here are the values of the paths as detected by the toolchain logic:

- octeon2 (soft-float) SYSROOT_DIR=/home/tdescham/repo/isam/buildroot/output/host/opt/ext-toolchain/mips64-octeon-linux-gnu/sys-root/; ARCH_SYSROOT_DIR=/home/tdescham/repo/isam/buildroot/output/host/opt/ext-toolchain/mips64-octeon-linux-gnu/sys-root/; ARCH_SUBDIR=;
ARCH_LIB_DIR=lib32/octeon2; SUPPORT_LIB_DIR=/home/tdescham/repo/isam/buildroot/output/host/opt/ext-toolchain/mips64-octeon-linux-gnu/lib32/octeon2/

- octeon3 (hard-float) SYSROOT_DIR=/home/tdescham/repo/isam/buildroot/output/host/opt/ext-toolchain/mips64-octeon-linux-gnu/sys-root/; ARCH_SYSROOT_DIR=/home/tdescham/repo/isam/buildroot/output/host/opt/ext-toolchain/mips64-octeon-linux-gnu/sys-root/; ARCH_SUBDIR=;
ARCH_LIB_DIR=lib32-fp; SUPPORT_LIB_DIR=/home/tdescham/repo/isam/buildroot/output/host/opt/ext-toolchain/mips64-octeon-linux-gnu/lib32-fp/

The function create_lib_symlinks in toolchain/toolchain-external/pkg-toolchain-external.mk will use ARCH_LIB_DIR and create an additional link $(ARCH_LIB_DIR)->lib. In this case, the situation is thus:

lrwxrwxrwx 1 tdescham tdescham    3 Dec 17 15:37 lib32 -> lib/
lrwxrwxrwx 1 tdescham tdescham    3 Dec 17 15:37 lib32-fp -> lib/
lrwxrwxrwx 1 tdescham tdescham    3 Dec 17 15:37 lib64 -> lib/

Where the 'lib32' one is probably not needed, and the 'lib64' one is added by this patch.

Quoted 3 lines

I'm not suggesting we need to change anything to the patch itself, only perhaps to the comments and/or commit log, just to clarify the issue.

I can try to extend it..

Best regards,
Thomas