Skip to content

Android: dx serve --android fails with "Failed to encode RUSTFLAGS" when NDK/linker path contains a space #5835

Description

@devcompil

Problem
dx serve --android fails before cargo runs:

Build failed: Failed to encode RUSTFLAGS

1: flag in rustflags must not contain its separator (' ')

Cause
The Android rustflags for clang_rt.builtins are built as a single string:

format!(
            "-L{} -lstatic=clang_rt.builtins-{}-android",
            clang_builtins_target.join("lib").join("linux").display(),
            rt_builtins(&triple)
)

Fichier : packages/cli/src/build/android.rs
Fonction : BuildRequest::android_env_vars()

That string always contains a space (two flags concatenated). If the NDK path itself also has a space (Android SDK, username with space, etc.), cargo-config2 encode_space_separated rejects it.

Expected
Split into two flags and encode with CARGO_ENCODED_RUSTFLAGS (\x1f), which allows spaces in paths.

Reproduction
NDK path with a space

dx compilation error

$ dx serve android
...
[dev] Build failed: Failed to encode RUSTFLAGS
       1: flag in rustflags must not contain its separator (' ')

Workaround
Symlink the SDK/NDK to a path without spaces (/opt/android/sdk).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions