-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Runtime error with NDK stl #392
Comments
Do you see the same error when you build the apk and install the app using adb? |
Yes, just tried |
Hmm, yes, it looks like the standard libraries aren't being added correctly. I'll take a look. |
Okay, please let me know if there is a fix I can do locally. Thanks Alex |
Hi Alex, any update you can provide? |
Using git bisect I have found that the commit that broke it is a2e2cc2 |
Before that commit I also can't use std::future (which is a limitation on the standard STL used in the NDK). From my reading it seems we can add support if we use a different STL implementation (e.g. stlport), which we can do by creating our own toolchain with the android make-standalone-toolchain.sh script (provided by the NDK). Where does bazel determine which android ndk compiler to use? The CROSSTOOL file in tools/cpp has /bin/false for all tools in the armeabi-v7a toolchains. |
Is this going to be fixed before the upcoming release? This is blocking for us. |
The commits in a2e2cc2 added support for the different kinds of STL implementations available in the NDK, in addition to the different architectures, however STL support is still incomplete. I hope to get this solved very soon. |
So how do we specify which STL we want to use? |
The generated Android NDK crosstool needs to be updated to allow specifying the different STL implementations from the command line. If you look at /bazel-/external//BUILD, you'll see that all the default_toolchain entries are for libstdc++, and there needs to be an extra entry for each cpu for the other STL implementations. Then you can do, for example, --android_cpu=armeabi-v7a for the default STL implementation, or --android_cpu=armeabi-v7a-stlport to get stlport. I plan to get to that after fixing the runtime errors. |
So can you give an ETA on that? is there someway I can hard code the stl value? In about 2 days I'm going to have to start writing make files if there isn't a workaround. |
You can change the default CPUs here: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java#L169 |
There is a workaround in the sense that you can customize everything already. The big question is what needs to be changed. The android_ndk_repository rule is 'just' a convenience wrapper for new_local_repository that auto-generates a BUILD file to configure the NDK. If you previously ran a build, then bazel-clientname/external/androidndk/ actually contains the auto-generated BUILD file - it's pretty big at ~15k lines. In my client, this file actually contains a set of -stlport targets. However, IIUC, you can't just select the right one from the command line. And you can't edit the file in bazel-clientname because bazel will just overwrite it in the next run. However, I think you could copy the BUILD file and switch to new_local_repository, add a bind rule to map the target into external, change the cc_toolchain_suite to point at the -stlport targets, and that ought to work. I didn't try it myself, though. On the other hand, it shouldn't be too difficult to change the android_ndk_repository rule to generate an stlport cc_toolchain_suite target. What's a bit surprising is that there aren't stlport targets for all target architectures. I'm not sure if that's a shortcoming of the ndk or a bug in the repository rule. |
Or what Alex said. Pfff. Way too easy. |
Right, the generated crosstool for the NDK has the toolchain entry in the proto and the cc_toolchain rules for the other STL implementations, they just need default_toolchain entries in the proto so you can select it via --android_cpu=x86-stlport (for example). The runtime problems are just more important to fix at the moment. |
Alex found a workaround, but it's not very nice - he's adding a cc_library with the stdc++ .a file to the deps of the android_binary. |
Actually I was using libgnustl_static.a cc_library( The crosstool file defaults to gnu libstdc++. It's looking like this will take some more time to solve, so Indigo, in the meantime, can you see if this workaround works for you? |
I can't test that until the #415 issue is resolved. Also, should I be adding that cc_library to the android_binary as ulfjack suggests or should I be adding it to the my top-level cc_library (which is currently the only cc_library included by the android_binary)? |
The libgnustl_static should be added as a dep of the cc_library: android_binary -> cc_library -> cc_library |
Note that you should still be able to test this with plain bazel build and adb install |
Oh, good idea, I'll try that now. |
No luck. I run
then
It still fails trying to find |
I'm able to build and run the code below. Do you have an idea of what STL thing might be triggering the problem? I'm using string and sstream below.
and jni.cc is:
|
I have a fix, I think. |
The fix is not quite complete. It's not correct for the non-default toolchains, but it should at least get it to work with the default toolchains. |
We target build-tools 21.1.2.
I'm running |
But as I say in my post above, the error seems to be a file not found error. It is trying to find aapt in bin/external (doesn't seem right). |
ls -l /private/var/tmp/_bazel_root/8965add7011578a5d33385a234e6a985/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/aapt_binary: line 5: /private/var/tmp/_bazel_root/8965add7011578a5d33385a234e6a985/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/aapt_binary.runfiles//private/var/tmp/_bazel_root/8965add7011578a5d33385a234e6a985/Master/bazel-out/local_darwin-fastbuild/bin/external/androidsdk/build-tools/21.1.2/aapt ? And following the symlink? |
|
I guess you tried not What do you have in |
That path doesn't exist for me (i even tried the path given in the failure for bazel build). |
oh. Can you try to use bazel at head and remove your What does your WORKSPACE looks like? On Fri, Sep 4, 2015 at 6:38 PM Indigo Orton notifications@github.com
|
Ok, commented it out. Same error as above. My WORKSPACE now has:
|
Can you post a gist when doing a bazel build with '-s'? there's definitely several things that are wrong |
After clean this is what build -s gave:
|
Ok, I updated to ab4abc4 and tried to build the example hello_world... and it works! Even when I add in However, when I went back to my project and tried building it got the exact same issue as before. My build rules are practically the same. Posting below for comparison:
|
When I copy the bazel example directory (examples/android/java/bazel) to my workspace it fails with the same issue. So somehow my workspace is in a bad state. One that bazel clean doesn't fix. |
Try bazel shutdown if you haven't already. On Sat, Sep 5, 2015 at 4:40 AM, Indigo Orton notifications@github.com
|
Just tried, no luck. |
A colleague tried the same build in our workspace and it worked fine. Very odd, something about my environment then for this issue. About to try cloning into a clean area. |
Ok, very odd. When I cloned a new repo (my own repo, not bazel) the bazel example (I had copied in previously, see above) worked in it. However, when I ran a build on my android_binary target (shown above) I get the aapt error. Now whenever I run build on any android target the aapt error occurs. |
I created a gist containing the output of Gist here: https://gist.github.com/XperielIndigo/a564fb57fdaa4093e67a |
Looking at the path that is failing: it seems like the script is wanting to access an absolute path but instead is hitting a relative one ( |
Do you have a file here? /private/var/tmp/_bazel_root/373fe016a982fda7060b14fd6dde0b On Sat, Sep 5, 2015 at 10:39 PM, Indigo Orton notifications@github.com
|
I managed to get around the issue by changing For now I'm having another issue with documentation (see: #426). |
Thanks for your patience here Indigo. If things are compiling correctly for you I'll close this bug. Let us know if you're still having trouble. |
Hi all, So my fix ended up being two changes to 1> Line 60: 2> Line 140: Is there some nicer (read: not hard coded) fix that can be implemented in bazel master? |
What does your WORKSPACE file look like? |
I don't have any change about WORKSPACE! This is the original file: # Uncomment and update the paths in these entries to build the Android demo.
#android_sdk_repository(
# name = "androidsdk",
# api_level = 23,
# build_tools_version = "23.0.1",
# # Replace with path to Android SDK on your system
# path = "<PATH_TO_SDK>",
#)
#
#android_ndk_repository(
# name="androidndk",
# path="<PATH_TO_NDK>",
# api_level=21)
# Please add all new TensorFlow dependencies in workspace.bzl.
load("//tensorflow:workspace.bzl", "tf_workspace")
tf_workspace()
# TENSORBOARD_BOWER_AUTOGENERATED_BELOW_THIS_LINE_DO_NOT_EDIT
new_git_repository(
name = "d3",
build_file = "bower.BUILD",
remote = "https://github.com/mbostock-bower/d3-bower.git",
tag = "v3.5.15",
)
new_git_repository(
name = "dagre",
build_file = "bower.BUILD",
remote = "https://github.com/cpettitt/dagre.git",
tag = "v0.7.4",
)
new_git_repository(
name = "es6_promise",
build_file = "bower.BUILD",
remote = "https://github.com/components/es6-promise.git",
tag = "v2.1.0",
)
new_git_repository(
name = "font_roboto",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/font-roboto.git",
tag = "v1.0.1",
)
new_git_repository(
name = "graphlib",
build_file = "bower.BUILD",
remote = "https://github.com/cpettitt/graphlib.git",
tag = "v1.0.7",
)
new_git_repository(
name = "iron_a11y_keys_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-a11y-keys-behavior.git",
tag = "v1.1.1",
)
new_git_repository(
name = "iron_ajax",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-ajax.git",
tag = "v1.1.1",
)
new_git_repository(
name = "iron_autogrow_textarea",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-autogrow-textarea.git",
tag = "v1.0.12",
)
new_git_repository(
name = "iron_behaviors",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-behaviors.git",
tag = "v1.0.13",
)
new_git_repository(
name = "iron_checked_element_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-checked-element-behavior.git",
tag = "v1.0.4",
)
new_git_repository(
name = "iron_collapse",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-collapse.git",
tag = "v1.0.6",
)
new_git_repository(
name = "iron_dropdown",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-dropdown.git",
tag = "v1.2.0",
)
new_git_repository(
name = "iron_fit_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-fit-behavior.git",
tag = "v1.0.6",
)
new_git_repository(
name = "iron_flex_layout",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-flex-layout.git",
tag = "v1.3.1",
)
new_git_repository(
name = "iron_form_element_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-form-element-behavior.git",
tag = "v1.0.6",
)
new_git_repository(
name = "iron_icon",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-icon.git",
tag = "v1.0.8",
)
new_git_repository(
name = "iron_icons",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-icons.git",
tag = "v1.1.3",
)
new_git_repository(
name = "iron_iconset_svg",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-iconset-svg.git",
tag = "v1.0.9",
)
new_git_repository(
name = "iron_input",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-input.git",
tag = "1.0.8",
)
new_git_repository(
name = "iron_list",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-list.git",
tag = "v1.1.7",
)
new_git_repository(
name = "iron_menu_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-menu-behavior.git",
tag = "v1.1.4",
)
new_git_repository(
name = "iron_meta",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-meta.git",
tag = "v1.1.1",
)
new_git_repository(
name = "iron_overlay_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-overlay-behavior.git",
tag = "v1.4.2",
)
new_git_repository(
name = "iron_range_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-range-behavior.git",
tag = "v1.0.4",
)
new_git_repository(
name = "iron_resizable_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/iron-resizable-behavior.git",
tag = "v1.0.3",
)
new_git_repository(
name = "iron_selector",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-selector.git",
tag = "v1.2.4",
)
new_git_repository(
name = "iron_validatable_behavior",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/iron-validatable-behavior.git",
tag = "v1.0.5",
)
new_git_repository(
name = "lodash",
build_file = "bower.BUILD",
remote = "https://github.com/lodash/lodash.git",
tag = "3.10.1",
)
new_git_repository(
name = "neon_animation",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/neon-animation.git",
tag = "v1.1.1",
)
new_git_repository(
name = "paper_behaviors",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-behaviors.git",
tag = "v1.0.11",
)
new_git_repository(
name = "paper_button",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-button.git",
tag = "v1.0.11",
)
new_git_repository(
name = "paper_checkbox",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-checkbox.git",
tag = "v1.1.3",
)
new_git_repository(
name = "paper_dropdown_menu",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-dropdown-menu.git",
tag = "v1.1.3",
)
new_git_repository(
name = "paper_header_panel",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-header-panel.git",
tag = "v1.1.4",
)
new_git_repository(
name = "paper_icon_button",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-icon-button.git",
tag = "v1.0.6",
)
new_git_repository(
name = "paper_input",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-input.git",
tag = "v1.1.3",
)
new_git_repository(
name = "paper_item",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-item.git",
tag = "v1.1.4",
)
new_git_repository(
name = "paper_material",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/paper-material.git",
tag = "v1.0.6",
)
new_git_repository(
name = "paper_menu",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-menu.git",
tag = "v1.2.2",
)
new_git_repository(
name = "paper_menu_button",
build_file = "bower.BUILD",
remote = "https://github.com/polymerelements/paper-menu-button.git",
tag = "v1.0.4",
)
new_git_repository(
name = "paper_progress",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-progress.git",
tag = "v1.0.8",
)
new_git_repository(
name = "paper_radio_button",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-radio-button.git",
tag = "v1.1.1",
)
new_git_repository(
name = "paper_radio_group",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-radio-group.git",
tag = "v1.0.9",
)
new_git_repository(
name = "paper_ripple",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-ripple.git",
tag = "v1.0.5",
)
new_git_repository(
name = "paper_slider",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-slider.git",
tag = "v1.0.8",
)
new_git_repository(
name = "paper_styles",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-styles.git",
tag = "v1.1.1",
)
new_git_repository(
name = "paper_tabs",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-tabs.git",
tag = "v1.2.4",
)
new_git_repository(
name = "paper_toggle_button",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-toggle-button.git",
tag = "v1.0.12",
)
new_git_repository(
name = "paper_toolbar",
build_file = "bower.BUILD",
remote = "https://github.com/PolymerElements/paper-toolbar.git",
tag = "v1.1.2",
)
new_git_repository(
name = "plottable",
build_file = "bower.BUILD",
remote = "https://github.com/palantir/plottable.git",
tag = "v1.16.1",
)
new_git_repository(
name = "polymer",
build_file = "bower.BUILD",
remote = "https://github.com/Polymer/polymer.git",
tag = "v1.3.1",
)
new_git_repository(
name = "promise_polyfill",
build_file = "bower.BUILD",
remote = "https://github.com/polymerlabs/promise-polyfill.git",
tag = "v1.0.0",
)
new_git_repository(
name = "web_animations_js",
build_file = "bower.BUILD",
remote = "https://github.com/web-animations/web-animations-js.git",
tag = "2.1.4",
)
new_git_repository(
name = "webcomponentsjs",
build_file = "bower.BUILD",
remote = "https://github.com/Polymer/webcomponentsjs.git",
tag = "v0.7.21",
[)] |
It seem from the error "The first argument of load() is a path, not a label" that you're using an older version of bazel. Updating bazel might fix the issue. |
hello! ahumesky, My bazel is the latest for now ! |
@forfish FYI I made a minor edit to your comment to format the WORKSPACE file contents you pasted as code so that it will be easier for us to look at. |
Hi,
I've just updated to the latest commit (
8e5d60a9811f18e5c57132fd5d6eb1ccf448e7fd
), and now my C++ will compile but fail at runtime when runningmobile-install
. It fails withThat symbol represents
std::allocator<char>::allocator()
.When I remove usage of
std::string
from my C++ file it runs just fine.When I search this people seem to talk about setting
APP_STL
inApplication.mk
, what is the equivalent value for bazel?The text was updated successfully, but these errors were encountered: