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

CI: use MSYS2 cargo package for example project #194

Merged
merged 1 commit into from
Jan 9, 2022

Conversation

mgeier
Copy link
Contributor

@mgeier mgeier commented May 20, 2021

I recently found out that there is a Rust package for MSYS2 (https://packages.msys2.org/base/mingw-w64-rust), and there is even a package for cargo-c (https://packages.msys2.org/base/mingw-w64-cargo-c)!

I tried to use the Rust package on CI, but still compile the latest version of cargo-c on the fly.

Sadly, there are a few problems ...

Currently, there is a build error during cargo cinstall, any ideas how to fix this?

After that, there might still be a problem with the library not being installed into the default location normally used for MSYS2, but for now that's blocked by the compilation error.

There seems to be another error in the Windows build (the one without MSYS2), which should also be solved, but it isn't really related to this PR.

@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2021

Codecov Report

Merging #194 (749ac88) into master (b84d67a) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #194   +/-   ##
=======================================
  Coverage   84.70%   84.70%           
=======================================
  Files          12       12           
  Lines        1811     1811           
=======================================
  Hits         1534     1534           
  Misses        277      277           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b84d67a...749ac88. Read the comment docs.

@mgeier
Copy link
Contributor Author

mgeier commented Jul 31, 2021

I've just re-based this PR and the error still occurs:

     Running `rustc --crate-name libc 'C:\Users\runneradmin\.cargo\registry\src\github.yoyoweb123.workers.dev-1ecc6299db9ec823\libc-0.2.98\src\lib.rs' --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -Cpanic=abort --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=484b93cfa35492db -C extra-filename=-484b93cfa35492db --out-dir 'D:\a\cargo-c\cargo-c\example-project\target\x86_64-pc-windows-msvc\release\deps' --target x86_64-pc-windows-msvc -L 'dependency=D:\a\cargo-c\cargo-c\example-project\target\x86_64-pc-windows-msvc\release\deps' -L 'dependency=D:\a\cargo-c\cargo-c\example-project\target\release\deps' --cap-lints allow --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor`
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-pc-windows-msvc` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `libc`

@mgeier mgeier force-pushed the msys2-cargo branch 2 times, most recently from f9c026c to 702c3a3 Compare January 9, 2022 16:41
@mgeier mgeier marked this pull request as ready for review January 9, 2022 17:59
@mgeier
Copy link
Contributor Author

mgeier commented Jan 9, 2022

I finally managed to make this work!

I had to manually specify --target and --prefix, which isn't very nice IMHO.
This shouldn't be a blocker for merging this PR, but in the future it would be nice if we could avoid those.

# NB: --prefix doesn't seem to matter on Windows
cp -r temp/usr/local/{lib,bin,include} /mingw64/
shell: msys2 {0}
cargo cinstall --verbose --release --prefix /mingw64 --target x86_64-pc-windows-gnu
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess cargo has the msvc toolchain as default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like it.

I was hoping to get the right target automatically, since I'm using cargo from MSYS2, which should know that it uses the GNU toolchain.

Strangely, when I'm using the MSYS2 package for cargo-c (instead of compiling it on-the-fly), the --target flag is not necessary (see https://github.com/mgeier/cargo-c/runs/4754623622)!

So why does the MSYS2 package of cargo-c do the right thing?

But, as I said, I don't think this should be a blocker for now, we can try to figure this out later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a separate issue as a reminder: #244.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness, I've also created one about the --prefix: #245

@lu-zero lu-zero merged commit 97a9d53 into lu-zero:master Jan 9, 2022
@lu-zero
Copy link
Owner

lu-zero commented Jan 9, 2022

Thank you!

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

Successfully merging this pull request may close these issues.

3 participants