Skip to content

Commit 42a4c06

Browse files
committed
feat: improve WASM installation with macOS-like environment setup
- Add comprehensive environment variables (CC, CXX, AR, NM, RANLIB, STRIP) - Set WASI_SYSROOT and toolchain paths properly - Add fallback installation method with --no-set flag - Mirror successful macOS setup approach - Better debugging output for environment variables - This should resolve the configure failures by providing proper toolchain environment
1 parent e3f5b40 commit 42a4c06

1 file changed

Lines changed: 38 additions & 16 deletions

File tree

build_context/Dockerfile.haskell

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,59 @@ RUN echo "🔧 Setting up WASM toolchain via ghcup..." && \
5656
curl https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/bootstrap.sh | SKIP_GHC=1 sh && \
5757
# Add WASM release channel to ghcup
5858
ghcup config add-release-channel https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/ghcup-wasm-0.0.9.yaml && \
59-
# Set up environment for WASM toolchain
59+
# Set up environment for WASM toolchain (similar to macOS setup)
6060
export PATH="${HOME}/.ghc-wasm/wasi-sdk/bin:$PATH" && \
61+
export WASI_SYSROOT="${HOME}/.ghc-wasm/wasi-sdk/share/wasi-sysroot" && \
62+
export CC="${HOME}/.ghc-wasm/wasi-sdk/bin/clang" && \
63+
export CXX="${HOME}/.ghc-wasm/wasi-sdk/bin/clang++" && \
64+
export AR="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-ar" && \
65+
export NM="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-nm" && \
66+
export RANLIB="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-ranlib" && \
67+
export STRIP="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-strip" && \
6168
# Create missing tool symlinks that the configure script expects
6269
ln -sf ~/.ghc-wasm/wasi-sdk/bin/nm ~/.ghc-wasm/wasi-sdk/bin/wasm32-wasi-nm && \
6370
ln -sf ~/.ghc-wasm/wasi-sdk/bin/strip ~/.ghc-wasm/wasi-sdk/bin/wasm32-wasi-strip && \
6471
# Debug: Check what tools are available
6572
echo "🔍 Debug: Checking WASM tools..." && \
6673
ls -la ~/.ghc-wasm/wasi-sdk/bin/ | grep -E "(nm|strip|clang|wasm)" && \
67-
echo "🔍 Debug: PATH contains:" && \
68-
echo "$PATH" | tr ':' '\n' | grep -E "(ghc-wasm|wasi)" && \
69-
# Try WASM GHC installation with verbose output and capture logs
74+
echo "🔍 Debug: Environment variables:" && \
75+
echo "PATH: $PATH" | tr ':' '\n' | grep -E "(ghc-wasm|wasi)" && \
76+
echo "WASI_SYSROOT: $WASI_SYSROOT" && \
77+
echo "CC: $CC" && \
78+
echo "CXX: $CXX" && \
79+
# Try WASM GHC installation with proper environment
7080
echo "🔧 Attempting WASM GHC installation..." && \
7181
if ghcup install ghc wasm32-wasi-9.12.20250327 --verbose; then \
7282
echo "✅ WASM GHC toolchain installed successfully"; \
7383
else \
74-
echo "⚠️ WASM GHC installation failed, capturing detailed logs..." && \
75-
echo "📋 GHCup logs directory:" && \
76-
ls -la /home/dev/.ghcup/logs/ 2>/dev/null || echo "No logs directory found" && \
77-
echo "📋 Recent log files:" && \
78-
find /home/dev/.ghcup/logs/ -name "*.log" -type f -exec ls -la {} \; 2>/dev/null | tail -10 || echo "No log files found" && \
79-
echo "📋 Latest log content:" && \
80-
find /home/dev/.ghcup/logs/ -name "*.log" -type f -exec tail -50 {} \; 2>/dev/null | head -100 || echo "No log content found" && \
81-
echo "📋 Config.log from GHC installation (if exists):" && \
82-
find /home/dev/.ghcup/tmp/ -name "config.log" -type f -exec cat {} \; 2>/dev/null | head -100 || echo "No config.log found" && \
83-
echo "⚠️ Continuing without WASM GHC - you can install it manually later" && \
84-
echo "💡 To install manually: ghcup install ghc wasm32-wasi-9.12.20250327"; \
84+
echo "⚠️ WASM GHC installation failed, trying alternative approach..." && \
85+
# Try without explicit host specification (let ghcup auto-detect)
86+
if ghcup install ghc wasm32-wasi-9.12.20250327 --verbose --no-set; then \
87+
echo "✅ WASM GHC toolchain installed successfully (alternative method)"; \
88+
else \
89+
echo "⚠️ WASM GHC installation failed, capturing detailed logs..." && \
90+
echo "📋 GHCup logs directory:" && \
91+
ls -la /home/dev/.ghcup/logs/ 2>/dev/null || echo "No logs directory found" && \
92+
echo "📋 Recent log files:" && \
93+
find /home/dev/.ghcup/logs/ -name "*.log" -type f -exec ls -la {} \; 2>/dev/null | tail -10 || echo "No log files found" && \
94+
echo "📋 Latest log content:" && \
95+
find /home/dev/.ghcup/logs/ -name "*.log" -type f -exec tail -50 {} \; 2>/dev/null | head -100 || echo "No log content found" && \
96+
echo "📋 Config.log from GHC installation (if exists):" && \
97+
find /home/dev/.ghcup/tmp/ -name "config.log" -type f -exec cat {} \; 2>/dev/null | head -100 || echo "No config.log found" && \
98+
echo "⚠️ Continuing without WASM GHC - you can install it manually later" && \
99+
echo "💡 To install manually: ghcup install ghc wasm32-wasi-9.12.20250327"; \
100+
fi; \
85101
fi
86102

87103
# Set up WASM environment variables for all sessions
88104
RUN echo 'export PATH="${HOME}/.ghc-wasm/wasi-sdk/bin:$PATH"' >> ~/.bashrc && \
89-
echo 'export WASI_SYSROOT="${HOME}/.ghc-wasm/wasi-sdk/share/wasi-sysroot"' >> ~/.bashrc
105+
echo 'export WASI_SYSROOT="${HOME}/.ghc-wasm/wasi-sdk/share/wasi-sysroot"' >> ~/.bashrc && \
106+
echo 'export CC="${HOME}/.ghc-wasm/wasi-sdk/bin/clang"' >> ~/.bashrc && \
107+
echo 'export CXX="${HOME}/.ghc-wasm/wasi-sdk/bin/clang++"' >> ~/.bashrc && \
108+
echo 'export AR="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-ar"' >> ~/.bashrc && \
109+
echo 'export NM="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-nm"' >> ~/.bashrc && \
110+
echo 'export RANLIB="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-ranlib"' >> ~/.bashrc && \
111+
echo 'export STRIP="${HOME}/.ghc-wasm/wasi-sdk/bin/llvm-strip"' >> ~/.bashrc
90112

91113
ENV PATH="/home/dev/.cabal/bin:/home/dev/.ghcup/bin:/home/dev/.local/bin:$PATH"
92114
# Install Ormolu (Haskell formatter) as binary

0 commit comments

Comments
 (0)