3

I am tying to cross-compile GLIBC_2.36 from source for ARM. I am using arm-linux-gnueabihf toolchain to do this. The command I am passing from my build directory is below:

../glibc-2.36/configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --prefix=$PWD --enable-kernel=5.10 CFLAGS="-O2 -Wno-error=pragmas -Wno-error=builtin-declaration-mismatch"

Then I do make -j4 to start the build process but it fails with the below error:

In file included from <command-line>:
iofgetpos.c:84:40: error: conflicting types for ‘fgetpos’; have ‘int(FILE *, __fpos_t *)’ {aka ‘int(struct _IO_FILE *, struct _G_fpos_t *)’}
   84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
      |                                        ^~~~~~~
./../include/libc-symbols.h:155:26: note: in definition of macro ‘_weak_alias’
  155 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
      |                          ^~~~~~~~~
../include/shlib-compat.h:117:3: note: in expansion of macro ‘weak_alias’
  117 |   weak_alias (local, symbol)
      |   ^~~~~~~~~~
iofgetpos.c:84:1: note: in expansion of macro ‘versioned_symbol’
   84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
      | ^~~~~~~~~~~~~~~~
In file included from ../include/sys/cdefs.h:10,
                 from ../include/features.h:490,
                 from ../stdlib/errno.h:25,
                 from ../include/errno.h:2,
                 from libioP.h:40,
                 from iofgetpos.c:34:
../libio/stdio.h:768:24: note: previous declaration of ‘fgetpos’ with type ‘int(FILE * restrict,  fpos_t * restrict)’ {aka ‘int(struct _IO_FILE * restrict,  struct _G_fpos64_t * restrict)’}
  768 | extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
      |                        ^~~~~~~
../misc/sys/cdefs.h:247:41: note: in definition of macro ‘__REDIRECT’
  247 | # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))

I need GLIBC_2.36 specifically since my target platform has this version, and static linking is not an option. My build platform is x86_64

6
  • since it's a library (that will be later cross-compiled) and not an executable, try removing the host part : ../glibc-2.36/configure --target=arm-linux-gneabihf --prefix=$PWD --enable-kernel=5.10 CFLAGS="-O2 -Wno-error=pragmas -Wno-error=builtin-declaration-mismatch" Commented yesterday
  • @W4ZM if I do that it will start ompiling for x86_64. It has to be cross-compiled for ARM Commented yesterday
  • that's the point, no it won't, i was confused also when i faced this issue at the first time, but when i examined a compiled object file from the library with the command file in linux i found that it's compiled for ARM. Commented yesterday
  • If you specify just --host it tries to make a native build but uses your specification rather than guessing. Looking at the docs, you need --build to specify what you are building on and --host for the system that the library is for. Commented yesterday
  • You want the 'x86' for the host. The glibc may build tools (not just the library). The tools might not be end-user, but something to take data files and translate to source or objects. So, when building, you need your 'host' correct to be the hosting build machine. For glibc, 'host==build'. See: build,host,target. 'target' is arm. For a cross-compiler, the build could be x86, host could be 'powerpc mac' and the target an 'arm-linux'. Usually host==build. Most don't need 'build'. Commented 5 hours ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.