|
24 | 24 | # empty, then we will test both an optimized version (compiled with -O3) and a debugging version |
25 | 25 | # (compiled with -g -O0); otherwise, a version indicated by FFLAGS will be tested. |
26 | 26 | # |
| 27 | +# 4. `-Wl,-z,noexecstack` passes the `-z noexecstack` option to the linker and tells the linker to |
| 28 | +# set the "stack is not executable" attribute in the output file. If executable stacks are actually |
| 29 | +# needed, then it will lead to a runtime error. This is to test that our code does not require executable |
| 30 | +# stacks, which is a security risk. COBYLA used to use an internal subroutine passed as an actual |
| 31 | +# argument, which necessitates an executable stack with some compilers, but such code has been |
| 32 | +# removed on 20250812. See git commit 5e5e871 and |
| 33 | +# https://fortran-lang.discourse.group/t/implementation-of-a-parametrized-objective-function-without-using-module-variables-or-internal-subroutines |
27 | 34 | # Coded by Zaikun ZHANG (www.zhangzk.net). |
28 | 35 | # |
29 | 36 | # Started: September 2021 |
@@ -361,6 +368,7 @@ ifeq ($(TESTDIM),small) |
361 | 368 | endif |
362 | 369 | # Strangely, with `-Mchkptr`, the compiler may not print the error message of `-Mbounds` anymore. |
363 | 370 | DFORT := $(AFLANG) -std=f$(FSTD) -pedantic -Weverything -Wall -Wextra -Minform=warn -Mstandard -Mbounds -Mrecursive #-Kieee #-Mchkptr |
| 371 | +DFORT := $(DFORT) -Wl,-z,noexecstack |
364 | 372 |
|
365 | 373 | dtest_i2_r4_d1_tst_c dtest_i4_r4_d1_tst_c dtest_i8_r4_d1_tst_c dtest_i2_r4_d0_tst_c dtest_i4_r4_d0_tst_c dtest_i8_r4_d0_tst_c: \ |
366 | 374 | FCO := $(DFORT) $(FFLAGSO) |
|
397 | 405 | FFORT := $(FFORT) -fno-stack-arrays -mmlir -fdynamic-heap-array |
398 | 406 | endif |
399 | 407 | FFORT := $(FFORT) -std=f2018 -pedantic # As of flang 19.0, only -std=f2018 is supported |
| 408 | +FFORT := $(FFORT) -Wl,-z,noexecstack |
400 | 409 |
|
401 | 410 | ftest_i2_r4_d1_tst_c ftest_i4_r4_d1_tst_c ftest_i8_r4_d1_tst_c ftest_i2_r4_d0_tst_c ftest_i4_r4_d0_tst_c ftest_i8_r4_d0_tst_c: \ |
402 | 411 | FCO := $(FFORT) $(FFLAGSO) |
@@ -468,6 +477,7 @@ GFORT := $(GFORT) $(GFSTD) -fall-intrinsics -frecursive \ |
468 | 477 | -ftrapv |
469 | 478 | #-finit-real=nan -finit-integer=-9999999 # This will hide some warnings on uninitialized variables. |
470 | 479 | #-Wrealloc-lhs -Wrealloc-lhs-all |
| 480 | +GFORT := $(GFORT) -Wl,-z,noexecstack |
471 | 481 |
|
472 | 482 | gtest_i2_r4_d1_tst_c gtest_i4_r4_d1_tst_c gtest_i8_r4_d1_tst_c gtest_i2_r4_d0_tst_c gtest_i4_r4_d0_tst_c gtest_i8_r4_d0_tst_c: \ |
473 | 483 | FCO := $(GFORT) $(FFLAGSO) -Wno-function-elimination -ffpe-trap=zero |
|
514 | 524 | IFORT := $(IFORT) -auto -heap-arrays |
515 | 525 | endif |
516 | 526 | IFORT := $(IFORT) -standard-semantics -assume recursion -fimplicit-none |
| 527 | +IFORT := $(IFORT) -Wl,-z,noexecstack |
517 | 528 |
|
518 | 529 | itest_i2_r4_d1_tst_c itest_i4_r4_d1_tst_c itest_i8_r4_d1_tst_c itest_i2_r4_d0_tst_c itest_i4_r4_d0_tst_c itest_i8_r4_d0_tst_c: \ |
519 | 530 | FCO := $(IFORT) $(FFLAGSO) -fp-trap=divzero |
@@ -549,6 +560,7 @@ NFORT := $(NFORT) -I $(TESTSUITE_DIR) |
549 | 560 | NFORT := $(NFORT) -colour=error:red,warn:magenta,info:cyan |
550 | 561 | NFORT := $(NFORT) -f$(FSTD) -recursive -info -gline -u -C -C=alias -C=dangling -C=intovf -C=undefined -kind=unique \ |
551 | 562 | -Warn=constant_coindexing -Warn=subnormal #-Warn=allocation |
| 563 | +NFORT := $(NFORT) -Wl,-z,noexecstack |
552 | 564 |
|
553 | 565 | ntest_i2_r4_d1_tst_c ntest_i4_r4_d1_tst_c ntest_i8_r4_d1_tst_c ntest_i2_r4_d0_tst_c ntest_i4_r4_d0_tst_c ntest_i8_r4_d0_tst_c: \ |
554 | 566 | FCO := $(NFORT) $(FFLAGSO) -nan -ieee=full |
|
582 | 594 | VFORT := $(VFORT) -Mnostack_arrays |
583 | 595 | endif |
584 | 596 | VFORT := $(VFORT) -C -Wall -Wextra -Minform=warn -Mstandard -Mrecursive -Mbounds -Mchkstk -Mchkptr -traceback |
| 597 | +VFORT := $(VFORT) -Wl,-z,noexecstack |
585 | 598 |
|
586 | 599 | vtest_i2_r4_d1_tst_c vtest_i4_r4_d1_tst_c vtest_i8_r4_d1_tst_c vtest_i2_r4_d0_tst_c vtest_i4_r4_d0_tst_c vtest_i8_r4_d0_tst_c: \ |
587 | 600 | FCO := $(VFORT) $(FFLAGSO) #-Ktrap=divz #-Kieee |
|
614 | 627 | RFORT := $(RFORT) -fno-stack-arrays |
615 | 628 | endif |
616 | 629 | RFORT := $(RFORT) -std=f$(FSTD) -pedantic -Weverything -Wall -Wextra -Minform=warn -Mstandard -Mrecursive -Mbounds -Mchkptr #-Kieee |
| 630 | +RFORT := $(RFORT) -Wl,-z,noexecstack |
617 | 631 |
|
618 | 632 | rtest_i2_r4_d1_tst_c rtest_i4_r4_d1_tst_c rtest_i8_r4_d1_tst_c rtest_i2_r4_d0_tst_c rtest_i4_r4_d0_tst_c rtest_i8_r4_d0_tst_c: \ |
619 | 633 | FCO := $(RFORT) $(FFLAGSO) |
@@ -643,6 +657,7 @@ ifeq ($(TESTDIM),small) |
643 | 657 | SFORT := $(SFORT) -stackvar # Force all automatic arrays to be on the stack to test whether stack overflow can occur |
644 | 658 | endif |
645 | 659 | SFORT := $(SFORT) -w3 -u -U -ansi -xcheck=%all -C |
| 660 | +SFORT := $(SFORT) -Wl,-z,noexecstack |
646 | 661 |
|
647 | 662 | stest_i2_r4_d1_tst_c stest_i4_r4_d1_tst_c stest_i8_r4_d1_tst_c stest_i2_r4_d0_tst_c stest_i4_r4_d0_tst_c stest_i8_r4_d0_tst_c: \ |
648 | 663 | FCO := $(SFORT) $(FFLAGSO) -fnonstd -ftrap=division |
|
682 | 697 | XFORT := $(XFORT) -auto -heap-arrays |
683 | 698 | endif |
684 | 699 | XFORT := $(XFORT) -standard-semantics -assume recursion -fimplicit-none |
| 700 | +XFORT := $(XFORT) -Wl,-z,noexecstack |
685 | 701 |
|
686 | 702 | # In the following, `-check all,nouninit` can be changed to `-check all` later, probably with OneAPI 2024.1. See |
687 | 703 | # https://community.intel.com/t5/Intel-Fortran-Compiler/ifx-missing-clang-rt-msan-to-link-Fortran-program-in-debug-build/m-p/1533430 |
@@ -723,6 +739,7 @@ xtest_i2_r16_d1_tst_c xtest_i4_r16_d1_tst_c xtest_i8_r16_d1_tst_c xtest_i2_r16_d |
723 | 739 | -Werror=100,113,115,137,146,147,159,163 \ |
724 | 740 | -Wimplicit-none -Wline-truncation -Wprecision-loss -Wunused-module-vars -Wunused-vars -Wunset-vars \ |
725 | 741 | -fimplicit-none -fbounds-check -ftrace=full -freal=nan -fmodule-private |
| 742 | +9FORT := $(9FORT) -Wl,-z,noexecstack |
726 | 743 |
|
727 | 744 | 9test_i2_r4_d1_tst_c 9test_i4_r4_d1_tst_c 9test_i8_r4_d1_tst_c 9test_i2_r4_d0_tst_c 9test_i4_r4_d0_tst_c 9test_i8_r4_d0_tst_c: \ |
728 | 745 | FCO := $(9FORT) $(FFLAGSO) |
|
0 commit comments