Skip to content

Commit f8c14e1

Browse files
committed
[Docker] Extract duplicated compiler wrapper setup into shared script
- Created docker/setup_compiler_wrappers.sh for reproducible builds - Updated Dockerfile.dev and Dockerfile.builder to use the shared script - Fixed typo 'scrip' -> 'script' in build_openroad.sh help text Signed-off-by: Vi-shub <smsharma3121@gmail.com>
1 parent ba57297 commit f8c14e1

4 files changed

Lines changed: 35 additions & 21 deletions

File tree

‎build_openroad.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Options:
6767
-n, --nice Nice all jobs. Use all cpus unless --threads is
6868
also given, then use N threads.
6969
70-
--yosys-args-overwrite Do not use default flags set by this scrip during
70+
--yosys-args-overwrite Do not use default flags set by this script during
7171
Yosys compilation.
7272
7373
--yosys-args STRING Additional compilation flags for Yosys compilation.
@@ -76,7 +76,7 @@ Options:
7676
to the Verific source folder.
7777
7878
--openroad-args-overwrite
79-
Do not use default flags set by this scrip during
79+
Do not use default flags set by this script during
8080
OpenROAD app compilation.
8181
8282
--openroad-args STRING Additional compilation flags for OpenROAD app

‎docker/Dockerfile.builder‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ 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 -sf /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++
18+
# Add compiler wrapper scripts for reproducible builds
19+
COPY --link docker/setup_compiler_wrappers.sh /tmp/
20+
RUN /tmp/setup_compiler_wrappers.sh && rm /tmp/setup_compiler_wrappers.sh
2721

2822
# Prepend wrapper directory to PATH so they override system compilers
2923
ENV PATH="/usr/local/bin/wrapped-cc:$PATH"

‎docker/Dockerfile.dev‎

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

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 -sf /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++
18+
# add compiler wrapper scripts for reproducible builds
19+
COPY setup_compiler_wrappers.sh /tmp/
20+
RUN /tmp/setup_compiler_wrappers.sh && rm /tmp/setup_compiler_wrappers.sh
2821

2922
ENV PATH="/usr/local/bin/wrapped-cc:$PATH"
3023

‎docker/setup_compiler_wrappers.sh‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
# setup_compiler_wrappers.sh
3+
# Creates compiler wrapper scripts for reproducible builds by overriding
4+
# __TIME__, __DATE__, and __TIMESTAMP__ macros with constant values.
5+
# This ensures Docker image builds are deterministic regardless of build time.
6+
7+
set -e
8+
9+
WRAPPER_DIR="/usr/local/bin/wrapped-cc"
10+
mkdir -p "$WRAPPER_DIR"
11+
12+
# GCC wrapper
13+
cat > "$WRAPPER_DIR/gcc" << 'WRAPPER'
14+
#!/bin/sh
15+
exec /usr/bin/gcc -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"
16+
WRAPPER
17+
chmod +x "$WRAPPER_DIR/gcc"
18+
19+
# Symlink cc to gcc wrapper
20+
ln -sf "$WRAPPER_DIR/gcc" "$WRAPPER_DIR/cc"
21+
22+
# G++ wrapper
23+
cat > "$WRAPPER_DIR/g++" << 'WRAPPER'
24+
#!/bin/sh
25+
exec /usr/bin/g++ -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"
26+
WRAPPER
27+
chmod +x "$WRAPPER_DIR/g++"

0 commit comments

Comments
 (0)