Skip to content

Commit 5614737

Browse files
authored
Merge pull request #530 from gareth-nx/pr/readme_updates
Make it clearer how the user can control compiler optimization
2 parents 8bfcdf9 + dba123d commit 5614737

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Makefile.manual

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Fortran stdlib Makefile
22

3-
FC = gfortran
4-
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
5-
FYPPFLAGS=
3+
FC ?= gfortran
4+
FFLAGS ?= -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
5+
FYPPFLAGS ?=
66

77
export FC
88
export FFLAGS

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ Important options are
134134
Compiling with maximum rank 15 can be resource intensive and requires at least 16 GB of memory to allow parallel compilation or 4 GB memory for sequential compilation.
135135
- `-DBUILD_SHARED_LIBS` set to `on` in case you want link your application dynamically against the standard library (default: `off`).
136136

137-
For example, to configure a build using the Ninja backend and generating procedures up to rank 7, which is installed to your home directory use
137+
For example, to configure a build using the Ninja backend while specifying compiler flags `FFLAGS`, generating procedures up to rank 7, and installing to your home directory, use
138138

139139
```sh
140+
export FFLAGS="-O3"
140141
cmake -B build -G Ninja -DCMAKE_MAXIMUM_RANK:String=7 -DCMAKE_INSTALL_PREFIX=$HOME/.local
141142
```
142143

@@ -162,6 +163,10 @@ cmake --install build
162163

163164
Now you have a working version of stdlib you can use for your project.
164165

166+
If at some point you wish to recompile `stdlib` with different options, you might
167+
want to delete the `build` folder. This will ensure that cached variables from
168+
earlier builds do not affect the new build.
169+
165170

166171
### Build with make
167172

@@ -177,6 +182,11 @@ You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``FYPPFLAGS
177182
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
178183
```
179184

185+
You can also specify the compiler and compiler-flags by setting the ``FC`` and ``FFLAGS`` environmental variables. Among other things, this facilitates use of compiler optimizations that are not specified in the Makefile.manual defaults.
186+
```sh
187+
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4 FC=gfortran FFLAGS="-O3 -flto"
188+
```
189+
180190
### Build with [fortran-lang/fpm](https://github.com/fortran-lang/fpm)
181191

182192
Fortran Package Manager (fpm) is a package manager and build system for Fortran.

0 commit comments

Comments
 (0)