Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build Toybox with Android NDK #446

Closed
eugenesan opened this issue Jul 28, 2023 · 2 comments
Closed

Unable to build Toybox with Android NDK #446

eugenesan opened this issue Jul 28, 2023 · 2 comments

Comments

@eugenesan
Copy link

eugenesan commented Jul 28, 2023

I followed instructions for building Toybox with Android NDK.
The newest version I was able to build with NDK (21-25 with API 29-33) was 0.8.7.
Strangely 0.8.5 wouldn't build while 0.8.4 and 0.8.3 did just fine.

Anyone had better luck?

This what I used to build it:

#!/bin/sh -x

#unzip android-ndk-r25c-linux-x86_64.zip
NDK_TC_DIR=~/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin
NDK_TC=aarch64-linux-android-

cd ${NDK_TC_DIR}
test -f ${NDK_TC}cc || ln -s aarch64-linux-android33-clang ${NDK_TC}cc
test -f ${NDK_TC}strip || ln -s llvm-objcopy ${NDK_TC}strip
cd -

export PATH="${NDK_TC_DIR}:$PATH"

make distclean
make LDFLAGS=--static CROSS_COMPILE=${NDK_TC} defconfig toybox

Below is the failed build output of 0.8.9 (0.8.5+ fail with similar errors):

+ make distclean
cleaned
root cleaned
removed .config
+ make LDFLAGS=--static CROSS_COMPILE=aarch64-linux-android- defconfig toybox
cc -o kconfig/conf kconfig/conf.c kconfig/zconf.tab.c -DKBUILD_NO_NLS=1 \
	-DPROJECT_NAME=\"ToyBox\"
In file included from kconfig/zconf.tab.c:2340:
kconfig/confdata.c: In function ‘conf_write’:
kconfig/confdata.c:435:34: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 128 [-Wformat-overflow=]
  435 |                 sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
      |                                  ^~~~~~~~~~~~~~~~~
kconfig/confdata.c:435:17: note: ‘sprintf’ output between 13 and 150 bytes into a destination of size 128
  435 |                 sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/genconfig.sh
kconfig/conf -D /dev/null Config.in > /dev/null
scripts/make.sh
Library probe
generated/{Config.in,newtoys.h,flags.h,globals.h,tags.h,help.h}
Compile toybox
..........................toys/lsb/passwd.c:71:45: error: implicit declaration of function 'getspnam' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  if (*(pass = pw->pw_passwd)=='x' && (sp = getspnam(name))) pass = sp->sp_pwdp;
                                            ^
toys/lsb/passwd.c:71:43: warning: incompatible integer to pointer conversion assigning to 'struct spwd *' from 'int' [-Wint-conversion]
  if (*(pass = pw->pw_passwd)=='x' && (sp = getspnam(name))) pass = sp->sp_pwdp;
                                          ^ ~~~~~~~~~~~~~~
toys/lsb/passwd.c:71:71: error: incomplete definition of type 'struct spwd'
  if (*(pass = pw->pw_passwd)=='x' && (sp = getspnam(name))) pass = sp->sp_pwdp;
                                                                    ~~^
toys/lsb/passwd.c:58:10: note: forward declaration of 'struct spwd'
  struct spwd *sp;
         ^
toys/lsb/passwd.c:93:14: error: implicit declaration of function 'crypt' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      pass = crypt(toybuf+2048, pw->pw_passwd);
             ^
toys/lsb/passwd.c:93:12: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
      pass = crypt(toybuf+2048, pw->pw_passwd);
           ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toys/lsb/passwd.c:103:17: error: implicit declaration of function 'crypt' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    encrypted = crypt(toybuf, salt);
                ^
toys/lsb/passwd.c:103:15: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
    encrypted = crypt(toybuf, salt);
              ^ ~~~~~~~~~~~~~~~~~~~
3 warnings and 4 errors generated.
.make: *** [Makefile:17: toybox] Error 1
@eugenesan eugenesan changed the title Unable to build Toybox with NDK after version 0.8.4 Unable to build Toybox with NDK Jul 28, 2023
@eugenesan eugenesan changed the title Unable to build Toybox with NDK Unable to build Toybox with Android NDK Jul 28, 2023
@landley
Copy link
Owner

landley commented Jul 28, 2023

Not make defconfig, make android_defconfig. Some commands don't build under the NDK.

The biggest chunk of them is the shadow password stuff, which I have a patch locally to rewrite (fixes ~5 commands I think) but I've bumped that until next release...

@enh-google
Copy link
Collaborator

WAI and -- unlike macOS -- not obvious that make defconfig could ever auto-detect cross-compilation for Android...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants