cross icon indicating copy to clipboard operation
cross copied to clipboard

aarch64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)

Open jszwedko opened this issue 4 years ago • 5 comments
trafficstars

Similar to https://github.com/rust-embedded/cross/pull/501, I'm wondering how difficult it'd be to also lower the requirement for aarch64-unknown-linux-gnu to 2.17.

Notably I think the table entry is out-of-date:

aarch64-unknown-linux-gnu 2.19 4.8.2 4.1.0

At least when building my test binary, it seems to only include symbols from 2.17 and 2.18.

	linux-vdso.so.1 (0x0000ffffb1de6000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000ffffb1d46000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x0000ffffb1d11000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000ffffb1ce0000)
	libc.so.6 => /lib64/libc.so.6 (0x0000ffffb1b5a000)
	/lib/ld-linux-aarch64.so.1 (0x0000ffffb1da8000)

	Version information:
	./tmp:
		libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6
		libc.so.6 (GLIBC_2.18) => /lib64/libc.so.6
		libgcc_s.so.1 (GCC_3.3) => /lib64/libgcc_s.so.1
		libgcc_s.so.1 (GCC_3.0) => /lib64/libgcc_s.so.1
		libgcc_s.so.1 (GCC_4.2.0) => /lib64/libgcc_s.so.1
		libpthread.so.0 (GLIBC_2.17) => /lib64/libpthread.so.0
		libdl.so.2 (GLIBC_2.17) => /lib64/libdl.so.2
	/lib64/libdl.so.2:
		ld-linux-aarch64.so.1 (GLIBC_PRIVATE) => /lib/ld-linux-aarch64.so.1
		ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1
		libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
		libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6
	/lib64/libpthread.so.0:
		ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1
		ld-linux-aarch64.so.1 (GLIBC_PRIVATE) => /lib/ld-linux-aarch64.so.1
		libc.so.6 (GLIBC_PRIVATE) => /lib64/libc.so.6
		libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6
	/lib64/libgcc_s.so.1:
		libc.so.6 (GLIBC_2.17) => /lib64/libc.so.6
	/lib64/libc.so.6:
		ld-linux-aarch64.so.1 (GLIBC_2.17) => /lib/ld-linux-aarch64.so.1
		ld-linux-aarch64.so.1 (GLIBC_PRIVATE) => /lib/ld-linux-aarch64.so.1

jszwedko avatar Mar 09 '21 18:03 jszwedko

This seems to be a duplicate of #455

Ten0 avatar May 22 '22 14:05 Ten0

For lowering glibc version I'd want something as described in #680. Thanks for doing some triaging @Ten0 <3

Emilgardis avatar May 22 '22 16:05 Emilgardis

I think we can do this in https://github.com/cross-rs/cross-toolchains. It shouldn't be too hard to add an aarch64-unknown-linux-gnu target with an older glibc using crosstool-ng.

Alexhuszagh avatar Jul 02 '22 19:07 Alexhuszagh

It's a little trickier than required since crosstool-ng has bugs with glibc for aarch64 below 2.25. See the discussion for dockcross. It seems config.guess is probably wrong, and this leads to the following error output:

[INFO ]  =================================================================
[INFO ]  Installing C library headers & start files
[INFO ]    =================================================================
[INFO ]    Building for multilib 1/1: ''
[EXTRA]      Configuring C library
[ERROR]      checking sysdep dirs... configure: error: The aarch64 is not supported.

The discussed solution, enabling ports, did not work. I guess the other solution would be to use the manylinux2014_aarch64 toolchain, however, this is a native toolchain for aarch64, so running it on an x86_64 host may not work as desired. However, running it does show the toolchain uses glibc 2.17:

$  docker run -it --rm quay.io/pypa/manylinux2014_aarch64:latest bash
$ echo '#include <iostream>
int main() {
    std::cout << "Hello" << std::endl;
    return 0;
}' > main.cc
$ g++ main.cc
$ readelf -a a.out | grep GLIBC
000000420050  000c00000400 R_AARCH64_COPY    0000000000420050 _ZSt4cout@GLIBCXX_3.4 + 0
000000420000  000100000402 R_AARCH64_JUMP_SL 0000000000000000 __libc_start_main@GLIBC_2.17 + 0
000000420010  000300000402 R_AARCH64_JUMP_SL 0000000000000000 _ZNSt8ios_base4In[...]@GLIBCXX_3.4 + 0
000000420018  000400000402 R_AARCH64_JUMP_SL 0000000000000000 __cxa_atexit@GLIBC_2.17 + 0
000000420020  000b00000402 R_AARCH64_JUMP_SL 0000000000400750 _ZNSt8ios_base4In[...]@GLIBCXX_3.4 + 0
000000420028  000600000402 R_AARCH64_JUMP_SL 0000000000000000 _ZStlsISt11char_t[...]@GLIBCXX_3.4 + 0
000000420030  000800000402 R_AARCH64_JUMP_SL 0000000000000000 abort@GLIBC_2.17 + 0
000000420038  000900000402 R_AARCH64_JUMP_SL 0000000000000000 _ZNSolsEPFRSoS_E@GLIBCXX_3.4 + 0
000000420040  000a00000402 R_AARCH64_JUMP_SL 0000000000400790 _ZSt4endlIcSt11ch[...]@GLIBCXX_3.4 + 0
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND [...]@GLIBCXX_3.4 (3)
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
     6: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND [...]@GLIBCXX_3.4 (3)
     8: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort@GLIBC_2.17 (2)
     9: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND [...]@GLIBCXX_3.4 (3)
    10: 0000000000400790     0 FUNC    GLOBAL DEFAULT  UND [...]@GLIBCXX_3.4 (3)
    11: 0000000000400750     0 FUNC    GLOBAL DEFAULT  UND [...]@GLIBCXX_3.4 (3)
    12: 0000000000420050   272 OBJECT  GLOBAL DEFAULT   24 [...]@GLIBCXX_3.4 (3)
    91: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort@@GLIBC_2.17
    94: 0000000000420050   272 OBJECT  GLOBAL DEFAULT   24 _ZSt4cout@@GLIBC[...]
  000:   0 (*local*)       2 (GLIBC_2.17)    0 (*local*)       3 (GLIBCXX_3.4)
  004:   2 (GLIBC_2.17)    0 (*local*)       3 (GLIBCXX_3.4)   0 (*local*)    
  008:   2 (GLIBC_2.17)    3 (GLIBCXX_3.4)   3 (GLIBCXX_3.4)   3 (GLIBCXX_3.4)
  00c:   3 (GLIBCXX_3.4)
  0x0010:   Name: GLIBCXX_3.4  Flags: none  Version: 3
  0x0030:   Name: GLIBC_2.17  Flags: none  Version: 2

So it uses the correct version: it's very slow (on x86_64) but it works.

Alexhuszagh avatar Jul 04 '22 00:07 Alexhuszagh

I updated config.guess in https://github.com/cross-rs/cross/pull/726 and was able to get it working halfways with that

Emilgardis avatar Jul 04 '22 08:07 Emilgardis