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

Allow CGO_ENABLED=1 #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Allow CGO_ENABLED=1 #65

wants to merge 1 commit into from

Conversation

e-nikolov
Copy link

Dynamically linked Go applications compiled with CGO_ENABLED=1 on a system with glibc (default on debian based distros) instead of musl (default on alpine) can now run inside an iron/go container.

Dynamically linked Go applications compiled with CGO_ENABLED=1 on a system with glibc (default on debian based distros) instead of musl (default on alpine) can now run inside an iron/go container.
Copy link
Contributor

@vasilev vasilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @e-nikolov for your contribution.

Could you provide an instruction how to test your changes ?

We tried to compile a simple example on Ubuntu using Go 1.5, and built a Docker image for that binary based on this Dockerfile.
We encountered the following error during image execution:

Error relocating /app/test: __vfprintf_chk: symbol not found
Error relocating /app/test: __fprintf_chk: symbol not found

Was this test correct ?

@e-nikolov
Copy link
Author

e-nikolov commented Oct 26, 2017

Initially I tested only with a simple program that printed something to the screen and it worked, but after I started using CGO_ENABLED=1 features such as golang plugins, I got the same error as you. I ended up using https://github.com/frol/docker-alpine-glibc, which has a real glibc inside an alpine container, instead of trying to make musl look like glibc via symlinks.

The work around proposed here only seems to work when compiling a program with CGO_ENABLED=1, but not using features that require dynamic linking or linking with C programs, which is indeed not very useful.

In theory musl and glibc should be compatible and there should be a way to make CGO_ENABLED=1 work with just musl installed, but it seems that the proposed symlink is not sufficient.

Feel free to reject this pull request for now, if I come up with a better solution, I'll make another.

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.

2 participants