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

note: ld: error: unable to find library -lgcc #75

Closed
sonwh98 opened this issue Nov 8, 2021 · 19 comments
Closed

note: ld: error: unable to find library -lgcc #75

sonwh98 opened this issue Nov 8, 2021 · 19 comments

Comments

@sonwh98
Copy link

sonwh98 commented Nov 8, 2021

I am just trying to get a simple hello world to compile with gradle. there's no linking with java

but running

gradle cargoBuild

results in note: ld: error: unable to find library -lgcc

Cargo.toml

[package]                                                                                                                                                                                                          
name = "hello-rust"                                                                                                                                                                                                
version = "0.1.0"                                                                                                                                                                                                  
edition = "2021"                                                                                                                                                                                                                                                                                                                                                        

app/build.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 30
    ndkVersion = "23.1.7779620"
    defaultConfig {
        applicationId "world.datom.gossipy"
        minSdk 30
        targetSdk 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
cargo {
    module  = "/home/sto/workspace/gossipy/app/src/main/rust"       // Or whatever directory contains your Cargo.toml
    //module  = "rust"       // Or whatever directory contains your Cargo.toml
    libname = "hello-rust"          // Or whatever matches Cargo.toml's [package] name.
    //targets = ["arm", "x86"]
    targets = ["arm"]
    //targets = ["x86"]  // See bellow for a longer list of options
    prebuiltToolchains = true
}

dependencies {
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'org.greenrobot:eventbus:3.2.0'
    implementation 'com.mapbox.maps:android:10.0.0'
    implementation 'com.cognitect:transit-java:1.0.343'
    implementation("com.android.volley:volley:1.2.1")

}

My output-bin-hello-rust

{"message":"linking with `/home/sto/workspace/gossipy/build/linker-wrapper/linker-wrapper.sh` failed: exit status: 1","code":null,"level":"error","spans":[],"children":[{"message":"\"/home/sto/workspace/gossipy/build/linker-wrapper/linker-wrapper.sh\" \"-Wl,--allow-multiple-definition\" \"-march=armv7-a\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.1bwfdeuvu8a9k9aq.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2lq2loeqyv4sqlcx.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.36ihj3hc249f8dep.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.3v6jphhmynuc2c0g.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.4avtxjcjs6fdxwow.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.53uv1bqi2rkqxtpm.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.583vd311drys3jy0.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.g7x0m4cw2efep5y.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.kj3bul5o16w4s9m.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.o12osxe1lsshpau.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2pqxinfcvyef71zg.rcgu.o\" \"-Wl,--as-needed\" \"-L\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps\" \"-L\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/debug/deps\" \"-L\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib\" \"-Wl,--start-group\" \"-Wl,-Bstatic\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd-d5d15712b0d47922.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libpanic_unwind-e72bbab6178a0884.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libminiz_oxide-2e4db270d24f62b9.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libadler-3ae2550096f18bc8.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libobject-a839db316dbe86c2.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libmemchr-e17e5f04154177aa.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libaddr2line-8f04a5f6df91d7a2.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libgimli-1dcf71ed9052de88.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd_detect-300e0154326ff076.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_demangle-5e30874379f66265.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libhashbrown-f0d820e1ad87c37b.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_alloc-da29c2594fa8a6eb.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libunwind-15a2b681778bc685.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcfg_if-22057ec6a5d83031.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liblibc-e8521973bf4ef813.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liballoc-711bd3a1f87159d1.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_core-7bd985023a710cc9.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcore-bfbb3a1d0067c43a.rlib\" \"-Wl,--end-group\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-0fc41c80f57d6aac.rlib\" \"-Wl,-Bdynamic\" \"-ldl\" \"-llog\" \"-lgcc\" \"-lc\" \"-lm\" \"-Wl,--eh-frame-hdr\" \"-Wl,-znoexecstack\" \"-L\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib\" \"-o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3\" \"-Wl,--gc-sections\" \"-pie\" \"-Wl,-zrelro\" \"-Wl,-znow\" \"-nodefaultlibs\"","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"ld: error: unable to find library -lgcc\nclang-12: error: linker command failed with exit code 1 (use -v to see invocation)\n/home/sto/android/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi30-clang -Wl,-soname,libhello-rust.so -Wl,--allow-multiple-definition -march=armv7-a /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.1bwfdeuvu8a9k9aq.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2lq2loeqyv4sqlcx.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.36ihj3hc249f8dep.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.3v6jphhmynuc2c0g.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.4avtxjcjs6fdxwow.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.53uv1bqi2rkqxtpm.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.583vd311drys3jy0.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.g7x0m4cw2efep5y.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.kj3bul5o16w4s9m.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.o12osxe1lsshpau.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2pqxinfcvyef71zg.rcgu.o -Wl,--as-needed -L /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps -L /home/sto/workspace/gossipy/app/src/main/rust/target/debug/deps -L /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib -Wl,--start-group -Wl,-Bstatic /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd-d5d15712b0d47922.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libpanic_unwind-e72bbab6178a0884.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libminiz_oxide-2e4db270d24f62b9.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libadler-3ae2550096f18bc8.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libobject-a839db316dbe86c2.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libmemchr-e17e5f04154177aa.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libaddr2line-8f04a5f6df91d7a2.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libgimli-1dcf71ed9052de88.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd_detect-300e0154326ff076.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_demangle-5e30874379f66265.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libhashbrown-f0d820e1ad87c37b.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_alloc-da29c2594fa8a6eb.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libunwind-15a2b681778bc685.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcfg_if-22057ec6a5d83031.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liblibc-e8521973bf4ef813.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liballoc-711bd3a1f87159d1.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_core-7bd985023a710cc9.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcore-bfbb3a1d0067c43a.rlib -Wl,--end-group /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-0fc41c80f57d6aac.rlib -Wl,-Bdynamic -ldl -llog -lgcc -lc -lm -Wl,--eh-frame-hdr -Wl,-znoexecstack -L /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib -o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3 -Wl,--gc-sections -pie -Wl,-zrelro -Wl,-znow -nodefaultlibs\n","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: linking with `/home/sto/workspace/gossipy/build/linker-wrapper/linker-wrapper.sh` failed: exit status: 1\u001b[0m\n\u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: \"/home/sto/workspace/gossipy/build/linker-wrapper/linker-wrapper.sh\" \"-Wl,--allow-multiple-definition\" \"-march=armv7-a\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.1bwfdeuvu8a9k9aq.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2lq2loeqyv4sqlcx.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.36ihj3hc249f8dep.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.3v6jphhmynuc2c0g.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.4avtxjcjs6fdxwow.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.53uv1bqi2rkqxtpm.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.583vd311drys3jy0.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.g7x0m4cw2efep5y.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.kj3bul5o16w4s9m.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.o12osxe1lsshpau.rcgu.o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2pqxinfcvyef71zg.rcgu.o\" \"-Wl,--as-needed\" \"-L\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps\" \"-L\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/debug/deps\" \"-L\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib\" \"-Wl,--start-group\" \"-Wl,-Bstatic\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd-d5d15712b0d47922.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libpanic_unwind-e72bbab6178a0884.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libminiz_oxide-2e4db270d24f62b9.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libadler-3ae2550096f18bc8.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libobject-a839db316dbe86c2.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libmemchr-e17e5f04154177aa.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libaddr2line-8f04a5f6df91d7a2.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libgimli-1dcf71ed9052de88.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd_detect-300e0154326ff076.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_demangle-5e30874379f66265.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libhashbrown-f0d820e1ad87c37b.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_alloc-da29c2594fa8a6eb.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libunwind-15a2b681778bc685.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcfg_if-22057ec6a5d83031.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liblibc-e8521973bf4ef813.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liballoc-711bd3a1f87159d1.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_core-7bd985023a710cc9.rlib\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcore-bfbb3a1d0067c43a.rlib\" \"-Wl,--end-group\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-0fc41c80f57d6aac.rlib\" \"-Wl,-Bdynamic\" \"-ldl\" \"-llog\" \"-lgcc\" \"-lc\" \"-lm\" \"-Wl,--eh-frame-hdr\" \"-Wl,-znoexecstack\" \"-L\" \"/home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib\" \"-o\" \"/home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3\" \"-Wl,--gc-sections\" \"-pie\" \"-Wl,-zrelro\" \"-Wl,-znow\" \"-nodefaultlibs\"\u001b[0m\n\u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: ld: error: unable to find library -lgcc\u001b[0m\n\u001b[0m          clang-12: error: linker command failed with exit code 1 (use -v to see invocation)\u001b[0m\n\u001b[0m          /home/sto/android/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi30-clang -Wl,-soname,libhello-rust.so -Wl,--allow-multiple-definition -march=armv7-a /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.1bwfdeuvu8a9k9aq.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2lq2loeqyv4sqlcx.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.36ihj3hc249f8dep.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.3v6jphhmynuc2c0g.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.4avtxjcjs6fdxwow.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.53uv1bqi2rkqxtpm.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.583vd311drys3jy0.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.g7x0m4cw2efep5y.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.kj3bul5o16w4s9m.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.o12osxe1lsshpau.rcgu.o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3.2pqxinfcvyef71zg.rcgu.o -Wl,--as-needed -L /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps -L /home/sto/workspace/gossipy/app/src/main/rust/target/debug/deps -L /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib -Wl,--start-group -Wl,-Bstatic /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd-d5d15712b0d47922.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libpanic_unwind-e72bbab6178a0884.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libminiz_oxide-2e4db270d24f62b9.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libadler-3ae2550096f18bc8.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libobject-a839db316dbe86c2.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libmemchr-e17e5f04154177aa.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libaddr2line-8f04a5f6df91d7a2.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libgimli-1dcf71ed9052de88.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libstd_detect-300e0154326ff076.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_demangle-5e30874379f66265.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libhashbrown-f0d820e1ad87c37b.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_alloc-da29c2594fa8a6eb.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libunwind-15a2b681778bc685.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcfg_if-22057ec6a5d83031.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liblibc-e8521973bf4ef813.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/liballoc-711bd3a1f87159d1.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/librustc_std_workspace_core-7bd985023a710cc9.rlib /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcore-bfbb3a1d0067c43a.rlib -Wl,--end-group /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-0fc41c80f57d6aac.rlib -Wl,-Bdynamic -ldl -llog -lgcc -lc -lm -Wl,--eh-frame-hdr -Wl,-znoexecstack -L /home/sto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib -o /home/sto/workspace/gossipy/app/src/main/rust/target/armv7-linux-androideabi/debug/deps/hello_rust-556aaa043ec277a3 -Wl,--gc-sections -pie -Wl,-zrelro -Wl,-znow -nodefaultlibs\u001b[0m\n\u001b[0m          \u001b[0m\n\n"}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m\n\n"}
@sonwh98
Copy link
Author

sonwh98 commented Nov 8, 2021

it seems it was fixed with this PR rust-lang/rust#85806

however, it doesn't seem to work for me. I'm running

rustc 1.56.1 (59eed8a2a 2021-11-01)

@ncalexan
Copy link
Member

ncalexan commented Nov 8, 2021

@sonwh98 thanks for the report. I'm sorry that I haven't much to advise: it looks like you're running into a Rust-specific issue with the very modern NDK version you're trying to use, and not something to do with rust-android-gradle. If your project does compile fine without the plugin, you could try to narrow down the exact cargo commands failing and how rust-android-gradle is impacting the cargo environment.

If you do get to the bottom of this, please let us know what's going on in this ticket!

@sonwh98
Copy link
Author

sonwh98 commented Nov 9, 2021

@ncalexan I think there maybe a problem with calling the script make_standalone_toolchain.py

This script is obsolete according to this document.
https://developer.android.com/ndk/guides/standalone_toolchain

@ncalexan
Copy link
Member

ncalexan commented Nov 9, 2021

@ncalexan I think there maybe a problem with calling the script make_standalone_toolchain.py

This script is obsolete according to this document. https://developer.android.com/ndk/guides/standalone_toolchain

Indeed. And I see that the pre-built toolchains are not yet default: https://github.com/mozilla/rust-android-gradle#prebuilttoolchains. Could you try with the pre-built toolchains and see if this is still an issue? We might mutate this ticket to be "make pre-built the default".

@sonwh98
Copy link
Author

sonwh98 commented Nov 9, 2021

@ncalexan actually make_standalone_toolchain.py is never called. The problem is NDK 23.1.7779620 has stop distributing libgcc . I got around this by hacking linker-wrapper.py to statically linking libgcc.a from NDK 22.1.7171670

args.remove("-lgcc")
args.append("/home/sto/android/ndk/22.1.7171670/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/libgcc.a")

published this plugin locally with
gradle publishToMavenLocal

then rebuild my project with
gradle cargoBuild

then tested it with

sto@big:~/workspace/gossipy$ adb push ./app/src/main/rust/target/armv7-linux-androideabi/debug/hello-rust /data/local/tmp
./app/src/main/rust/target/armv7-linux-androideabi/debug/hello-rust: 1 file pushed, 0 skipped. 250.7 MB/s (3264536 bytes in 0.012s)
sto@big:~/workspace/gossipy$ adb shell /data/local/tmp/hello-rust
Hello, rust world!

is there a better way to do this? the plugin should have a way of including static libraries

there should also be an option to change the linker-wrapper.py to not link -lgcc and use static version instead

@ncalexan
Copy link
Member

ncalexan commented Nov 9, 2021

linker-wrapper.py just passes through the arguments its given. So it's the cargo invocation that needs to be fixed: that's what determines those arguments.

It's not a good idea to allow monkeying with those arguments (any more than we do in linker-wrapper.py, I guess). Again, you need to track down where the mismatches are here and fix them at the Rust layer. This isn't a rust-android-gradle issue (AFAICT).

@sonwh98
Copy link
Author

sonwh98 commented Nov 9, 2021

This isn't a rust-android-gradle issue (AFAICT)

@ncalexan
rustc is invoked with this param

-C linker=/home/sto/workspace/gossipy/build/linker-wrapper/linker-wrapper.sh

linker-wrapper.py is called from linker-wrapper.sh . Is there a way the plugin allows me to over ride -C linker with my own custom shell script?

@ncalexan
Copy link
Member

ncalexan commented Nov 9, 2021

No, I don't think we have a method to change the linker wrapper. In fact, we'd like to remove it: see #49, IIRC.

Again: don't solve this by monkeying with these plugin details. Fix the problem at the right level, which is teaching cargo and the NDK toolchain and the specific packages you're using (backtrace, it looks like) to know what the right libraries.

@sonwh98
Copy link
Author

sonwh98 commented Nov 9, 2021

I am new to Rust and Cargo. Can you give some guidance?

It seems libgcc is a required dependency and its linked as a shared library but since the latest NDK has stop distributing libgcc linking it as a shared library will fail. libgcc.a from an previous version of NDK should be used to statically link to satisfy rust dependency.

The logic is
if NDK version "23.1.7779620" is used, statically link libgcc

Or remove libgcc as a dependency in Rust. Why is Rust dependent on gcc? it can't be built using LLVM?

@ncalexan
Copy link
Member

ncalexan commented Nov 9, 2021

This could be challenging to address. If you look at the Rust patch, it's actually patching one of the build scripts: rust-lang/rust@965997b. The first thing to do is to dig into the build failures you're seeing and figure out which build scripts is injecting the -lgcc argument. It's that dependency (or possibly those dependencies) that need to be bumped.

Can you share the underlying Rust project? I may be able to help you track down what's asking for libgcc. As to why... it's because libgcc implements stack unwinding in a general way. IIRC, clang uses it itself, but don't quote me on that.

@sonwh98
Copy link
Author

sonwh98 commented Nov 10, 2021

@ncalexan https://github.com/sonwh98/gossipy/tree/master/app/src/main/rust

its just a simple hello world just to test

thanks for any help!

@ncalexan
Copy link
Member

@ncalexan https://github.com/sonwh98/gossipy/tree/master/app/src/main/rust

its just a simple hello world just to test

Yeah, no dependencies at all! Isn't the question then: why not use an NDK that Rust supports? Can you set ndkVersion = "22.1.7171670" and simplify your life?

@sonwh98
Copy link
Author

sonwh98 commented Nov 10, 2021

yes its possible. I am just experimenting . I have a solution by hacking the python script if i need to use the latest NDK. However, Rust should work with the latest NDK. Rust is an official supported language for developing android right?

@ncalexan
Copy link
Member

yes its possible. I am just experimenting . I have a solution by hacking the python script if i need to use the latest NDK. However, Rust should work with the latest NDK. Rust is an official supported language for developing android right?

What does that even mean? Google (or AOSP) gives no support for building Android applications that I am aware of. Rust does support targeting Android, but the android-* platforms are Tier 2: https://doc.rust-lang.org/nightly/rustc/platform-support.html.

You're at the bleeding edge and bleeding. I suggest you move back from the edge. In any case, there is no indication that this is a rust-android-gradle issue.

@sonwh98
Copy link
Author

sonwh98 commented Nov 10, 2021

What does that even mean? Google (or AOSP) gives no support for building Android applications that I am aware of

https://source.android.com/setup/build/rust/building-rust-modules/overview

@ncalexan
Copy link
Member

What does that even mean? Google (or AOSP) gives no support for building Android applications that I am aware of

https://source.android.com/setup/build/rust/building-rust-modules/overview

TIL! All very new, and very cool.

@mercurydaihui
Copy link

@ncalexan can this plugin support modern NDK version (e.g. 23r version)?

@sonwh98
Copy link
Author

sonwh98 commented Nov 16, 2021

@mercurydaihui no. the most recently supported NDK is 22.1.7171670

with NDK 23 and greater, libgcc has to be statically linked because libgcc has been removed from NDK 23.

if you must use NDK 23+, see my work around by hacking the python script #75 (comment) . Its not recommended but it worked for me

@ncalexan
Copy link
Member

@ncalexan can this plugin support modern NDK version (e.g. 23r version)?

Following up to what @sonwh98 said -- thanks, Sonny! -- there's nothing specific to the plugin in the NDK 23 failures you are seeing. Once Rust works with NDK 23, the plugin should work too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants