stardust-enterprises / gradle-rust

A plugin for inter-compatibility with Rust inside Gradle projects.
https://stardust-enterprises.github.io/gradle-rust/
ISC License
27 stars 3 forks source link

issues with native compliation when lib type is set to cdylib #11

Closed hYdos closed 1 year ago

hYdos commented 1 year ago

So i've been modifying the example to build win64, linux64, mac64, and macArm64 and for some reason cargo is trying to link with cc which I dont have installed on my machine. I've never had the issue with cargo and was wondering if there is anything i can do in my buildscript to fix it image

My native subproject buildscript:

plugins {
    id("fr.stardustenterprises.rust.wrapper")
}

val nativeName = "test"

rust {
    release.set(true)
    command.set("cargo")
    cargoInstallTargets.set(true)

    targets {
        this += defaultTarget()

        create("linux64") {
            target = "x86_64-unknown-linux-gnu"
            outputName = "lib${nativeName}.so"
        }

        create("win64") {
            target = "x86_64-pc-windows-gnu"
            outputName = "${nativeName}.dll"
        }

        create("macOS-x86") {
            target = "x86_64-apple-darwin"
            outputName = "lib${nativeName}.dylib"

            command = "cargo"
            env += "CC" to "oa64-clang"
            env += "CXX" to "oa64-clang++"
        }

        create("macOS-aarch64") {
            target = "aarch64-apple-darwin"
            outputName = "lib${nativeName}.dylib"

            command = "cargo"
            env += "CC" to "oa64-clang"
            env += "CXX" to "oa64-clang++"
        }
    }
}
xtrm-en commented 1 year ago

This might just be a cargo quirk, can't this be changed via the .cargo/config.toml file? Does this happen without gradle-rust? I don't see any issue in your screenshot unfortunately.

hYdos commented 1 year ago

it doesnt happen without gradle-rust and i have the .cargo/config.toml

xtrm-en commented 1 year ago

To be honest I don't really see what could've caused this, the plugin basically just wraps the command execution in a pretty bundle, so the only thing I could think off is you having different defaults that somehow aren't passed through?

I haven't touched rustc in a hot minute, is there a way to debug log (both with and without gradle-rust) which linker (exact path) rustc is trying to use? (logs or screenshots at your convenience)

Also could you please show the error that you're getting when compiling with gradle-rust?

xtrm-en commented 1 year ago

Hey :wave:, any update on this issue?

hYdos commented 1 year ago

give me 2 seconds to setup a project to test this again

xtrm-en commented 1 year ago

Will reopen if updated :3