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

Android and related cross fixes #56197

Merged
merged 6 commits into from Feb 27, 2019
Merged

Conversation

matthewbauer
Copy link
Member

Motivation for this change

Gets more android things to build correctly.

echo "-D__ANDROID_API__=${stdenv.targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags
echo "-D__ANDROID_API__=${stdenv.targetPlatform.sdkVer} " >> $out/nix-support/cc-cflags
echo "-target ${stdenv.targetPlatform.config} " >> $out/nix-support/cc-cflags
echo "--gcc-toolchain=${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/${targetInfo.triple}-${targetInfo.gccVer}/prebuilt/${hostInfo.double} " >> $out/nix-support/cc-cflags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is stuff for LLVM?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah androidndk 18+ is using clang + ld.bfd. Apparently they are planning to move lld eventually. Maybe this would be a good chance to get rid of their toolchain completely and just use gccCrossStageStatic?

Copy link
Member

@Mic92 Mic92 Feb 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the nixpkgs side, gcc would be probably easier to support, since at the moment the defacto standard is: linux == gcc. Does the current cross-compiling port uses bionic or musl on android?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses bionic which would still make since. Right now we also use the NDKs c compiler which isn’t really necessary although it does save us building gcc for android. Since we have androidndk in hydra now i think it becomes easier to do thay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses bionic which would still make since. Right now we also use the NDKs c compiler which isn’t really necessary although it does save us building gcc for android. Since we have androidndk in hydra now i think it becomes easier to do that.

@@ -13,6 +13,7 @@
, extraPackages ? [], extraBuildCommands ? ""
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {}
, passthru ? {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually isn't needed anymore, although it might still be nice to get androidndk out of stdenv.

@@ -151,4 +148,7 @@ in {
};
};

unbound = super.unbound.override {
static = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe enableStatic for consistency?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, there does not seem to be a standard on naming things like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it’s inconsistent… enableStatic usually implies that you should build static libraries. In this case the static is needed for building the binaries statically. That’s the distinction i’ve arrived at between the two.

Now that i think about it, these aren’t really needed for this pr so i could leave them out.

@matthewbauer
Copy link
Member Author

It probably would work, but I think the stuff we do with -march flags (which was made generic) is still good, as I'm not sure the triple can control all that.

Could we do that for all gcc toolchains then? I think making it consistent is best for things like this.

@nomeata
Copy link
Contributor

nomeata commented Feb 24, 2019

Not sure if this is a regression, but on this branch I cannot build libiconv:

/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/src/./iconv.c:713: undefined reference to `__errno_location'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/src/./iconv.c:721: undefined reference to `__errno_location'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/src/./iconv.c:693: undefined reference to `__errno_location'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/src/./iconv.c:775: undefined reference to `__errno_location'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/src/./iconv.c:783: undefined reference to `__errno_location'
../srclib/libicrt.a(progname.o): In function `set_program_name':
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/srclib/progname.c:70: undefined reference to `program_invocation_short_name'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/srclib/progname.c:70: undefined reference to `program_invocation_short_name'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/srclib/progname.c:90: undefined reference to `program_invocation_name'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/srclib/progname.c:90: undefined reference to `program_invocation_name'
../srclib/libicrt.a(safe-read.o): In function `safe_read':
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/srclib/safe-read.c:70: undefined reference to `__errno_location'
../srclib/libicrt.a(strerror.o): In function `rpl_strerror':
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/srclib/strerror.c:60: undefined reference to `__errno_location'
../lib/.libs/libiconv.a(iconv.o): In function `libiconv_open':
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/lib/./iconv.c:238: undefined reference to `__errno_location'
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/lib/./iconv.c:246: undefined reference to `__errno_location'
../lib/.libs/libiconv.a(iconv.o): In function `unicode_loop_convert':
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/lib/./loop_unicode.h:(.text+0x81c): undefined reference to `__errno_location'
../lib/.libs/libiconv.a(iconv.o):/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/lib/./loop_unicode.h:347: more undefined references to `__errno_location' follow
../lib/.libs/libiconv.a(localcharset.o): In function `get_charset_aliases':
/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/lib/./../libcharset/lib/localcharset.c:217: undefined reference to `__isoc99_fscanf'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:78: iconv_no_i18n] Error 1
make[1]: Leaving directory '/tmp/nix-build-libiconv-1.15-aarch64-unknown-linux-android.drv-0/libiconv-1.15/src'
make: *** [Makefile:35: all] Error 2
builder for '/nix/store/86bvrw315q6s7hsp9fd3lgq4gzfzfs05-libiconv-1.15-aarch64-unknown-linux-android.drv' failed with exit code 2
cannot build derivation '/nix/store/74g33cc8px3galkxggx0w6a9wcd059jb-SDL-1.2.15-aarch64-unknown-linux-android.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0nykzav51d0cb9lxqx2k7r81npa5g5lz-aarch64-unknown-linux-android-ghc-8.6.3.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/j66xgjdpv3ldka7n93ic3lpy8jpq28zj-SDL-0.6.7.0-aarch64-unknown-linux-android.drv': 1 dependencies couldn't be built
error: build of '/nix/store/j66xgjdpv3ldka7n93ic3lpy8jpq28zj-SDL-0.6.7.0-aarch64-unknown-linux-android.drv' failed

(via nix-build -A pkgsCross.aarch64-android-prebuilt.haskellPackages.SDL)

@matthewbauer
Copy link
Member Author

matthewbauer commented Feb 24, 2019

Yeah im getting that now too. Should have a fix soon. Should be fixed.

These are no longer used. We build all targets now.
LLVM should be target independent because it will work with all
machine types. This is different from GCC where it needs to know what
target to build ahead of time.
(cherry picked from commit 08f5b419b9efc77db044f8c1d725632552617966)
This should be picking up the OpenGL ES headers provided by the NDK.
More testing is needed.
@matthewbauer matthewbauer changed the base branch from master to staging February 24, 2019 23:39
@matthewbauer matthewbauer changed the base branch from staging to master February 24, 2019 23:55
@matthewbauer matthewbauer changed the base branch from master to staging February 24, 2019 23:55
@nomeata
Copy link
Contributor

nomeata commented Mar 2, 2019

In the hope of not just producing noise: It seems that even with these changes, SDL (the C-library, independent of Haskell) does not cross-build, unless I am invoking it in a wrong way:

$ nix-build -A pkgsCross.aarch64-android-prebuilt.SDL
…
libtool: compile:  aarch64-unknown-linux-android-gcc -g -O2 -I./include -D_GNU_SOURCE=1 -fvisibility=hidden -DHAVE_LINUX_VERSION_H -Wall -c ./src/video/fbcon/SDL_fbelo.c  -fPIC -DPIC -o build/.libs/SDL_fbelo.o
In file included from ./src/video/fbcon/SDL_fb3dfx.c:26:
In file included from ./src/video/fbcon/SDL_fb3dfx.h:26:
In file included from ./src/video/fbcon/SDL_fbvideo.h:33:
In file included from ./src/video/fbcon/../SDL_sysvideo.h:37:
./include/SDL_opengl.h:116:9: warning: 'GL_GLEXT_VERSION' macro redefined [-Wmacro-redefined]
#define GL_GLEXT_VERSION 29
        ^
/usr/include/GL/glext.h:54:9: note: previous definition is here
#define GL_GLEXT_VERSION 20180725
        ^
In file included from ./src/video/fbcon/SDL_fbelo.c:29:
In file included from ./src/video/fbcon/SDL_fbvideo.h:33:
In file included from ./src/video/fbcon/../SDL_sysvideo.h:37:
./include/SDL_opengl.h:116:9: warning: 'GL_GLEXT_VERSION' macro redefined [-Wmacro-redefined]
#define GL_GLEXT_VERSION 29
        ^
/usr/include/GL/glext.h:54:9: note: previous definition is here
#define GL_GLEXT_VERSION 20180725
        ^
./src/video/fbcon/SDL_fbelo.c:221:2: error: invalid output constraint '=c' in asm
        FD_ZERO(&readfds);
        ^
/usr/include/sys/select.h:88:26: note: expanded from macro 'FD_ZERO'
#define FD_ZERO(fdsetp)         __FD_ZERO (fdsetp)
                                ^
/usr/include/bits/select.h:37:8: note: expanded from macro '__FD_ZERO'
                          : "=c" (__d0), "=D" (__d1)                          \
                            ^
1 warning and 1 error generated.
make: *** [build-deps:1070: build/SDL_fbelo.lo] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.
builder for '/nix/store/s92r33vfbpva297wq5aiawnl8f5g676b-SDL-1.2.15-aarch64-unknown-linux-android.drv' failed with exit code 2
error: build of '/nix/store/s92r33vfbpva297wq5aiawnl8f5g676b-SDL-1.2.15-aarch64-unknown-linux-android.drv' failed

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

Successfully merging this pull request may close these issues.

None yet

5 participants