Skip to content

build: support amdflang (LLVMFlang) CPU builds via non-PIE link#1635

Merged
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:feature/amdflang-cpu
Jul 9, 2026
Merged

build: support amdflang (LLVMFlang) CPU builds via non-PIE link#1635
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:feature/amdflang-cpu

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

Summary

Adds an LLVMFlang branch to the compiler dispatch in cmake/GPU.cmake so amdflang (AMD's LLVM-based flang, which CMake identifies as LLVMFlang, distinct from classic Flang) can build the CPU targets.

Previously amdflang matched no branch in GPU.cmake, so a CPU build received no compiler-appropriate flags and Debug/RelDebug failed to link:

ld.lld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC

ld.lld defaults to producing a PIE, but the static dependencies (e.g. libfftw3) are not built -fPIC. The new branch links a non-PIE executable for the non-LTO build types, which accepts those objects.

Scope / safety

  • Gated on NOT (MFC_OpenMP OR MFC_OpenACC), so the merged OpenMP-offload GPU path (Add AMD HPCFund (amdfund) amdflang OpenMP-offload build/run support #1632) is untouched — it sets its own flags in MFCTargets.cmake and links via the offload wrapper.
  • Only affects Debug/RelDebug. Release is unchanged — it already linked, via LTO's link-time PIC codegen.
  • Verified on AMD HPCFund (MI250X node, amdflang from rocm/7.2.0): simulation CPU Debug and Release both build clean.

Caveats

Copilot AI review requested due to automatic review settings July 9, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the build-system compiler dispatch to recognize CMake’s LLVMFlang Fortran compiler ID (as used by AMD’s amdflang) and applies a non-PIE link for CPU-only Debug/RelDebug builds to avoid ld.lld PIE relocation failures when linking against non-PIC static dependencies.

Changes:

  • Add a new LLVMFlang compiler branch in cmake/GPU.cmake.
  • For CPU-only (NOT (MFC_OpenMP OR MFC_OpenACC)) Debug/RelDebug builds, add -no-pie at link time and apply -O1 -g compile options.

@sbryngelson sbryngelson merged commit c2fc9fa into MFlowCode:master Jul 9, 2026
30 checks passed
drcole17 added a commit to cmtl-wpi/MFC-drcole that referenced this pull request Jul 9, 2026
Sync 8 upstream commits: BC-routine unification (MFlowCode#1629), synthetic
turbulence (MFlowCode#1548), extrusion v3 (MFlowCode#1349), amdflang CPU builds (MFlowCode#1635),
batched example validation (MFlowCode#1634).

Conflicts (all 'both added, keep both'):
- m_global_parameters_common.fpp: thermal_conduction + synthetic_turbulence GPU_DECLAREs
- m_checker.fpp: thermal_conduction/visc_model + synthetic_turbulence checks
- m_start_up.fpp: conduction finalize + broadened body-forces finalize condition

Verified: all 3 targets build+install on gfortran CPU.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants