LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   TAR cross-compile error (arm-linux-gnueabi) (https://www.linuxquestions.org/questions/linux-software-2/tar-cross-compile-error-arm-linux-gnueabi-4175642648/)

Michele13 11-19-2018 06:31 AM

TAR cross-compile error (arm-linux-gnueabi)
 
Hello, I'm having trouble cross-compiling TAR-1.30. I would like to get a static tar executable so that I can Copy it to my phone and use it to extract tar archives from the terminal (busybox tar does not work very well sometimes).

Here is the configure command that I used:

Code:

./configure --prefix=/home/michele/tmp/arm-bin/install/ --host=arm-linux-gnueabi CFLAGS="-Os -g0" CXXFLAGS="-Os -g0" LDFLAGS="-s -static"
and here is the error:

Code:

  CC      areadlink-with-size.o
In file included from /home/michele/x-tools/arm-linux-gnueabi/arm-linux-gnueabi/include/stdlib.h:1014,
                from ./stdlib.h:36,
                from areadlink-with-size.c:28:
/home/michele/x-tools/arm-linux-gnueabi/arm-linux-gnueabi/include/bits/stdlib.h: In function ‘wctomb’:
/home/michele/x-tools/arm-linux-gnueabi/arm-linux-gnueabi/include/bits/stdlib.h:90:3: error: #error "Assumed value of MB_LEN_MAX wrong"
 # error "Assumed value of MB_LEN_MAX wrong"
  ^~~~~
Makefile:1897: set di istruzioni per l'obiettivo "areadlink-with-size.o" non riuscito
make[4]: *** [areadlink-with-size.o] Errore 1
make[4]: uscita dalla directory "/home/michele/tmp/arm-bin/tar-1.30/gnu"
Makefile:1922: set di istruzioni per l'obiettivo "all-recursive" non riuscito
make[3]: *** [all-recursive] Errore 1
make[3]: uscita dalla directory "/home/michele/tmp/arm-bin/tar-1.30/gnu"
Makefile:1583: set di istruzioni per l'obiettivo "all" non riuscito
make[2]: *** [all] Errore 2
make[2]: uscita dalla directory "/home/michele/tmp/arm-bin/tar-1.30/gnu"
Makefile:1388: set di istruzioni per l'obiettivo "all-recursive" non riuscito
make[1]: *** [all-recursive] Errore 1
make[1]: uscita dalla directory "/home/michele/tmp/arm-bin/tar-1.30"
Makefile:1327: set di istruzioni per l'obiettivo "all" non riuscito
make: *** [all] Errore 2

I'm using gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
as native compiler.

These are the info on my cross-compiler (built manually):

Code:

COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/michele/x-tools/arm-linux-gnueabi/libexec/gcc/arm-linux-gnueabi/8.2.0/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../configure --target=arm-linux-gnueabi --prefix=/home/michele/x-tools/arm-linux-gnueabi/ --enable-languages=c,c++ --disable-libsanitizer --disable-multilib --disable-libmpx
Thread model: posix
gcc version 8.2.0 (GCC)

Cross Binutils 2.31.1

Code:

../configure --target=arm-linux-gnueabi --disable-nls --disable-multilib CFLAGS="-Os -g0" CXXFLAGS="-Os -g0" LDFLAGS="-s"
and Glibc 2.28 compiled with "--disable-werror", otherwise it would fail because of a warning being treated as an error while compiling op-2.h

Can someone help me with this? The toolchain can cross-compile some complex packages such as:

- binutils
- gmp
- mpfr
- mpc
- gcc
- glibc (disable werror)
- busybox
- xz

but it fails with this one. What can I do?

dc.901 11-19-2018 07:35 AM

What phone/OS? On Android, there are apps that can handel tar files, and I am sure similar apps exist for iOS.
Sorry, perhaps not what you are asking, but trying to understand why is this really needed?

Michele13 11-19-2018 08:17 AM

Quote:

Originally Posted by dc.901 (Post 5927645)
What phone/OS? On Android, there are apps that can handel tar files, and I am sure similar apps exist for iOS.
Sorry, perhaps not what you are asking, but trying to understand why is this really needed?

Because I really love playing on the command line, I love linux and I would like to install a hand made linux distribution inside my phone. I cross-compiled GCC, binutils, Glibc and make to bootstrap a little chroot where I can jail myself using proot, with this I can start tinkering and building other packages natively from my phone. I really enjoy compiling stuff, and I would like to create a sort of pocket machine that I can use as a laptop or something similar. However I don't know how to solder things, don't have much money but I like to learn how software works, how a certain result is achived by a software. I know that android has an issue with hardlinks (you are not allowed to create them) but I think that I've resolved the problem by trying to avoid the use of hardlinks alltoghther by using a script that I've wrote.

Even if an application was not what I was looking for Thanks for your help. :)
Does someone else know how to fix the problem with the build process of tar? It's very important to me to fix this issue

Michele13 11-25-2018 05:13 PM

Can someone help? Please, if you need some extra details just tell me, I'll try to give them to you.

EDIT:

Ok, I've figured
out the problem. My Cross compiler is a normal
cross-compiler without a full limits.h. When you build TAR the compiler looks inside its internal fix-include directory that has a limits.h file. Unfortunately that file is not complete yet and the compilation fails.

areadlink-with-size.c calls limits.h which is incomplete.

the incomplete file is inside $GCC_INST_DIR/lib/gcc/arm-linux-gnueabi/$GCC_VERSION/include-fixed/

here is the code that we are interested in:

Code:

/* Maximum length of a multibyte character.  */
#ifndef MB_LEN_MAX
#define MB_LEN_MAX 1
#endif

after that it calls stdlib.h inside $GCC_INST_DIR/arm-linux-gnueabi/stdlib.h
which calls $GCC_INST_DIR/arm-linux-gnueabi/include/bits/stdlib.h

and it says:

Code:

__NTH (wctomb (char *__s, wchar_t __wchar))
{
  /* We would have to include <limits.h> to get a definition of MB_LEN_MAX.
    But this would only disturb the namespace.  So we define our own
    version here.  */
#define __STDLIB_MB_LEN_MAX        16
#if defined MB_LEN_MAX && MB_LEN_MAX != __STDLIB_MB_LEN_MAX
# error "Assumed value of MB_LEN_MAX wrong"
#endif
  if (__bos (__s) != (size_t) -1 && __STDLIB_MB_LEN_MAX > __bos (__s))
    return __wctomb_chk (__s, __wchar, __bos (__s));
  return __wctomb_alias (__s, __wchar);
}

__STDLIB_MB_LEN_MAX is 16
MB_LEN_MAX (inside the incomplete limits.h) is 1

16 is different than 1 and so it fails with the folowing error:

# error "Assumed value of MB_LEN_MAX wrong"

To fix the problem you have to go inside GCC's source directory and type the command:

Code:

cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $(arm-linux-gnueabi-gcc -print-libgcc-file-name)`/include-fixed/limits.h

the now complete limits.h calls GLIBC's limits.h and now the compilation can complete successfully!

Code:

#include_next <limits.h>                /* recurse down to the real one */
The problem is now fixed


All times are GMT -5. The time now is 11:59 PM.