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

Cross compile docker script #14

Merged
merged 7 commits into from
Nov 22, 2019
Merged

Cross compile docker script #14

merged 7 commits into from
Nov 22, 2019

Conversation

ethanfrey
Copy link
Member

Closes #8

Dockerfile that builds linux and osx right now.
Details and README in the build directory.

@shanev can you please checkout this branch and validate that make test works out of the box (using my generated .dylib, not yours).

@shanev
Copy link
Contributor

shanev commented Oct 23, 2019

@ethanfrey This is the result of make test:

go test -v ./api
dyld: Library not loaded: /code/target/x86_64-apple-darwin/release/deps/libgo_cosmwasm.dylib
  Referenced from: /var/folders/jr/f46xqp790tl7sw7xlf3jjcg40000gn/T/go-build317794611/b001/api.test
  Reason: image not found
FAIL	github.com/confio/go-cosmwasm/api	0.003s
FAIL
make: *** [test] Error 1

@ethanfrey
Copy link
Member Author

ethanfrey commented Oct 23, 2019

Remote debugging here:

https://stackoverflow.com/questions/17703510/dyld-library-not-loaded-reason-image-not-found

Please try:

otool -L ./api/libgo_cosmwasm.dylib

Maybe try setting DYLD_LIBRARY_PATH to point it to the proper location

@shanev
Copy link
Contributor

shanev commented Oct 23, 2019

After otool -L ./api/libgo_cosmwasm.dylib:

./api/libgo_cosmwasm.dylib:
	/code/target/x86_64-apple-darwin/release/deps/libgo_cosmwasm.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)

@ethanfrey
Copy link
Member Author

@shanev I made another attempt here, maybe these work?
Can you check this out again and try make test and otool -L ./api/libgo_cosmwasm.dylib?

@shanev
Copy link
Contributor

shanev commented Oct 24, 2019

make test:

go test -v ./api
=== RUN   TestInitAndReleaseCache
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/libcore/result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
--- PASS: TestInitAndReleaseCache (0.00s)
    api_test.go:40: /var/folders/jr/f46xqp790tl7sw7xlf3jjcg40000gn/T/go-cosmwasm208121230
=== RUN   TestCreateAndGet
--- PASS: TestCreateAndGet (0.08s)
=== RUN   TestCreateFailsWithBadData
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ValidationError { msg: "Bad magic number" }', src/libcore/result.rs:1084:5
--- PASS: TestCreateFailsWithBadData (0.00s)
=== RUN   TestInstantiate
--- PASS: TestInstantiate (0.08s)
=== RUN   TestHandle
--- PASS: TestHandle (0.07s)
=== RUN   TestMultipleInstances
--- PASS: TestMultipleInstances (0.07s)
=== RUN   TestQueryFails
--- PASS: TestQueryFails (0.00s)
PASS
ok  	github.com/confio/go-cosmwasm/api	(cached)

otool -L ./api/libgo_cosmwasm.dylib:

./api/libgo_cosmwasm.dylib:
	/code/target/x86_64-apple-darwin/release/deps/libgo_cosmwasm.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)

@ethanfrey
Copy link
Member Author

Looks like the otool output is the same.

make test is still using a cached test, doesn't rebuild on .dylib changes. You actually have to edit api.go and then run the tests again to ensure it will run the linkage step again (edit the file that declares linkage in the cgo header, not any other file).

Anyway, with the otool output, I will take it that nothing changed.

@ethanfrey ethanfrey added the Blocked Impossible to continue without outside intervention label Oct 24, 2019
@ethanfrey ethanfrey removed the Blocked Impossible to continue without outside intervention label Nov 22, 2019
@ethanfrey
Copy link
Member Author

With a bit of help, I discovered a solution to the problem, properly setting @rpath when compiling the libraries. I managed to get a valid build to work on an osx machine. But it needs some fixes, it leaves root files all over the target dir and breaks native cargo build on macos. Resolving these issues, then soon should have Dockerfied cross compilation, at least for linux and osx

@ethanfrey
Copy link
Member Author

Validated to work on osx - both the cross-compile output and the native cargo build command.

@ethanfrey ethanfrey merged commit c018bc1 into master Nov 22, 2019
@ethanfrey ethanfrey deleted the cross-compile branch November 22, 2019 11:52
tomtau pushed a commit to tomtau/wasmvm that referenced this pull request Oct 6, 2021
* build: support cross-compile for private repo

Remove docker -u option when cargo build
because it occurs git config failure.

* build: update linux prebuilt binary

used 'make release-build-linux'

* build: update macos prebuilt binary

used 'make release-build-macos'
faddat pushed a commit to faddat/go-cosmwasm that referenced this pull request Dec 10, 2021
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.

Commit pre-built dlls for go-cosmwasm
2 participants