-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support cross compilation with xgo #230
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
PARENT_PATH=$(dirname $(cd $(dirname $0); pwd -P)) | ||
pushd $PARENT_PATH | ||
|
||
# Make sure we have xgo | ||
go get -u github.com/karalabe/xgo | ||
|
||
# Apply patch for OSX, Go 1.10 and old notify version | ||
# https://stackoverflow.com/questions/54064293/cannot-use-nil-as-type-ctype-cfallocatorref-in-argument-to-func-literal | ||
# Can be removed if we upgrade notify (which probably requires upgrading go-ethereum etc.) | ||
pushd vendor/github.com/rjeczalik/notify | ||
patch -N < $PARENT_PATH/scripts/watcher_fsevents_cgo.go.patch || true | ||
popd | ||
|
||
mkdir -p build | ||
|
||
# Stuck on Go 1.10.x until https://github.com/singnet/snet-daemon/issues/201 is resolved. | ||
GO_VERSION=1.10.x | ||
|
||
# All targets compiled when Joel tried (2019-March), but we probably don't want to build them all! | ||
#TARGETS=*/* | ||
|
||
# See here for details | ||
# https://github.com/karalabe/xgo#limit-build-targets | ||
TARGETS=linux/amd64,linux/arm-6,darwin-10.6/amd64,windows/amd64 | ||
xgo -dest build -go $GO_VERSION -targets=$TARGETS ./snetd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- /home/joel/Downloads/watcher_fsevents_cgo.go 2019-03-20 13:14:12.643748593 +1300 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this file related to cross compilation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, at least until we upgrade our deps and Go. This patch is required for compiling for OSX and gets automatically applied by the build script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, that clarifies |
||
+++ watcher_fsevents_cgo.go 2019-03-20 12:49:33.489170174 +1300 | ||
@@ -48,7 +48,7 @@ | ||
// started and is ready via the wg. It also serves purpose of a dummy source, | ||
// thanks to it the runloop does not return as it also has at least one source | ||
// registered. | ||
-var source = C.CFRunLoopSourceCreate(nil, 0, &C.CFRunLoopSourceContext{ | ||
+var source = C.CFRunLoopSourceCreate(C.kCFAllocatorDefault, 0, &C.CFRunLoopSourceContext{ | ||
perform: (C.CFRunLoopPerformCallBack)(C.gosource), | ||
}) | ||
|
||
@@ -162,8 +162,8 @@ | ||
return nil | ||
} | ||
wg.Wait() | ||
- p := C.CFStringCreateWithCStringNoCopy(nil, C.CString(s.path), C.kCFStringEncodingUTF8, nil) | ||
- path := C.CFArrayCreate(nil, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil) | ||
+ p := C.CFStringCreateWithCStringNoCopy(C.kCFAllocatorDefault, C.CString(s.path), C.kCFStringEncodingUTF8, C.kCFAllocatorDefault) | ||
+ path := C.CFArrayCreate(C.kCFAllocatorDefault, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil) | ||
ctx := C.FSEventStreamContext{} | ||
ref := C.EventStreamCreate(&ctx, C.uintptr_t(s.info), path, C.FSEventStreamEventId(atomic.LoadUint64(&since)), latency, flags) | ||
if ref == nilstream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change required for the cross compilation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Int is 32bit on Arm6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks