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

Fix shadowing of jv in generated C for go 1.15 #15

Merged
merged 1 commit into from
Dec 4, 2020
Merged

Fix shadowing of jv in generated C for go 1.15 #15

merged 1 commit into from
Dec 4, 2020

Conversation

danopia
Copy link
Contributor

@danopia danopia commented Nov 19, 2020

Fixes #13.

cgo 1.15 apparently switched from p0, p1, etc to preserving argument names. This introduced a naming clash for jv.

go 1.14

CGO_NO_SANITIZE_THREAD
void goLibjqErrorHandler(GoUint64 p0, jv p1)
{
	__SIZE_TYPE__ _cgo_ctxt = _cgo_wait_runtime_init_done();
	struct {
		GoUint64 p0;
		jv p1;
	} __attribute__((__packed__, __gcc_struct__)) a;
	a.p0 = p0;
	a.p1 = p1;
	_cgo_tsan_release();
	crosscall2(_cgoexp_3ade700565aa_goLibjqErrorHandler, &a, 24, _cgo_ctxt);
	_cgo_tsan_acquire();
	_cgo_release_context(_cgo_ctxt);
}

go 1.15 (currently)

CGO_NO_SANITIZE_THREAD
void goLibjqErrorHandler(GoUint64 id, jv jv)   // <-- shadowing occurs here
{
	__SIZE_TYPE__ _cgo_ctxt = _cgo_wait_runtime_init_done();
	struct {
		GoUint64 p0;
		jv p1;         // <--  error: unknown type name 'jv'
	} __attribute__((__packed__)) _cgo_a;
	_cgo_a.p0 = id;
	_cgo_a.p1 = jv;
	_cgo_tsan_release();
	crosscall2(_cgoexp_1a11dafe0c9a_goLibjqErrorHandler, &_cgo_a, 24, _cgo_ctxt);
	_cgo_tsan_acquire();
	_cgo_release_context(_cgo_ctxt);
}

Error message

$ go get github.com/ashb/jqrepl/jq
go: found github.com/ashb/jqrepl/jq in github.com/ashb/jqrepl v0.1.0
# github.com/ashb/jqrepl/jq
_cgo_export.c:29:3: error: unknown type name 'jv'

go 1.15 patched

CGO_NO_SANITIZE_THREAD
void goLibjqErrorHandler(GoUint64 id, jv value)
{
	__SIZE_TYPE__ _cgo_ctxt = _cgo_wait_runtime_init_done();
	struct {
		GoUint64 p0;
		jv p1;
	} __attribute__((__packed__)) _cgo_a;
	_cgo_a.p0 = id;
	_cgo_a.p1 = value;
	_cgo_tsan_release();
	crosscall2(_cgoexp_1a11dafe0c9a_goLibjqErrorHandler, &_cgo_a, 24, _cgo_ctxt);
	_cgo_tsan_acquire();
	_cgo_release_context(_cgo_ctxt);
}

@ashb
Copy link
Owner

ashb commented Dec 3, 2020

Will close then re-open to trigger CI.

@ashb ashb closed this Dec 3, 2020
@ashb ashb reopened this Dec 3, 2020
cgo 1.15 apparently switched from p0, p1, etc to preserving argument names. This introduced a naming clash for `jv`.
@ashb ashb merged commit 3b27e8e into ashb:master Dec 4, 2020
@danopia danopia deleted the patch-1 branch December 6, 2020 22:36
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.

Doesn't compile under go 1.15.1
2 participants