llvm / llvm/llvm-project

[flang] Linker error when calling ieee_set_halting_mode from a subroutine

Open
#177,849 1 comment 0 reactions 0 assignees View on GitHub
flang
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Dear all,
when I compile this minimal example
```fortran
use, intrinsic :: ieee_exceptions
call foo ( .false. )
contains
subroutine foo ( ieee_halting )
logical, intent(in) :: ieee_halting
if ( ieee_support_halting(ieee_overflow) ) &
call ieee_set_halting_mode ( ieee_overflow, halting = ieee_halting )
end subroutine foo
end
```
I get this error :
```
flang truc.f90
Undefined symbols for architecture arm64:
"_fedisableexcept", referenced from:
__QFPfoo in truc-917008.o
"_feenableexcept", referenced from:
__QFPfoo in truc-917008.o
"_fegetexcept", referenced from:
__QFPfoo in truc-917008.o
ld: symbol(s) not found for architecture arm64
flang-21: error: linker command failed with exit code 1 (use -v to see invocation)
```
```
flang --version
Homebrew flang version 21.1.8
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/flang/21.1.8/libexec
Configuration file: /opt/homebrew/Cellar/flang/21.1.8/libexec/flang.cfg
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg
```

The issue goes away if ieee_set_halting_mode is called directly from the main program :
```
use, intrinsic :: ieee_exceptions
logical :: ieee_halting = .false.
if ( ieee_support_halting(ieee_overflow) ) &
call ieee_set_halting_mode ( ieee_overflow, halting = ieee_halting )
end
```

Contributor guide

Open the contributing guide

Research direction

Start with the minimal Fortran example and the flang --version details in the issue, reproducing it on arm64-apple-darwin24.6.0. Investigate how ieee_set_halting_mode is linked when called from a subroutine versus the main program; done means the example links and runs without the undefined fedisableexcept, feenableexcept, and fegetexcept symbols.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.