Commit 40ad00b
authored
[flang] Define array named constants from the iso_fortran_env intrins… (#201190)
…ic module
createIntrinsicModuleDefinitions() only emitted definitions for array
named constants belonging to the __fortran_ieee_exceptions intrinsic
module. Array constants declared directly in the iso_fortran_env
intrinsic module -- in practice character_kinds -- were therefore only
lowered as bodyless `fir.global` external declarations at their use site
and never defined anywhere, producing an undefined reference at link
time.
This is usually hidden because scalar iso_fortran_env parameters fold to
immediates and constant-shape array accesses are folded away, so the
dangling external symbol is DCE'd before linking. It surfaces when the
address of the array genuinely escapes to runtime, e.g.:
```
use iso_fortran_env
integer :: i, x(1)
do i = 1, size(character_kinds)
x = findloc(character_kinds, character_kinds(i))
end do
```
which fails with:
undefined reference to `_QMiso_fortran_envECcharacter_kinds'
Fix by also processing the iso_fortran_env scope in
createIntrinsicModuleDefinitions(), so its array constants are emitted
as linkonce_odr definitions with initializers.
Note that integer_kinds/real_kinds/logical_kinds are unaffected: they
are renamed from iso_fortran_env_impl, a non-intrinsic module that is
compiled into the runtime, so their definitions already exist there.
Assisted-by: AI1 parent 162076f commit 40ad00b
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6526 | 6526 | | |
6527 | 6527 | | |
6528 | 6528 | | |
6529 | | - | |
| 6529 | + | |
| 6530 | + | |
6530 | 6531 | | |
6531 | 6532 | | |
6532 | 6533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments