Skip to content

[flang-rt][cuda] Fix the aarch64 build of the runtime with CUDA 12.0 - #239488

Merged
clementval merged 1 commit into
llvm:mainfrom
clementval:flanr_rt_cuda120
Nov 6, 2026
Merged

clementval merged 1 commit into
llvm:mainfrom
clementval:flanr_rt_cuda120

Conversation

@clementval

Copy link
Copy Markdown
Contributor

On aarch64, glibc's <fpu_control.h> defines _FPU_GETCW and _FPU_SETCW
as __builtin_aarch64_get_fpcr() and __builtin_aarch64_set_fpcr() when the
compiler reports GCC 6 or later. nvcc 12.0 reports the host GCC version but
does not recognize these builtins, so building flang-rt with
FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA fails on aarch64:

flang-rt/lib/runtime/exceptions.cpp(205): error: identifier "__builtin_aarch64_get_fpcr" is undefined
flang-rt/lib/runtime/exceptions.cpp(216): error: identifier "__builtin_aarch64_get_fpcr" is undefined
flang-rt/lib/runtime/exceptions.cpp(222): error: identifier "__builtin_aarch64_set_fpcr" is undefined

With nvcc 12.0 on aarch64, read and write FPCR with mrs/msr inline
assembly, which is what glibc itself uses for compilers older than GCC 6.
Other compilers and CUDA versions keep using _FPU_GETCW/_FPU_SETCW
unchanged.

@vzakhari vzakhari 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.

Thank you, Valentin!

@clementval
clementval merged commit bf51440 into llvm:main Nov 6, 2026
12 checks passed
@clementval
clementval deleted the flanr_rt_cuda120 branch November 6, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants