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

androidsdk: Re-add emulator #49515

Closed
wants to merge 1 commit into from
Closed

Conversation

clefru
Copy link
Contributor

@clefru clefru commented Oct 31, 2018

Motivation for this change
<clefru> I can't execute <nixpkgs-unstable>.androidenv.android_8_0/libexec/tools/emulator. This will give "./emulator: line 5: /nix/store/[...]-android-sdk-26.1.1/libexec/tools/.emulator-wrapped: No such file or directory". The file is clearly there however. This smells like a linker error. "ldd -d"-ing the file shows no missing dependencies. "objdump -x" shows no crazy rpath's. Running that wrapped file with LD_DEBUG=all doesn't even produce a single line of 
<clefru> output. strace-ing shows the execve call fails right there. I am bit puzzled. 
<clever> clefru: what about file on the binary?
<clefru> file-ing "/nix/store/[...]-android-sdk-26.1.1/libexec/tools/.emulator-wrapped" gives  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.15, stripped, so I don't even have an arch mismatch
<clever> clefru: yep, its /lib64/ld-linux-x86-64.so.2 thats not found
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@@ -78,6 +78,8 @@ stdenv.mkDerivation rec {
${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
for i in emulator emulator-check
do
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
Copy link
Member

Choose a reason for hiding this comment

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

Was is not possible to set the rpath and interpreter within the same invocation?

Copy link
Member

@Mic92 Mic92 Nov 1, 2018

Choose a reason for hiding this comment

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

This also seems to duplicated LD_LIBRARY_PATH below. Is emulator calling any unpatched binaries or is using dlopen at runtime that justify LD_LIBRARY_PATH? Otherwise all libraries could be moved up to this rpath invocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also seems to duplicated LD_LIBRARY_PATH below. Is emulator calling any unpatched binaries or is using dlopen at runtime that justify LD_LIBRARY_PATH? Otherwise all libraries could be moved up to this rpath invocation.

I can't answer that.

Was is not possible to set the rpath and interpreter within the same invocation?

I combined the invocation.

@myguidingstar
Copy link
Contributor

@clefru I got this error when trying to launch emulator:

[140623058774912]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at /nix/store/ks3zbnxm0kaq1js6cdzxi1ji3q52h6r7-android-sdk-26.1.1/emulator/lib64/qt/lib
Could not launch '/nix/store/ks3zbnxm0kaq1js6cdzxi1ji3q52h6r7-android-sdk-26.1.1/emulator/qemu/linux-x86_64/qemu-system-x86_64': No such file or directory

@clefru
Copy link
Contributor Author

clefru commented Nov 1, 2018

@clefru I got this error when trying to launch emulator:

[140623058774912]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at /nix/store/ks3zbnxm0kaq1js6cdzxi1ji3q52h6r7-android-sdk-26.1.1/emulator/lib64/qt/lib
Could not launch '/nix/store/ks3zbnxm0kaq1js6cdzxi1ji3q52h6r7-android-sdk-26.1.1/emulator/qemu/linux-x86_64/qemu-system-x86_64': No such file or directory

I am aware of that. Looks like the qemu binaries were removed, and moved into a downloadable artefact, see https://developer.android.com/studio/releases/emulator

I don't understand how to access the artifact, and this needs to be addressed in a separate commit. This PR is solely reverting a change in 950608b#diff-8732e6195b98297321a5343f293624cfL68

@clefru clefru force-pushed the android-emulator-fix branch 2 times, most recently from 36a57a3 to 54779e9 Compare November 1, 2018 14:21
@clefru clefru changed the title androidsdk: emulator(-check) binaries still require patchElf. androidsdk: Re-add emulator Nov 1, 2018
@clefru
Copy link
Contributor Author

clefru commented Nov 1, 2018

I found a way to re-add the emulator. It's a bit crude. Please test.

You can only invoke the emulator by the fully wrapped entry points under libexec/tools/*. The binaries under libexec/emulator/ are only patched for their interpreter. rpath's aren't fixed as this will be inherited from the LD_LIBRARY_PATH wrap when call from libexec/tools/emulator.

@myguidingstar
Copy link
Contributor

just tested. The error remains:

[140160916286336]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at /nix/store/7a5q5cqk39zc031pan4ld9993bw9qanf-android-sdk-26.1.1/emulator/lib64/qt/lib
Could not launch '/nix/store/7a5q5cqk39zc031pan4ld9993bw9qanf-android-sdk-26.1.1/emulator/qemu/linux-x86_64/qemu-system-x86_64': No such file or directory

@clefru
Copy link
Contributor Author

clefru commented Nov 2, 2018

Updated PR to wrap/patch all emulator binaries. Please retest. This probably needlessly patches/wraps a few binaries.

@myguidingstar
Copy link
Contributor

the qt error is still there :(

@clefru
Copy link
Contributor Author

clefru commented Nov 3, 2018

Ah, the problem seems to be not including emulator/lib64/qt/lib into the LD_LIBRARY_PATH. Well, this is getting tedious. I am not going to manually figure out which binary needs which.

I suggest that we plainly revert 950608b#diff-8732e6195b98297321a5343f293624cfL68 and then work on a plan to merge https://discourse.nixos.org/t/my-revised-experimental-android-build-functions/923

This is a dead-end here.

@clefru clefru closed this Nov 3, 2018
@myguidingstar
Copy link
Contributor

@clefru can you give me some instruction on how to make use of Sander's nix-androidenvtests above. How do I put things together and what does a basic .nix to feed to nix-build look like?

@clefru
Copy link
Contributor Author

clefru commented Nov 3, 2018

I replied to you on the discourse thread. Best option might be to stick to the 18.09 release, which should still have a working emulator.

@corngood
Copy link
Contributor

@clefru I took your change made a small fixup: corngood@d3c3221

It's just ignoring tools/emulator and linking to emulator/emulator instead.

The emulator starts up fine for me now, but I haven't tested it a whole lot.

@Mic92
Copy link
Member

Mic92 commented Nov 10, 2018

@corngood can you open a pull request?

@corngood
Copy link
Contributor

@Mic92 I can, but I think it might still need a bit more work. There's this error when starting the emulator:

ERROR: resizing partition failed to launch /nix/store/gw8sj81sp6wyby2xqa64jyw7z8b492nh-android-sdk-26.1.1/libexec/emulator/bin64/e2fsck

Which is probably just more missing elf patches.

Also the SDK reports that the emulator is out of date.

Mic92 added a commit to Mic92/nixpkgs that referenced this pull request Nov 12, 2018
@corngood corngood mentioned this pull request Nov 12, 2018
9 tasks
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