Created
March 5, 2026 14:22
-
-
Save mathomp4/b073a15ca4eaea4bdcc0cad00266cadb to your computer and use it in GitHub Desktop.
Flang Label Reproducer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # ---- config ---- | |
| FLANG="${FLANG:-flang}" | |
| FLAGS=(-O0 -g -fno-integrated-as -save-temps=obj) | |
| OUTDIR="${OUTDIR:-obj}" | |
| MAX=8 | |
| mkdir -p "$OUTDIR" | |
| # header | |
| printf "%-6s | %-10s | %-4s | %s\n" "spaces" "label_col" "rc" "result" | |
| printf "%s\n" "-------+------------+------+------------------------------" | |
| tsv="$OUTDIR/results.tsv" | |
| printf "spaces\tlabel_col\trc\tresult\n" > "$tsv" | |
| for n in $(seq 0 $MAX); do | |
| f="$OUTDIR/repro_indent_${n}.F90" | |
| o="$OUTDIR/repro_indent_${n}.o" | |
| log="$OUTDIR/repro_indent_${n}.log" | |
| # Generate source | |
| { | |
| echo "write(*, fmt=101) 12" | |
| printf "%*s101 format(i0)\n" "$n" "" | |
| echo "end" | |
| } > "$f" | |
| # Compile | |
| set +e | |
| "$FLANG" "${FLAGS[@]}" -c "$f" -o "$o" >"$log" 2>&1 | |
| rc=$? | |
| set -e | |
| # Determine label column (1-indexed). If there are n leading spaces, '1' is at col n+1. | |
| label_col=$((n + 1)) | |
| if (( rc == 0 )); then | |
| result="OK" | |
| else | |
| # Try to pull the most relevant error line if present | |
| if grep -q "Label '101' was not found" "$log"; then | |
| result="FAIL: label 101 not found" | |
| elif grep -q "unknown integrated tool '-cc1as'" "$log"; then | |
| result="FAIL: cc1as (save-temps)" | |
| else | |
| # first error-ish line | |
| errline="$(grep -m1 -E 'error:|fatal error:' "$log" | sed 's/[[:space:]]\+/ /g')" | |
| result="FAIL: ${errline:-see log}" | |
| fi | |
| fi | |
| printf "%-6s | %-10s | %-4s | %s\n" "$n" "$label_col" "$rc" "$result" | |
| printf "%s\t%s\t%s\t%s\n" "$n" "$label_col" "$rc" "$result" >> "$tsv" | |
| done | |
| echo | |
| echo "Wrote:" | |
| echo " Sources/logs: $OUTDIR/repro_indent_*.F90 / .log" | |
| echo " Table TSV: $tsv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment