-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Mobile updates #50596
Mobile updates #50596
Conversation
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/my-revised-experimental-android-build-functions/923/12 |
@Ericson2314 I could use your help for the stdenv.cross |
@matthewbauer I could use your help for readding |
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch
Outdated
Show resolved
Hide resolved
@Mic92 I simplified the patch |
CC @luigy. We should probably have a |
@svanderburg so I think the "android ndk packages" file I made you'll basically want to keep as-is. The point of it is to take the NDK stuff, however that is gotten, and chop it up into things that we can replace normal nixpkgs derivations with (gcc, bionic libc, etc). Maybe with your new finer-grained plugin approach, it will be easier to get just those bits rather than downloading more and then throwing array the rest, but most of the complicatedness in that file has to do with the fact that tools and library overrides belong in different bootstrapping stages, and that much remains the same. |
dcdcd38
to
ae557d5
Compare
I just rebased against the latest master. This resolves a conflict and allows me to use the modified autoPatchelf executable implemented in issue #50802 |
@Ericson2314 Thanks! I'll start investigating a reintegration approach of these package soon. The stdenv/cross environment is also broken because of the new packaging structure -- we now need to refer to the Android NDK (that is now bundled as a plugin with the Android SDK) in a different way. |
@Ericson2314 I did a preliminary investigation and there are some practical concerns for which I need to know your opinion. The I'm not sure if putting this file in Do you mind if I put this expression in The other problem is the Android NDK package -- the newest Android SDK also bundles the NDK as a plugin that you can install with the SDK manager. This is how I integrate the Android NDK in Nixpkgs. I noticed that Is it still desired to support older NDK versions? If so, then we must package these older NDK versions differently somehow, by using the XML files of older SDK versions. |
Firstly, it's fine to drop the other versions. I'd just ask that the code stay structured so that multiple SDK/NDK versions be supported in principle, so that once Google has more newstyle releases they can be simultaneously supported, but I assume you're doing that anyways :). I don't mind if you move this file, but I don't think the comparison to the language packages is quite correct. The Android packages here are not, like, Java apps or something, but regular packages using prebuilt binaries. In other words the packages aren't really Android specific, only the platform they are built for and their provenance is. Language packages OTOH are different packages, but built in as normal a Nix approach as possible. That's almost the opposite. I do appreciate trying to get it away from any autogenerated files, though, so move as you see fit. |
@Ericson2314 I now started investigating whether I can separate the androidndkPackages from androidenv (on the upstream master branch). The idea is that I first try to separate it and check whether the functionality still works (e.g. whether there are no regressions). If this succeeds, then I apply the patches that provide my new SDK implementation. Finally, I will fix the androidndk packages to work with the NDK bundled with the new SDK implementation (version 18b). Is there simple way to test how this cross compiling stuff works? I noticed that there is $ nix-build -A bionic The above command throws an assertion error. I probably need to supply a bunch of cross compiling parameters, but from the documentation it is not clear to me how I can, for example, build on my Is there simple testcase that I can run to make |
$ nix-build -A pkgsCross.aarch64-android-prebuilt.hello will build GNU hello with ndk's GCC and bionic. [I pinged you on IRC if you have any follow-up questions.] |
@Ericson2314 I just created a new branch (forked from the current Nixpkgs) in which I implemented the separation (svanderburg@13d6088). Your testcase seems to pass. What I basically did: I moved androidPkgs from androidenv to the top-level expression and moved all androidPkgs stuff to Next thing is trying to rebase my SDK changes on top of this change and fixing to make it work with the Android NDK 18b. |
Looks great! And btw, thank you for maintaining this. |
1a37262
to
1572b13
Compare
I just rebased again to include the android NDK pkgs separation. @Ericson2314 I have managed to partially fix the cross compilation, but I need some help from you. The example package that you provided me now seems to properly evaluate. However, when I run the build, but the configure script still fails to properly detect the compiler. Inspecting I have created a separate WIP branch (https://github.com/svanderburg/nixpkgs/tree/mobile-updates-wip) that contains my changes so far: svanderburg@63f235c I think quite a few things in the Android 18b NDK have changed compared to the latest previous version 17c. For example, symlinking to the cross compilation executables no longer seems to work because they are shell script that themselves are wrappers using relative paths. Moreover, since the newest Android SDK distribution only supports NDK 18b so far, and the older NDK versions are no longer supported, we can probably also remove the code that is specific to these older version, e.g. 17c, 10e, 8e. Can you have look at it? |
I wonder if |
5dd3e24
to
15299d8
Compare
44f2f4c
to
8122431
Compare
@Ericson2314 I think I have managed to make the fixes on my own. Apparently, what I learned is that libgcc.a is still required in a clang build if GNU Binutils are used for linking. I modified the bintools package in such a way that the required libgcc.a can be found. Another problem I ran into is that the After making these modifications I have successfully compiled GNU Hello for aarch64 on Android. Since I'm not using this stuff extensively, let me know if there is anything else that may require fixing. My changes are in revision 5142862 I think everything now is fixed and there are, as far as I can see, no breaking changes so I believe there is nothing preventing me from removing the WIP status of this pull request. |
Great job! And sorry I didn't get to it before. I am taking a look now. BTW since you are doing xcode stuff, you may also want to checkout out what we did for ios cross here: https://github.com/nixos/nixpkgs/blob/master/pkgs/os-specific/darwin/xcode/default.nix using https://github.com/nixos/nixpkgs/blob/master/pkgs/os-specific/darwin/ios-sdk-pkgs/default.nix for the cross packages. |
@@ -54,8 +56,15 @@ rec { | |||
mkdir -p $out/bin | |||
for prog in ${ndkBinDir}/${targetInfo.triple}-*; do | |||
prog_suffix=$(basename $prog | sed 's/${targetInfo.triple}-//') | |||
ln -s $prog $out/bin/${stdenv.targetPlatform.config}-$prog_suffix | |||
cat > $out/bin/${stdenv.targetPlatform.config}-$prog_suffix <<EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason you switched from a here-doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, symlinking does not work for the executables in Android NDK 18b. The executables we refer to are bash scripts that load executable from relative locations and have the expectation that they are loaded from the Android NDK directory. If we use symlinks, then it will look relative to the path of the symlinks, breaking the executable because these paths are invalid.
in | ||
runCommand "bionic-prebuilt" {} '' | ||
mkdir -p $out | ||
cp -r ${includePath} $out/include | ||
chmod u+w $out/include | ||
cp -r ${asmIncludePath}/* $out/include | ||
chmod +w $out/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This chmod now happens twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm is not needed. Basically I needed to restore write permissions first before I could copy the asm headers, but I didn't bother to change the original statement that restores write permissions
@Ericson2314 I just removed the redundant chmod instruction. I also removed the WIP status from this pull request. I will give people just a little while to provide their feedback. I think these changes can be integrated soon. We can always refine the infrastructure after we have integrated it if something appears to be missing. |
Since I have not received any further comments, I'm planning to integrate this PR tomorrow |
Hm. It looks like |
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/building-openwrt-with-nix-discuss-on-35c3/1777/2 |
I’m not sure if it is this PR that changed it, but it looks like Is this a bug, or is there some other recommended way of installing |
@svanderburg Did you ever tried the |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/using-androidenv-error-functionargs-requires-a-function/32773/5 |
Readding in #254082 |
Motivation for this change
Replaces the androidenv implementation by a new implementation that uses:
Furthermore, it updates other mobile build aspects:
Status:
Done:
Broken packages ported:
Still to do:
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)