sailfishos / rust

3 stars 6 forks source link

Let Cargo obey the SB2_TARGET variable #14

Closed rubdos closed 2 years ago

rubdos commented 3 years ago

cargo should also know about the SB2_RUST_TARGET_TRIPLE variable, because cargo can conditionally add or remove dependencies based on target information. For example, polyval and other cryptographic crates like sha-1 and sha2 have statements like this:

[target."cfg(any(target_arch = \"aarch64\", target_arch = \"x86_64\", target_arch = \"x86\"))".dependencies.cpufeatures]
version = "0.2"

This can lead to very strange errors, because a dependency that is stated in Cargo.toml does not get injected in the build process.

error[E0433]: failed to resolve: use of undeclared crate or module `cpufeatures`
  --> /home/rsmet/.cargo/registry/src/github.com-1285ae84e5963aae/polyval-0.5.3/src/backend/autodetect.rs:18:1
   |
18 | cpufeatures::new!(mul_intrinsics, "pclmulqdq", "sse4.1");
   | ^^^^^^^^^^^ use of undeclared crate or module `cpufeatures`

This is a blocker for Whisperfish to be build with the SailfishOS SDK, especially now that Rust 1.52 is available!

I don't know to what extend this should be a real format-patch/e-mail style patch for Jolla to accept this here, let me know if I should clean that up a little.

PS., I had a 1.51 branch laying around, seems like you folks had to duplicate my efforts. Sorry for not notifying you!

rubdos commented 2 years ago

@xfade / @lbt , any chance this could get some love? This is literally the only thing that withholds Whisperfish from building with Jolla's Rust.

vigejolla commented 2 years ago

@rainemak opinion?

rainemak commented 2 years ago

This should be smoke tested with Sailfish core (i.e. rust + xulrunner-qt5).

Thaodan commented 2 years ago

Can you create the patch properly similar to the other patches? E.g. author, sign of, subject and description?

rubdos commented 2 years ago

Done. Would you like me to squash them together?

Also, when you guys run git format-patch, on what repository do you do that? I had to manually fiddle a bit with the paths, but that feels very dirty. I'm not very used to the format-patch stuff :-)

Thaodan commented 2 years ago

Done. Would you like me to squash them together? Yes please.

Also, when you guys run git format-patch, on what repository do you do that? I had to manually fiddle a bit with the paths, but that feels very dirty. I'm not very used to the format-patch stuff :-)

You can ether use the submodule or a separate git repository. I usually use a separate git repository, branch of the upstream version and apply our patches on top and then create the patch files like this:

git format-patch --no-numbered --zero-commit --full-index --no-signature --output-directory=$pkgdir/rpm

All those options reduce the noise when creating patch files to a minimum when we rebase them.

rubdos commented 2 years ago

Kind reminder :-)

If there's anything left that I should fix, please do let me know!

Tomin1 commented 2 years ago

This should be smoke tested with Sailfish core (i.e. rust + xulrunner-qt5).

It seems this does not cause any new issues with those, so it should be fine.