Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build_openroad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Options:
-n, --nice Nice all jobs. Use all cpus unless --threads is
also given, then use N threads.

--yosys-args-overwrite Do not use default flags set by this scrip during
--yosys-args-overwrite Do not use default flags set by this script during
Yosys compilation.

--yosys-args STRING Additional compilation flags for Yosys compilation.
Expand All @@ -76,7 +76,7 @@ Options:
to the Verific source folder.

--openroad-args-overwrite
Do not use default flags set by this scrip during
Do not use default flags set by this script during
OpenROAD app compilation.

--openroad-args STRING Additional compilation flags for OpenROAD app
Expand Down
12 changes: 3 additions & 9 deletions docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@ COPY --link build_openroad.sh build_openroad.sh

FROM orfs-base AS orfs-builder-base

# Inject compiler wrapper scripts that append the macros
RUN mkdir -p /usr/local/bin/wrapped-cc && \
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/gcc && \
echo 'exec /usr/bin/gcc -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/gcc && \
chmod +x /usr/local/bin/wrapped-cc/gcc && \
ln -sf /usr/local/bin/wrapped-cc/gcc /usr/local/bin/wrapped-cc/cc && \
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/g++ && \
echo 'exec /usr/bin/g++ -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/g++ && \
chmod +x /usr/local/bin/wrapped-cc/g++
# Add compiler wrapper scripts for reproducible builds
COPY --link etc/setup_compiler_wrappers.sh /tmp/
RUN sh /tmp/setup_compiler_wrappers.sh && rm /tmp/setup_compiler_wrappers.sh

# Prepend wrapper directory to PATH so they override system compilers
ENV PATH="/usr/local/bin/wrapped-cc:$PATH"
Expand Down
13 changes: 3 additions & 10 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ COPY InstallerOpenROAD.sh \
ARG options=""
ARG constantBuildDir="-constant-build-dir"

# add compiler wrapper scripts
# inject the macro definitions during compilation only
RUN mkdir -p /usr/local/bin/wrapped-cc && \
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/gcc && \
echo 'exec /usr/bin/gcc -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/gcc && \
chmod +x /usr/local/bin/wrapped-cc/gcc && \
ln -sf /usr/local/bin/wrapped-cc/gcc /usr/local/bin/wrapped-cc/cc && \
echo '#!/bin/sh' > /usr/local/bin/wrapped-cc/g++ && \
echo 'exec /usr/bin/g++ -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"' >> /usr/local/bin/wrapped-cc/g++ && \
chmod +x /usr/local/bin/wrapped-cc/g++
# add compiler wrapper scripts for reproducible builds
COPY setup_compiler_wrappers.sh /tmp/
RUN sh /tmp/setup_compiler_wrappers.sh && rm /tmp/setup_compiler_wrappers.sh

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

Expand Down
27 changes: 27 additions & 0 deletions etc/setup_compiler_wrappers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# setup_compiler_wrappers.sh
# Creates compiler wrapper scripts for reproducible builds by overriding
# __TIME__, __DATE__, and __TIMESTAMP__ macros with constant values.
# This ensures Docker image builds are deterministic regardless of build time.

set -e

WRAPPER_DIR="/usr/local/bin/wrapped-cc"
mkdir -p "$WRAPPER_DIR"

# GCC wrapper
cat > "$WRAPPER_DIR/gcc" << 'WRAPPER'
#!/bin/sh
exec /usr/bin/gcc -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"
WRAPPER
chmod +x "$WRAPPER_DIR/gcc"

# Symlink cc to gcc wrapper
ln -sf "$WRAPPER_DIR/gcc" "$WRAPPER_DIR/cc"

# G++ wrapper
cat > "$WRAPPER_DIR/g++" << 'WRAPPER'
#!/bin/sh
exec /usr/bin/g++ -D__TIME__="\"0\"" -D__DATE__="\"0\"" -D__TIMESTAMP__="\"0\"" -Wno-builtin-macro-redefined "$@"
WRAPPER
chmod +x "$WRAPPER_DIR/g++"