Skip to content

Commit

Permalink
Fix cross compile (#237)
Browse files Browse the repository at this point in the history
* Add target

* Fix test

* Add test

* Fix test

* Add targets

* Add cargo config files

* Do not run thread-unsafe rustups

* Add targets first

* Test more target triples

* Remove extra step

* Update gherkin2markdown
  • Loading branch information
raviqqe authored Aug 17, 2021
1 parent 9085da4 commit 8623356
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
if: startsWith(matrix.os, 'macos-')
- uses: actions/setup-ruby@v1
- run: bundler install
- run: rustup target add wasm32-unknown-unknown
- run: cargo build --release
- run: rm features/smoke/memory_leak.feature
if: startsWith(matrix.os, 'macos-')
Expand Down
39 changes: 37 additions & 2 deletions features/commands/build.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,34 @@ Feature: Building packages
When I run `pen build`
Then the exit status should be 0

Scenario: Cross-build a library package
Scenario: Cross-build an application package
Given a file named "pen.json" with:
"""json
{
"dependencies": {
"System": "file://pen-root/lib/os"
}
}
"""
And a file named "Main.pen" with:
"""pen
import System'Os
main = \(os Os'Os) number {
0
}
"""
And I successfully run `rustup target add <triple>`
When I run `pen build --target <triple>`
Then the exit status should be 0

Examples:
| triple |
| i686-unknown-linux-musl |
| x86_64-unknown-linux-musl |
| aarch64-unknown-linux-musl |

Scenario Outline: Cross-build a library package
Given a file named "pen.json" with:
"""json
{ "dependencies": {} }
Expand All @@ -44,5 +71,13 @@ Feature: Building packages
x
}
"""
When I run `pen build --target wasm32-unknown-unknown`
And I successfully run `rustup target add <triple>`
When I run `pen build --target <triple>`
Then the exit status should be 0

Examples:
| triple |
| i686-unknown-linux-musl |
| x86_64-unknown-linux-musl |
| aarch64-unknown-linux-musl |
| wasm32-wasi |
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/pen-lang/pen

go 1.16

require github.com/raviqqe/gherkin2markdown v0.0.0-20210720061714-b8cc673d62bc // indirect
require (
github.com/cucumber/gherkin-go v5.1.0+incompatible // indirect
github.com/raviqqe/gherkin2markdown v0.0.0-20210817012807-29d4bf48914b // indirect
)
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
github.com/cucumber/gherkin-go v5.1.0+incompatible h1:RCvyVI6KQLI2IJkijZBeJcE4K3U7DnhQ1RjD7VV+AIk=
github.com/cucumber/gherkin-go v5.1.0+incompatible/go.mod h1:bYJ65F+CDEAL70FXAu7/ef4ayC/NhRXO8zEW3IB21w0=
github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE=
github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw=
github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
github.com/cucumber/messages-go/v16 v16.0.1 h1:fvkpwsLgnIm0qugftrw2YwNlio+ABe2Iu94Ap8GMYIY=
github.com/cucumber/messages-go/v16 v16.0.1/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/raviqqe/gherkin2markdown v0.0.0-20210719155857-e67d7070d01c h1:oPpilw3zwViiffDgDWcA4nKdfiSTC22TLqRcJZNGgqU=
github.com/raviqqe/gherkin2markdown v0.0.0-20210719155857-e67d7070d01c/go.mod h1:wABwkm4MYdyFNenLnkFWFS6rcKf06IjqGS4AcarSj04=
github.com/raviqqe/gherkin2markdown v0.0.0-20210720005402-04d498e21684 h1:SyjUPIL+bnVBhSmfB4WamgLdXJoLlTLV54trZrUjCls=
github.com/raviqqe/gherkin2markdown v0.0.0-20210720005402-04d498e21684/go.mod h1:wABwkm4MYdyFNenLnkFWFS6rcKf06IjqGS4AcarSj04=
github.com/raviqqe/gherkin2markdown v0.0.0-20210720061714-b8cc673d62bc h1:aboKy2zZItp+zwRHPB9fuxzW0Bj14oRpAs52dU4+vW4=
github.com/raviqqe/gherkin2markdown v0.0.0-20210720061714-b8cc673d62bc/go.mod h1:wABwkm4MYdyFNenLnkFWFS6rcKf06IjqGS4AcarSj04=
github.com/raviqqe/gherkin2markdown v0.0.0-20210817012807-29d4bf48914b h1:wQriAbt38JYfu2VYiLfnNiF/WuIXiS4AeCR1ap9koFI=
github.com/raviqqe/gherkin2markdown v0.0.0-20210817012807-29d4bf48914b/go.mod h1:aHcRXHoelgyheBcHb1O2QjF9UhOyrRXhIwoub6TqRnQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/willf/pad v0.0.0-20200313202418-172aa767f2a4 h1:Y+IMUhhlO9FLTZpNrUAMWOr7Lh0tHDKu0nrDVhp6A7o=
Expand Down
8 changes: 8 additions & 0 deletions lib/os/ffi/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[target.i686-unknown-linux-musl]
linker = "rust-lld"

[target.x86_64-unknown-linux-musl]
linker = "rust-lld"

[target.aarch64-unknown-linux-musl]
linker = "rust-lld"

0 comments on commit 8623356

Please sign in to comment.