Skip to content

Commit fd9e6ae

Browse files
committed
260206.061707.CET add comments to CMakelist.txt
1 parent a3a6db6 commit fd9e6ae

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ option (BUILD_SHARED_LIBS "shared/static" ON)
99
include (GNUInstallDirs)
1010

1111
# the compiler enables an executable stack because of nested functions and this is fine
12+
# Zaikun 20260206: Is this still fined and needed? See commit 5e5e8716e709c4e534ccc1a916a15b7f89676ed3
13+
# executable stacks are not allowed by glibc 2.4+; see
14+
# https://fortran-lang.discourse.group/t/implementation-of-a-parametrized-objective-function-without-using-module-variables-or-internal-subroutines,
15+
# https://github.com/JuliaLang/julia/issues/57250, https://forums.gentoo.org/viewtopic-p-8866168.html
16+
# We should probably do the opposite: use `-Wl,-z,noexecstack` to pass the `-z noexecstack` option
17+
# to the linker and tells the linker to set the "stack is not executable" attribute in the output file.
1218
if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
1319
include (CheckLinkerFlag)
1420
check_linker_flag (Fortran "-Wl,--no-warn-execstack" HAVE_WARN_EXECSTACK)
@@ -20,6 +26,7 @@ endif ()
2026
# slower (does not matter for DFO applications) but can avoid memory errors on large problems.
2127
# 2. We require the compilers to compile the solvers so that they can be called recursively.
2228
# See https://fortran-lang.discourse.group/t/frecursive-assume-recursion-and-recursion-thread-safety
29+
# 3. Zaikun 20260206: Is the ID for ARM Flang correct? What about the AMD AOMP Flang?
2330
option (PRIMA_HEAP_ARRAYS "allocate arrays on heap" ON)
2431
if (PRIMA_HEAP_ARRAYS)
2532
if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU") # gfortran
@@ -37,8 +44,10 @@ if (PRIMA_HEAP_ARRAYS)
3744
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-stack-arrays -mmlir -fdynamic-heap-array")
3845
elseif (CMAKE_Fortran_COMPILER_ID MATCHES "Flang") # Classic Flang and AOCC Flang
3946
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive")
40-
elseif (CMAKE_Fortran_COMPILER_ID MATCHES "ARMClang") # ARM Flang
41-
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-stack-arrays -Mrecursive")
47+
elseif (CMAKE_Fortran_COMPILER_ID MATCHES "ARMClang") # ARM Flang (Zaikun 20260206: is the ID correct?)
48+
# N.B.: `-mmlir -fdynamic-heap-array` is needed; see
49+
# https://github.com/libprima/prima/commit/6e0963c210129273964aa6ea822fc52bd4736974
50+
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-stack-arrays -mmlir -fdynamic-heap-array")
4251
elseif (CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC") # nvfortran
4352
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mnostack_arrays -Mrecursive")
4453
endif ()

0 commit comments

Comments
 (0)