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

cargo-build-bpf: Add Windows support #20276

Merged
merged 2 commits into from
Dec 28, 2021

Conversation

joncinque
Copy link
Contributor

Problem

cargo-build-bpf doesn't support windows

Summary of Changes

Add support for it!

A few notes:

  • ld doesn't ship by default with mingw, causing linker not found errors, so one of the changes is to force the usage of ld.lld from the sdk to link. I have very little knowledge of different linker flavors, but this was the only one that worked. If you think it should be another one, please let me know.
  • it isn't possible to run bash scripts from the program, since they aren't natively executable by windows. To get around that, this avoids calling strip.sh and just calls llvm-objcopy directly.
  • for dump.sh, it's possible to run the script separately, and re-run cargo build-bpf --dump to do the postprocessing step. it isn't elegant, but it actually works!

Fixes #

dmakarov
dmakarov previously approved these changes Sep 28, 2021
@dmakarov
Copy link
Contributor

This looks good to me, but I'm not quite sure why the usual CI checks were not executed for this PR. Let's wait until bpf-tools release assets are published ( https://github.com/solana-labs/bpf-tools/actions/runs/1281082328 ) before merging this.

@joncinque
Copy link
Contributor Author

Sounds good to me! I've nudged a little update to the error message to restart the CI job

@mergify mergify bot dismissed dmakarov’s stale review September 28, 2021 09:21

Pull request has been modified.

dmakarov
dmakarov previously approved these changes Sep 28, 2021
@dmakarov
Copy link
Contributor

dmakarov commented Nov 15, 2021

Jon, I had to turn off the build on windows when I released bpf-tools v1.19. The build failed when the build artifacts were copied in preparation for making a package tarball. The reason for the failure was the CI agent ran out of disk space. I'm not sure how to request a bigger disk for a CI agent machine, and so for now CI doesn't build bpf-tools for Windows.

@joncinque
Copy link
Contributor Author

Ah that's too bad. Thanks for noticing this. It looks like we'll need to move the steps to a different directory for this to work as expected, if actions/runner-images#1341 is actually possible, we can pass in a new out directory to checkout and build everything. I'll take a longer look at this later.

@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #20276 (3b0471b) into master (a066466) will decrease coverage by 0.0%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master   #20276     +/-   ##
=========================================
- Coverage    81.2%    81.2%   -0.1%     
=========================================
  Files         520      520             
  Lines      145949   145949             
=========================================
- Hits       118533   118532      -1     
- Misses      27416    27417      +1     

dmakarov
dmakarov previously approved these changes Nov 15, 2021
@joncinque joncinque removed the v1.8 label Dec 28, 2021
@mergify mergify bot dismissed dmakarov’s stale review December 28, 2021 05:03

Pull request has been modified.

@joncinque joncinque added the v1.9 label Dec 28, 2021
@joncinque joncinque merged commit 57986f9 into solana-labs:master Dec 28, 2021
@joncinque joncinque deleted the build-bpf-win branch December 28, 2021 23:37
mergify bot pushed a commit that referenced this pull request Dec 28, 2021
* cargo-build-bpf: Add Windows support

* Update error message

(cherry picked from commit 57986f9)
mergify bot added a commit that referenced this pull request Dec 29, 2021
* cargo-build-bpf: Add Windows support

* Update error message

(cherry picked from commit 57986f9)

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
@brooksprumo brooksprumo mentioned this pull request Jan 5, 2022
@gajojr
Copy link

gajojr commented Mar 12, 2022

So what is the solution for this?

@TradeUpCards
Copy link

So what is the solution for this?

I'd also like to know. Just getting into Solana coding and can't even do Hello World example because it says

no such subcommand: +bpf

Been scouring the web, but seems most people getting it to work are on Linux and not Windows.

@joncinque
Copy link
Contributor Author

Be sure to install the solana command line tools and rust, then use a bash-compatible shell like Git Bash. If you need more support, please ask in the Solana Stack Exchange https://solana.stackexchange.com/

@solana-labs solana-labs locked as off-topic and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants