Code Monkey home page Code Monkey logo

Comments (4)

UebelAndre avatar UebelAndre commented on August 10, 2024

@timpeut @juliexxia Do you know if this is the correct place to ask this question?

from rules_android.

katre avatar katre commented on August 10, 2024

How are you invoking the build? What's your bazel command line?

This is probably an incompatibility between Android rules (which are not currently using toolchain resolution) and the Rust rules (which do use toolchain resolution). We are working on the former (see bazelbuild/bazel#11749). There should be a way to have your build work currently, by adding the extra flags needed, but I will need a little more information to help figure it out.

from rules_android.

UebelAndre avatar UebelAndre commented on August 10, 2024

@katre Hi! Thank you so much for the reply!

I've put together a small workspace to reproduce the issue. Simply running bazel build //... should generate the error above.

In case it helps, the .bazelrc file I use only contains

common --experimental_google_legacy_api

repro.zip

├── BUILD.bazel
├── WORKSPACE
├── android
│   ├── BUILD.bazel
│   ├── proguard-rules.pro
│   └── src
│       └── main
│           ├── AndroidManifest.xml
│           ├── LibraryManifest.xml
│           ├── java
│           │   └── io
│           │       └── uebel
│           │           └── example
│           │               └── MainActivity.java
│           └── res
│               ├── drawable
│               │   └── ic_launcher_background.xml
│               ├── drawable-v24
│               │   └── ic_launcher_foreground.xml
│               ├── layout
│               │   └── activity_main.xml
│               ├── mipmap-anydpi-v26
│               │   ├── ic_launcher.xml
│               │   └── ic_launcher_round.xml
│               ├── mipmap-hdpi
│               │   ├── ic_launcher.png
│               │   └── ic_launcher_round.png
│               ├── mipmap-mdpi
│               │   ├── ic_launcher.png
│               │   └── ic_launcher_round.png
│               ├── mipmap-xhdpi
│               │   ├── ic_launcher.png
│               │   └── ic_launcher_round.png
│               ├── mipmap-xxhdpi
│               │   ├── ic_launcher.png
│               │   └── ic_launcher_round.png
│               ├── mipmap-xxxhdpi
│               │   ├── ic_launcher.png
│               │   └── ic_launcher_round.png
│               └── values
│                   ├── colors.xml
│                   ├── strings.xml
│                   └── styles.xml
└── rust
    ├── BUILD.bazel
    ├── Cargo.lock
    ├── Cargo.toml
    ├── raze
    │   ├── BUILD.bazel
    │   ├── crates.bzl
    │   └── remote
    │       ├── BUILD.bazel
    │       ├── addr2line-0.13.0.BUILD.bazel
    │       ├── adler-0.2.3.BUILD.bazel
    │       ├── ansi_term-0.11.0.BUILD.bazel
    │       ├── atty-0.2.14.BUILD.bazel
    │       ├── backtrace-0.3.50.BUILD.bazel
    │       ├── bitflags-1.2.1.BUILD.bazel
    │       ├── bytes-0.5.6.BUILD.bazel
    │       ├── cesu8-1.1.0.BUILD.bazel
    │       ├── cfg-if-0.1.10.BUILD.bazel
    │       ├── clap-2.33.1.BUILD.bazel
    │       ├── combine-4.2.1.BUILD.bazel
    │       ├── error-chain-0.10.0.BUILD.bazel
    │       ├── error-chain-0.12.3.BUILD.bazel
    │       ├── ferris-says-0.2.0.BUILD.bazel
    │       ├── gimli-0.22.0.BUILD.bazel
    │       ├── hermit-abi-0.1.15.BUILD.bazel
    │       ├── jni-0.17.0.BUILD.bazel
    │       ├── jni-sys-0.3.0.BUILD.bazel
    │       ├── libc-0.2.74.BUILD.bazel
    │       ├── log-0.4.11.BUILD.bazel
    │       ├── memchr-2.3.3.BUILD.bazel
    │       ├── miniz_oxide-0.4.0.BUILD.bazel
    │       ├── object-0.20.0.BUILD.bazel
    │       ├── rustc-demangle-0.1.16.BUILD.bazel
    │       ├── same-file-1.0.6.BUILD.bazel
    │       ├── smallvec-0.4.5.BUILD.bazel
    │       ├── strsim-0.8.0.BUILD.bazel
    │       ├── textwrap-0.11.0.BUILD.bazel
    │       ├── unicode-width-0.1.8.BUILD.bazel
    │       ├── vec_map-0.8.2.BUILD.bazel
    │       ├── version_check-0.9.2.BUILD.bazel
    │       ├── walkdir-2.3.1.BUILD.bazel
    │       ├── winapi-0.3.9.BUILD.bazel
    │       ├── winapi-i686-pc-windows-gnu-0.4.0.BUILD.bazel
    │       ├── winapi-util-0.1.5.BUILD.bazel
    │       └── winapi-x86_64-pc-windows-gnu-0.4.0.BUILD.bazel
    └── src
        └── lib.rs

22 directories, 68 files

from rules_android.

katre avatar katre commented on August 10, 2024

Thanks for the test case. This has existed since at least Bazel 3.2.0, and possibly earlier.

The problem is that the Android binary is changing the configuration to use the c compiler from the NDK (which makes sense), but the rust rules are trying to access that using the legacy system and an invalid --cpu flag (with the deafult value, k8).

I'm not entirely sure where this is happening: it could be rules_rust, rules_android, or Bazel itself. We're in the process of migrating the Android rules to use toolchain resolution, which will also unblock using toolchain resolution for C++ code: this should make this much simpler because each set of rules will be using the same configuration settings to tell what platform to build for.

I'm going to keep poking and see if there's an easy way to get your build working without waiting for those efforts to finish. You might also consider asking on the mailing lists if anyone else is using an Android binary with another set of rules to build binary code: rules_rust, rules_go, and several others are all very similar and a fix for one might work for you, even if it's not specifically for rust.

from rules_android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.