Skip to content

Commit e97e142

Browse files
author
Dave Plummer
committed
Update Dockerfile with new compilation flags
1 parent 33aa68d commit e97e142

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

PrimeCPP/solution_5/Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
FROM ubuntu:22.04 AS build
33

44
RUN apt-get update -qq \
5-
&& apt-get install -y bash clang
5+
&& apt-get install -y bash clang lld
66

77
WORKDIR /opt/app
88
COPY *.cpp .
99

10-
# Optional: arch-aware flags using BuildKit's TARGETARCH
10+
# Build with the same flags as run.sh to enable vectorization
11+
# across Mac and Linux. On ARM64, use -mcpu=native instead of -march/-mtune.
1112
ARG TARGETARCH
1213
RUN set -eux; \
13-
CXXFLAGS="-O3 -ffast-math -std=c++17 -pthread"; \
14-
case "$TARGETARCH" in \
15-
amd64) CXXFLAGS="$CXXFLAGS -march=native -mtune=native" ;; \
16-
arm64) CXXFLAGS="$CXXFLAGS -mcpu=native" ;; \
17-
*) : ;; \
18-
esac; \
19-
clang++ $CXXFLAGS PrimeCPP_array.cpp -o primes_array.exe
14+
CXXFLAGS="-march=native -mtune=native -pthread -O3 -ffast-math -fno-math-errno -fno-trapping-math -flto -std=c++17"; \
15+
if [ "${TARGETARCH:-amd64}" = "arm64" ]; then \
16+
CXXFLAGS="-mcpu=native -pthread -O3 -ffast-math -fno-math-errno -fno-trapping-math -flto -std=c++17"; \
17+
fi; \
18+
clang++ ${CXXFLAGS} -fuse-ld=lld PrimeCPP_array.cpp -o primes_array.exe
2019

2120
# ---- runtime stage ----
2221
FROM ubuntu:22.04

0 commit comments

Comments
 (0)