mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-01-15 17:25:27 +00:00
Use docker run to compile C code not docker build
C version of #1006 Note that I switched all the C builds to use -O2 and that meant that the compiler found some more warnings so I also fixed these up. The possibly undefined ones were harmless, the aliasing one is now more correct. As these are small programs, the caching from `docker build` makes no real difference, and worst case compile time is much better. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
# Tag: b77cfc4ad0033d4366df830ed697afc7bab458a2
|
||||
FROM mobylinux/alpine-build-c@sha256:53739ea6042cb0ac39cf6e262012c1c4224206b2c9b719569fe7efa3a381348c
|
||||
|
||||
COPY . /9pmount-vsock
|
||||
|
||||
WORKDIR /9pmount-vsock
|
||||
|
||||
RUN cc -Wall -Werror 9pmount-vsock.c hvsock.c -lpthread -o 9pmount-vsock
|
||||
|
||||
CMD ["tar", "cf", "-", "9pmount-vsock"]
|
||||
@@ -1,12 +1,13 @@
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
# Tag: ac075fed7c87e4af30d8490ae0504166cceb0df3
|
||||
C_COMPILE=mobylinux/c-compile@sha256:0e82d441ce112d638f904a08199c76b022c065a2dbf8908bb366755267d4417f
|
||||
|
||||
9pmount-vsock: $(DEPS)
|
||||
mkdir -p sbin
|
||||
BUILD=$$( tar cf - $(DEPS) | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
echo "Built $$BUILD" && \
|
||||
docker run --rm --net=none $$BUILD | tar xf - -C sbin
|
||||
default: sbin/9pmount-vsock
|
||||
|
||||
DEPS=$(wildcard *.c *.h)
|
||||
|
||||
sbin/9pmount-vsock: $(DEPS)
|
||||
mkdir -p $(dir $@)
|
||||
tar cf - $(DEPS) | docker run --rm --net=none --log-driver=none -i $(C_COMPILE) -o $@ -lpthread | tar xf -
|
||||
|
||||
clean:
|
||||
rm -rf sbin
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Tag: b77cfc4ad0033d4366df830ed697afc7bab458a2
|
||||
FROM mobylinux/alpine-build-c@sha256:53739ea6042cb0ac39cf6e262012c1c4224206b2c9b719569fe7efa3a381348c
|
||||
|
||||
COPY . /nc-vsock
|
||||
|
||||
WORKDIR /nc-vsock
|
||||
|
||||
RUN cc -Wall -Werror -o nc-vsock nc-vsock.c -luuid
|
||||
|
||||
CMD ["tar", "cf", "-", "nc-vsock"]
|
||||
@@ -1,11 +1,13 @@
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
# Tag: ac075fed7c87e4af30d8490ae0504166cceb0df3
|
||||
C_COMPILE=mobylinux/c-compile@sha256:0e82d441ce112d638f904a08199c76b022c065a2dbf8908bb366755267d4417f
|
||||
|
||||
default: usr/bin/nc-vsock
|
||||
|
||||
DEPS=$(wildcard *.c *.h)
|
||||
|
||||
usr/bin/nc-vsock: $(DEPS)
|
||||
mkdir -p usr/bin
|
||||
BUILD=$$( tar cf - $(DEPS) | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
echo "Built $$BUILD" && \
|
||||
docker run --rm --net=none $$BUILD | tar xf - -C usr/bin
|
||||
mkdir -p $(dir $@)
|
||||
tar cf - $(DEPS) | docker run --rm --net=none --log-driver=none -i $(C_COMPILE) -o $@ -luuid | tar xf -
|
||||
|
||||
clean:
|
||||
rm -rf usr
|
||||
|
||||
@@ -193,7 +193,7 @@ static int hvsock_listen(const char *port_str)
|
||||
|
||||
static int tcp_connect(const char *node, const char *service)
|
||||
{
|
||||
int fd;
|
||||
int fd = -1;
|
||||
int ret;
|
||||
const struct addrinfo hints = {
|
||||
.ai_family = AF_INET,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Tag: b77cfc4ad0033d4366df830ed697afc7bab458a2
|
||||
FROM mobylinux/alpine-build-c@sha256:53739ea6042cb0ac39cf6e262012c1c4224206b2c9b719569fe7efa3a381348c
|
||||
|
||||
COPY . /tap-vsockd
|
||||
|
||||
WORKDIR /tap-vsockd
|
||||
|
||||
RUN cc -Wall -Werror tap-vsockd.c hvsock.c protocol.c -lpthread -o tap-vsockd
|
||||
|
||||
CMD ["tar", "cf", "-", "tap-vsockd"]
|
||||
@@ -1,11 +1,13 @@
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
# Tag: ac075fed7c87e4af30d8490ae0504166cceb0df3
|
||||
C_COMPILE=mobylinux/c-compile@sha256:0e82d441ce112d638f904a08199c76b022c065a2dbf8908bb366755267d4417f
|
||||
|
||||
default: sbin/tap-vsockd
|
||||
|
||||
DEPS=$(wildcard *.c *.h)
|
||||
|
||||
sbin/tap-vsockd: $(DEPS)
|
||||
mkdir -p sbin
|
||||
BUILD=$$( tar cf - $(DEPS) | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
echo "Built $$BUILD" && \
|
||||
docker run --rm --net=none $$BUILD | tar xf - -C sbin
|
||||
mkdir -p $(dir $@)
|
||||
tar cf - $(DEPS) | docker run --rm --net=none --log-driver=none -i $(C_COMPILE) -o $@ -lpthread | tar xf -
|
||||
|
||||
clean:
|
||||
rm -rf sbin
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Tag: b77cfc4ad0033d4366df830ed697afc7bab458a2
|
||||
FROM mobylinux/alpine-build-c@sha256:53739ea6042cb0ac39cf6e262012c1c4224206b2c9b719569fe7efa3a381348c
|
||||
|
||||
COPY . /transfused
|
||||
|
||||
WORKDIR /transfused
|
||||
|
||||
RUN cc -g -static -Wall -Werror -o transfused transfused.c transfused_log.c transfused_vsock.c
|
||||
|
||||
CMD ["tar", "cf", "-", "transfused"]
|
||||
@@ -1,11 +1,13 @@
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
# Tag: ac075fed7c87e4af30d8490ae0504166cceb0df3
|
||||
C_COMPILE=mobylinux/c-compile@sha256:0e82d441ce112d638f904a08199c76b022c065a2dbf8908bb366755267d4417f
|
||||
|
||||
default: sbin/transfused
|
||||
|
||||
DEPS=$(wildcard *.c *.h)
|
||||
|
||||
sbin/transfused: $(DEPS)
|
||||
mkdir -p sbin
|
||||
BUILD=$$( tar cf - $(DEPS) | docker build -q - ) && \
|
||||
[ -n "$$BUILD" ] && \
|
||||
echo "Built $$BUILD" && \
|
||||
docker run --rm --net=none $$BUILD | tar xf - -C sbin
|
||||
mkdir -p $(dir $@)
|
||||
tar cf - $(DEPS) | docker run --rm --net=none --log-driver=none -i $(C_COMPILE) -o $@ | tar xf -
|
||||
|
||||
clean:
|
||||
rm -rf sbin
|
||||
|
||||
@@ -97,7 +97,7 @@ void unlock(char *const descr, pthread_mutex_t *mutex)
|
||||
|
||||
int bind_socket(const char *socket)
|
||||
{
|
||||
int sock;
|
||||
int sock = -1;
|
||||
|
||||
if (socket[0] == 0)
|
||||
die(2, NULL, NULL, "Socket family required");
|
||||
@@ -118,7 +118,7 @@ int bind_socket(const char *socket)
|
||||
|
||||
int connect_socket(const char *socket)
|
||||
{
|
||||
int sock;
|
||||
int sock = -1;
|
||||
|
||||
if (socket[0] == 0)
|
||||
die(2, NULL, NULL, "Socket family required");
|
||||
@@ -549,12 +549,15 @@ void start_writer(connection_t *connection, int fuse)
|
||||
void negotiate_notify_channel(char *mount_point, int notify_sock)
|
||||
{
|
||||
int len = strlen(mount_point);
|
||||
char hdr[6];
|
||||
struct {
|
||||
uint32_t len;
|
||||
uint16_t channel;
|
||||
} __attribute__((packed)) hdr;
|
||||
|
||||
*((uint32_t *)hdr) = 6 + len;
|
||||
*((uint16_t *)(hdr + 4)) = TRANSFUSE_NOTIFY_CHANNEL;
|
||||
hdr.len = 6 + len;
|
||||
hdr.channel = TRANSFUSE_NOTIFY_CHANNEL;
|
||||
|
||||
write_exactly("negotiate_notify_channel hdr", notify_sock, hdr, 6);
|
||||
write_exactly("negotiate_notify_channel hdr", notify_sock, &hdr, 6);
|
||||
write_exactly("negotiate_notify_channel mnt",
|
||||
notify_sock, mount_point, len);
|
||||
}
|
||||
@@ -1087,7 +1090,7 @@ void serve(parameters *params)
|
||||
char subproto_selector;
|
||||
pthread_t child;
|
||||
connection_t *conn;
|
||||
void *(*connection_handler_thread)(void *);
|
||||
void *(*connection_handler_thread)(void *) = NULL;
|
||||
|
||||
if (listen(params->data_sock, 16))
|
||||
die(1, NULL, "listen", "");
|
||||
|
||||
Reference in New Issue
Block a user