Skip to content

Commit 2a81f92

Browse files
authored
Merge pull request #3165 from eder-matheus/update_dockerfile
inject macro definitions during compilation time
2 parents 458682e + 6bebebb commit 2a81f92

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

docker/Dockerfile.builder

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@ COPY --link build_openroad.sh build_openroad.sh
1515
1616
FROM orfs-base AS orfs-builder-base
1717
18+
# Inject compiler wrapper scripts that append the macros
19+
RUN mkdir -p /usr/local/bin/wrapped-cc && \
20+
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/gcc && \
21+
echo 'exec /usr/bin/gcc -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/gcc && \
22+
chmod +x /usr/local/bin/wrapped-cc/gcc && \
23+
ln -s /usr/local/bin/wrapped-cc/gcc /usr/local/bin/wrapped-cc/cc && \
24+
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/g++ && \
25+
echo 'exec /usr/bin/g++ -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/g++ && \
26+
chmod +x /usr/local/bin/wrapped-cc/g++
27+
28+
# Prepend wrapper directory to PATH so they override system compilers
29+
ENV PATH="/usr/local/bin/wrapped-cc:$PATH"
30+
1831
COPY --link tools tools
1932
ARG numThreads=$(nproc)
2033

2134
RUN echo "" > tools/yosys/abc/.gitcommit && \
22-
env CFLAGS="-Wno-builtin-macro-redefined" \
23-
CXXFLAGS="-Wno-builtin-macro-redefined" \
2435
./build_openroad.sh --no_init --local --threads ${numThreads}
2536

2637
FROM orfs-base

docker/Dockerfile.dev

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ COPY InstallerOpenROAD.sh \
1515
ARG options=""
1616
ARG constantBuildDir="-constant-build-dir"
1717

18-
ENV CFLAGS="-Wno-builtin-macro-redefined"
19-
ENV CXXFLAGS="-Wno-builtin-macro-redefined"
18+
# add compiler wrapper scripts
19+
# inject the macro definitions during compilation only
20+
RUN mkdir -p /usr/local/bin/wrapped-cc && \
21+
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/gcc && \
22+
echo 'exec /usr/bin/gcc -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/gcc && \
23+
chmod +x /usr/local/bin/wrapped-cc/gcc && \
24+
ln -s /usr/local/bin/wrapped-cc/gcc /usr/local/bin/wrapped-cc/cc && \
25+
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/g++ && \
26+
echo 'exec /usr/bin/g++ -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/g++ && \
27+
chmod +x /usr/local/bin/wrapped-cc/g++
28+
29+
ENV PATH="/usr/local/bin/wrapped-cc:$PATH"
2030

2131
RUN ./DependencyInstaller.sh -base $options $constantBuildDir \
2232
&& ./DependencyInstaller.sh -common $options $constantBuildDir \

0 commit comments

Comments
 (0)