Giter VIP home page Giter VIP logo

Comments (5)

Meziu avatar Meziu commented on July 17, 2024 1

The RUSTFLAGS invocation is there to link libctru against std I believe, there may be a problem with link order.

from cargo-3ds.

AzureMarker avatar AzureMarker commented on July 17, 2024 1

I just saw this too, which may help some things: rust-lang/rust#47384 (comment)

Possibly unrelated to this issue, but more useful for stuff like linker fix.

from cargo-3ds.

AzureMarker avatar AzureMarker commented on July 17, 2024

Yeah, you can test without it, but since std is linked near the end and introduces new symbol usages, those symbols need to get filled in by libctru again. The linker by default goes through its arguments linearly and throws away symbols that aren't needed at each stage.

from cargo-3ds.

Meziu avatar Meziu commented on July 17, 2024

Reopened as of #40. Seems like network related functions still won't link without using RUSTFLAGS.

from cargo-3ds.

ian-h-chamberlain avatar ian-h-chamberlain commented on July 17, 2024

I ran into a problem with this today, when linking ctrud via the build script from ctru-sys (but cargo-3ds still passes an explicit -lctru while building std), resulting in duplicate definitions between libctrud and libctru at link time.

I think part of the problem here is that -Zbuild-std builds the standard library with "plain" RUSTFLAGS, but Cargo might end up passing different flags to ctru-sys when it builds it (based on --release, [profile."*"] etc), resulting in different link flags between std and the final executable build.

From doing a bit of searching, perhaps we can somehow use the --as-needed flag rust-lang/rust#99424 ? (i.e. something like RUSTFLAGS="-Clink-arg=-Wl,--as-needed"). A little bit of testing hasn't gotten me far with it, but maybe there's some way to use it to solve this...

I am not sure of a general way to unify the linker flags (specifically -lctru[d]) between build-std and the downstream libraries, unless there is some magic rustc/cargo flag to say --link-but-only-if-nothing-else-did=ctru. Maybe something like https://doc.rust-lang.org/cargo/reference/unstable.html#profile-rustflags-option ?

Thus far I haven't found a relevant issue in https://github.com/rust-lang/wg-cargo-std-aware/ but that repo is rather large in scope so 🤷


If none of the above flags produce what we need, it's possible we could try to parse the cargo flags and figure out whether we should link ctrud or ctru (similar to https://github.com/rust3ds/ctru-rs/blob/a636722b4978d36531e5c9e2a866cdec3387877e/ctru-sys/build.rs#L27-L33 except we'd have to figure out the PROFILE based on the command invocation 😭) but this doesn't seem ideal.

from cargo-3ds.

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.