You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running it in an Alpine container with standard go tools works fine.
Dockerfile:
FROM golang:1.10.0-alpine3.7 as builder
USER root
ENV GOPATH='/builder'
WORKDIR /builder/src/github.com/richyhbm/go-test
ADD . /builder/src/github.com/richyhbm/go-test
RUN go build
Output of building the docker file:
/gotest $ docker build -t goapp .
Sending build context to Docker daemon 4.096kB
Step 1/6 : FROM golang:1.10.0-alpine3.7 as builder
---> 85256d3905e2
Step 2/6 : USER root
---> Using cache
---> 6fe0b5104cdf
Step 3/6 : ENV GOPATH='/builder'
---> Using cache
---> b70bb8a6b6a0
Step 4/6 : WORKDIR /builder/src/github.com/richyhbm/go-test
---> Using cache
---> 4d4707c0e99d
Step 5/6 : ADD . /builder/src/github.com/richyhbm/go-test
---> d507c37cf1c2
Step 6/6 : RUN go build
---> Running in 12f53eaba187
Removing intermediate container 12f53eaba187
---> ad2b407ca361
Successfully built ad2b407ca361
Successfully tagged goapp:latest
However take that same code and build it using vgo, using the following dockerfile:
FROM golang:1.10.0-alpine3.7 as builder
USER root
RUN apk update
RUN apk add git clang
RUN go get -u golang.org/x/vgo
WORKDIR /builder
ADD . /builder
RUN vgo build
And firstly running the vgo test without installing clang gives:
---> Running in d43959a0e06c
# runtime/cgo
exec: "clang": executable file not found in $PATH
After installing it you get:
/vgotest $ docker build -t goapp .
Sending build context to Docker daemon 12.8kB
Step 1/8 : FROM golang:1.10.0-alpine3.7 as builder
---> 85256d3905e2
Step 2/8 : USER root
---> Using cache
---> 6fe0b5104cdf
Step 3/8 : RUN apk update
---> Using cache
---> 808f907f3d65
Step 4/8 : RUN apk add git clang
---> Running in 88d527c9f56b
(1/10) Installing libgcc (6.4.0-r5)
(2/10) Installing libstdc++ (6.4.0-r5)
(3/10) Installing clang-libs (5.0.0-r0)
(4/10) Installing libxml2 (2.9.7-r0)
(5/10) Installing clang (5.0.0-r0)
(6/10) Installing libssh2 (1.8.0-r2)
(7/10) Installing libcurl (7.59.0-r0)
(8/10) Installing expat (2.2.5-r0)
(9/10) Installing pcre2 (10.30-r0)
(10/10) Installing git (2.15.0-r1)
Executing busybox-1.27.2-r7.trigger
OK: 200 MiB in 22 packages
Removing intermediate container 88d527c9f56b
---> ad5f5c333708
Step 5/8 : RUN go get -u golang.org/x/vgo
---> Running in 4e658f3fdcf5
Removing intermediate container 4e658f3fdcf5
---> 8a1c38f6f356
Step 6/8 : WORKDIR /builder
Removing intermediate container cfa3153bf761
---> fed5be70f790
Step 7/8 : ADD . /builder
---> a907cbe009da
Step 8/8 : RUN vgo build
---> Running in 73791c7de043
# runtime/cgo
cgo-builtin-prolog:1:10: fatal error: 'stddef.h' file not found
#include <stddef.h> /* for ptrdiff_t and size_t below */
^~~~~~~~~~
1 error generated.
Note that compiling it as a statically linked executable with cgo turned off works fine.
CGO_ENABLED=0 GOOS=linux vgo build -a -installsuffix cgo
What did you expect to see?
Program to build as expected
What did you see instead?
Missing header error
The text was updated successfully, but these errors were encountered:
In your vgo docker you're installing clang while in the go docker you did not. Try installing clang on the go docker to make sure this is indeed vgo related and not a clang issue.
What version of Go are you using (
go version
)?Go:
go version go1.10 linux/amd64
VGo:
go version go1.10 linux/amd64 vgo:2018-02-20.1
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Go
VGo
What did you do?
Given a basic golang program that makes use of net (thus cgo):
Running it in an Alpine container with standard go tools works fine.
Dockerfile:
Output of building the docker file:
However take that same code and build it using vgo, using the following dockerfile:
And firstly running the vgo test without installing clang gives:
After installing it you get:
Note that compiling it as a statically linked executable with cgo turned off works fine.
What did you expect to see?
Program to build as expected
What did you see instead?
Missing header error
The text was updated successfully, but these errors were encountered: