File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 22FROM ubuntu:22.04 AS build
33
44RUN apt-get update -qq \
5- && apt-get install -y bash clang
5+ && apt-get install -y bash clang lld
66
77WORKDIR /opt/app
88COPY *.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.
1112ARG TARGETARCH
1213RUN 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 ----
2221FROM ubuntu:22.04
You can’t perform that action at this time.
0 commit comments