mcc,
@mcc@mastodon.social avatar

I have been for some time frustrated with a project which practically speaking must use .cargo/config.toml, a Rust "feature of last resort" that the Rust devs seem to almost be leaving intentionally poorly supported to disusade you from using it. Just now I found a way to solve a serious and fundamental problem .cargo/config.toml normally causes, and I'm split between feeling very satisfied and really annoyed because oh my god this solution is so ugly

https://github.com/mcclure/pocket-riscv-rs-bug/commit/a369e1f185c729056a5886ef608d8225854f0915

mcc,
@mcc@mastodon.social avatar

If you look at that patch and don't understand what's happening in it: That's a normal reaction

mcc,
@mcc@mastodon.social avatar

Now, this solution to the problem actually introduces another problem. But that second problem turns out to be fixable by using an "unstable" feature in Rust nightly. Unfortunately, the "unstable" feature in Rust nightly introduces a third problem. I will not be elaborating on this post.

mcc,
@mcc@mastodon.social avatar

UPDATE: So someone on Mastodon reads my posts here, looks at what I did, and says "why don't you just use [X]?". So I look in the docs, and realize [X] is indeed a far superior solution which is clean and does not introduce additional problems. So I try doing [X]. Long story short, it's now nearly half an hour later and after a series of tests I believe I've found a bug in the Rust compiler and I'm setting up to file a bug on Cargo

mcc,
@mcc@mastodon.social avatar

UPDATE 2: After spending an hour writing a complex bug cataloguing the apparent bug "When I move .config/cargo.toml to special-cargo.toml and specify it using --config, it always looks one level up outside the git project for the platform json, in fact, all file paths behave relative to the parent directory of the cargo.toml, always, even when they're specified with --config".

Then I find this in the docs.

What!!!
What!!!!!
Why would you do it this way!!! This is so weird and unfriendly!!!

val,
@val@oc.todon.fr avatar

@mcc I had to read this three times to see what is weird about it

mcc,
@mcc@mastodon.social avatar

@val yeah it means if i'm in my git project and i say --config filename.toml and that toml specifies a json it's going to be looking entirely outside my git repo just in outer space somewhere

mcc,
@mcc@mastodon.social avatar

This is the kind of thing I'd expect out of like, perl, or javascript. It screams "this is a bug from version 1.58 we can't remove because existing code relies on it continuing to work however it works". Which I guess probably means I'm not going to have any luck filing a feature request suggesting they change it :(

mcc,
@mcc@mastodon.social avatar

Thinking about this further, I guess the reason it works this way is so you can use --config to specify another project's .config/cargo.toml without changing the toml contents. I still hate it

mcc,
@mcc@mastodon.social avatar

So I am continuing to pick at the .cargo/config.toml project refactor like a scab, and…

…hm.

I think that might be the worst error message I've ever got from Rust.

The error is "error: could not compile minibreak (bin "minibreak") due to 2 previous errors". There are no other errors

tdelmas,
@tdelmas@mamot.fr avatar

@mcc on the next line? Or is it a consequence

mcc,
@mcc@mastodon.social avatar

I don't know.

nilstrieb,
@nilstrieb@hachyderm.io avatar

@mcc uhh, what the fuck? if you could create a reproduction that would be great

mcc,
@mcc@mastodon.social avatar

@nilstrieb I'm in the process of filing a bug on rust-embedded/cargo-binutils github. Does that help?

mcc,
@mcc@mastodon.social avatar
whitequark,
@whitequark@mastodon.social avatar

@mcc > litex

Well there's your problem

mcc,
@mcc@mastodon.social avatar

@whitequark i assure you litex is giving me more than one problem

rain,
@rain@hachyderm.io avatar

@mcc you can also pass in a toml string to --config these days btw

mcc,
@mcc@mastodon.social avatar

@rain It would be a very long toml string. I'd have to do like $( cat filename ) in the makefile, or something, and I'm trying not to have a complex makefile.

Chip_Unicorn,
@Chip_Unicorn@im-in.space avatar

@mcc
Congratulations on finding a bug in the Rust compiler!

mcc,
@mcc@mastodon.social avatar

@Chip_Unicorn I didn't! I found a poorly thought out feature! :(

leo,
@leo@60228.dev avatar

@mcc can't you do --config riscv-config.toml

mcc,
@mcc@mastodon.social avatar

@leo our config cargo.toml has six complex options in it, three of which are arrays. it also contains comments. this would mean a very complex invocation line if we moved to the --config options, which would mean a very complex makefile, and i'm already unhappy we're using a makefile (what if someday I want to build on Windows?).

In addition, the other dev made an attempt to switch to --config this morning, and came back with "it isn't working for some reason". I don't want to touch the crab

leo,
@leo@60228.dev avatar

@mcc --config can take a path (or if you want to be unambiguous you can do --config 'include = "riscv-config.toml"')

mcc,
@mcc@mastodon.social avatar

@leo …oh god, really?

reads documentation more clearly

okay yeah really. i wish i'd known this weeks ago :(

congrats, the rust discord was not able to come up with this when asked :(

mcc,
@mcc@mastodon.social avatar

@leo Okay, can you help me with this?

Say I try to build this exact branch https://github.com/mcclure/pocket-riscv-rs-bug/tree/z_experimental_minibreak-agg-cargo-toml-2
instructions in run.txt

Via a makefile, I run cargo with --config riscv32imafdc-cargo-config.toml
Which contains [build] target = "riscv32imafdc-unknown-none-elf.json"

That's a file in the current directory.

But Cargo looks for it in the PARENT directory.

Why?

leo,
@leo@60228.dev avatar

@mcc it looks relative to the cargo cwd, I wonder if that's getting changed for some reason before it gets read? you could work around this by doing $PWD/riscv32imafdc-cargo-config.toml ig, probably worth reporting as a bug though....?

mcc,
@mcc@mastodon.social avatar

@leo Thanks

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • kavyap
  • thenastyranch
  • tester
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • tacticalgear
  • Youngstown
  • ethstaker
  • osvaldo12
  • slotface
  • everett
  • rosin
  • khanakhh
  • megavids
  • ngwrru68w68
  • Leos
  • modclub
  • cubers
  • cisconetworking
  • Durango
  • InstantRegret
  • GTA5RPClips
  • provamag3
  • normalnudes
  • anitta
  • JUstTest
  • lostlight
  • All magazines