Skip to content

Fix bash syntax in Makefile.hipfort that breaks environment variable inheritance#296

Open
marikurz-amd wants to merge 1 commit into
developfrom
users/marikurz/fix.Makefile
Open

Fix bash syntax in Makefile.hipfort that breaks environment variable inheritance#296
marikurz-amd wants to merge 1 commit into
developfrom
users/marikurz/fix.Makefile

Conversation

@marikurz-amd

Copy link
Copy Markdown

Motivation

The Makefile.hipfort uses bash shell parameter expansion syntax (${VAR:-default}) for setting default values, which does not work in GNU Make. This causes ROCM_PATH, CUDA_PATH, and HIP_PLATFORM to become empty strings instead of inheriting values from the environment or using their defaults.

This bug prevents users from using hipfort with just module load rocm - they must explicitly pass ROCM_PATH on the command line as a workaround.

Technical Details

bin/Makefile.hipfort

Replace bash parameter expansion syntax with proper Make conditional assignment (?=):

-CUDA_PATH=${CUDA_PATH:-/usr/local/cuda}
-ROCM_PATH=${ROCM_PATH:-/opt/rocm}
-HIP_PLATFORM=${HIP_PLATFORM:-amd}
+CUDA_PATH ?= /usr/local/cuda
+ROCM_PATH ?= /opt/rocm
+HIP_PLATFORM ?= amd

Why this matters:

  • ${VAR:-default} is bash syntax that Make interprets as a variable named VAR:-default, which doesn't exist, resulting in an empty string
  • VAR ?= default is proper Make syntax meaning "set VAR to default only if not already defined"

Submission Checklist

…inheritance

Replace bash parameter expansion syntax (e.g., ${VAR:-default}) with
proper Make conditional assignment (?=). The bash syntax doesn't work
in GNU Make, causing ROCM_PATH, CUDA_PATH, and HIP_PLATFORM to become
empty strings instead of inheriting values from the environment.

Made-with: Cursor
@marikurz-amd marikurz-amd requested a review from cgmb as a code owner April 13, 2026 08:22
@ronlieb ronlieb self-requested a review May 25, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants