Skip to content

Commit

Permalink
docker: add x86,armv7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Nov 29, 2023
1 parent 066c472 commit d399f28
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: ${{vars.DOCKERHUB_REPO}}:${{ github.event.inputs.version }}
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM ubuntu:latest as smartdns-builder
FROM debian:latest as smartdns-builder
LABEL previous-stage=smartdns-builder

# prepare builder
ARG OPENSSL_VER=3.0.10
ARG OPENSSL_VER=3.0.12
RUN apt update && \
apt install -y perl curl make musl-tools musl-dev && \
ln -s /usr/include/linux /usr/include/$(uname -m)-linux-musl && \
Expand All @@ -11,13 +11,14 @@ RUN apt update && \
\
mkdir -p /build/openssl && \
cd /build/openssl && \
curl -sSL http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_${OPENSSL_VER}.orig.tar.gz | tar --strip-components=1 -zxv && \
curl -sSL https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz | tar --strip-components=1 -zxv && \
\
export CC=musl-gcc && \
export OPENSSL_OPTIONS="no-tests no-ssl3 no-weak-ssl-ciphers no-shared no-idea -DOPENSSL_NO_SECURE_MEMORY" && \
if [ "$(uname -m)" = "aarch64" ]; then \
./config --prefix=/opt/build no-tests -mno-outline-atomics ; \
./config --prefix=/opt/build $OPENSSL_OPTIONS -mno-outline-atomics; \
else \
./config --prefix=/opt/build no-tests ; \
./config --prefix=/opt/build $OPENSSL_OPTIONS; \
fi && \
make all -j8 && make install_sw && \
cd / && rm -rf /build
Expand All @@ -26,8 +27,9 @@ RUN apt update && \
COPY . /build/smartdns/
RUN cd /build/smartdns && \
export CC=musl-gcc && \
export CFLAGS="-I /opt/build/include" && \
export EXTRA_CFLAGS="-I /opt/build/include" && \
export LDFLAGS="-L /opt/build/lib -L /opt/build/lib64" && \
export NOUNWIND=1 && \
sh ./package/build-pkg.sh --platform linux --arch `dpkg --print-architecture` --static && \
\
( cd package && tar -xvf *.tar.gz && chmod a+x smartdns/etc/init.d/smartdns ) && \
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ override CFLAGS += $(EXTRA_CFLAGS)
ifdef VER
override CFLAGS += -DSMARTDNS_VERION='"$(VER)"'
endif
ifdef NOUNWIND
override CFLAGS += -DNO_UNWIND
endif

CXXFLAGS=-O2 -g -Wall -std=c++11
override CXXFLAGS +=-Iinclude
Expand Down
39 changes: 37 additions & 2 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <unwind.h>

#define TMP_BUFF_LEN_32 32

Expand Down Expand Up @@ -1419,11 +1418,45 @@ uint64_t get_free_space(const char *path)
return size;
}

#ifdef NO_UNWIND
void print_stack(void)
{
return;
}
#else
#ifdef __USE_GNU
#include <execinfo.h>
void print_stack(void)
{
void *buffer[128];
int idx = 0;
int frame_num = backtrace(buffer, 128);
if (frame_num == 0) {
return;
}

tlog(TLOG_FATAL, "Stack:");
for (idx = 0; idx < frame_num; ++idx) {
const void *addr = buffer[idx];
const char *symbol = "";

Dl_info info;
memset(&info, 0, sizeof(info));
if (dladdr(addr, &info) && info.dli_sname) {
symbol = info.dli_sname;
}

void *offset = (void *)((char *)(addr) - (char *)(info.dli_fbase));
tlog(TLOG_FATAL, "#%.2d: %p %s() from %s+%p", idx + 1, addr, symbol, info.dli_fname, offset);
}
}

#else
#include <unwind.h>
struct backtrace_state {
void **current;
void **end;
};

static _Unwind_Reason_Code unwind_callback(struct _Unwind_Context *context, void *arg)
{
struct backtrace_state *state = (struct backtrace_state *)(arg);
Expand Down Expand Up @@ -1466,6 +1499,8 @@ void print_stack(void)
tlog(TLOG_FATAL, "#%.2d: %p %s() from %s+%p", idx + 1, addr, symbol, info.dli_fname, offset);
}
}
#endif
#endif

void bug_ext(const char *file, int line, const char *func, const char *errfmt, ...)
{
Expand Down

0 comments on commit d399f28

Please sign in to comment.