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

Can't build custom extension for k6 #57

Closed
ChipArtem opened this issue Jan 11, 2023 · 2 comments
Closed

Can't build custom extension for k6 #57

ChipArtem opened this issue Jan 11, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ChipArtem
Copy link

Brief summary

Im try build custom extension for k6.
But I have an error while building.
Xk6 does not see types in package that I am importing in the extension.

k6 version

v0.42.0

OS

macOS 11

Docker version and image (if applicable)

No response

Steps to reproduce the problem

xk6 build --output xk6Custom --with github.com/ChipArtem/bugxk6

Expected behaviour

Package xk6Custom created

Actual behaviour

Error:
../../../../go/pkg/mod/github.com/ibm-messaging/mq-golang-jms20@v1.9.0/jms20subset/MQOptions.go:5:32: undefined: ibmmq.MQCNO
(I checked, this type is imported correctly in mq-golang-jms20)

Full info:
2023/01/11 11:09:39 [INFO] Temporary folder: /Users/chip/git_repo/bugxk6/buildenv_2023-01-11-1109.559430917
2023/01/11 11:09:39 [INFO] Initializing Go module
2023/01/11 11:09:39 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init k6
go: creating new go.mod: module k6
2023/01/11 11:09:39 [INFO] Pinning versions
2023/01/11 11:09:39 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require github.com/ChipArtem/bugxk6@latest
2023/01/11 11:09:39 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
go: downloading github.com/ChipArtem/bugxk6 v0.0.0-20230111080905-ebbb48a21070
go: finding module for package github.com/nxadm/tail
go: finding module for package github.com/google/go-cmp/cmp
go: found github.com/google/go-cmp/cmp in github.com/google/go-cmp v0.5.9
go: found github.com/nxadm/tail in github.com/nxadm/tail v1.4.8
2023/01/11 11:09:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2023/01/11 11:09:55 [INFO] Writing main module: /Users/chip/git_repo/bugxk6/buildenv_2023-01-11-1109.559430917/main.go
2023/01/11 11:09:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2023/01/11 11:09:55 [INFO] Build environment ready
2023/01/11 11:09:55 [INFO] Building k6
2023/01/11 11:09:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2023/01/11 11:09:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /Users/chip/git_repo/bugxk6/xk6 -ldflags=-w -s -trimpath
#github.com/ibm-messaging/mq-golang-jms20/jms20subset
../../../../go/pkg/mod/github.com/ibm-messaging/mq-golang-jms20@v1.9.0/jms20subset/MQOptions.go:5:32: undefined: ibmmq.MQCNO
../../../../go/pkg/mod/github.com/ibm-messaging/mq-golang-jms20@v1.9.0/jms20subset/MQOptions.go:8:25: undefined: ibmmq.MQCNO
2023/01/11 11:09:56 [INFO] Cleaning up temporary folder: /Users/chip/git_repo/bugxk6/buildenv_2023-01-11-1109.559430917
2023/01/11 11:09:56 [FATAL] exit status 2

@ChipArtem ChipArtem added the bug Something isn't working label Jan 11, 2023
@mstoykov mstoykov self-assigned this Jan 11, 2023
@mstoykov
Copy link
Contributor

You are getting this error as xk6 defaults to disabling CGO and the dependency in question is using CGO to import C code and then use it.

Running CGO_ENABLED=1 xk6 build --output xk6Custom --with github.com/ChipArtem/bugxk6 does give a C error (not having a header file) so I would expect it will work.

I will move this to the xk6 repo to see if there is a reason we default to CGO_ENABLED=0 by default.

@mstoykov mstoykov transferred this issue from grafana/k6 Jan 11, 2023
@ChipArtem
Copy link
Author

@mstoykov Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants