Skip to content

Commit c89aa2c

Browse files
committed
partial updates
1 parent 579ce02 commit c89aa2c

1 file changed

Lines changed: 62 additions & 76 deletions

File tree

tutorial_configuration.rst

Lines changed: 62 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -147,58 +147,59 @@ YAML Format
147147
-----------
148148

149149
Spack configurations are nested YAML dictionaries with a specified schema.
150-
The configuration is organized into sections based on theme (e.g., a 'compilers' section) and the highest-level keys of the dictionary specify the section.
150+
The configuration is organized into sections based on theme (e.g., a 'packages' section) and the highest-level keys of the dictionary specify the section.
151151
Spack generally maintains a separate file for each section, although environments keep them together (in ``spack.yaml``).
152152

153153
When Spack checks its configuration, the configuration scopes are updated as dictionaries in increasing order of precedence, allowing higher precedence files to override lower.
154154
YAML dictionaries use a colon ":" to specify key-value pairs.
155155
Spack extends YAML syntax slightly to allow a double-colon "::" to specify a key-value pair.
156156
When a double-colon is used, instead of adding that section, Spack replaces what was in that section with the new value.
157-
For example, consider a user's compilers configuration file as follows:
157+
For example, look at high-level config:
158+
159+
.. code-block:: console
160+
161+
$ spack config blame config
158162
159163
.. code-block:: yaml
160164
161-
compilers::
162-
- compiler:
163-
spec: gcc@11.4.0
164-
paths:
165-
cc: /usr/bin/gcc
166-
cxx: /usr/bin/g++
167-
f77: /usr/bin/gfortran
168-
fc: /usr/bin/gfortran
169-
flags: {}
170-
operating_system: ubuntu22.04
171-
target: x86_64
172-
modules: []
173-
environment: {}
174-
extra_rpaths: []
165+
--- config:
166+
/etc/spack/config.yaml:2 suppress_gpg_warnings: True
167+
/home/spack/spack/etc/spack/defaults/config.yaml:19 install_tree:
168+
/home/spack/spack/etc/spack/defaults/config.yaml:20 root: $spack/opt/spack
169+
...
170+
/home/spack/spack/etc/spack/defaults/config.yaml:238 aliases:
171+
/home/spack/spack/etc/spack/defaults/config.yaml:239 concretise: concretize
172+
/home/spack/spack/etc/spack/defaults/config.yaml:240 containerise: containerize
173+
/home/spack/spack/etc/spack/defaults/config.yaml:241 rm: remove
174+
175+
We can see overrides in action with:
175176

177+
.. code-block:: console
176178
177-
This ensures that no other compilers are used, as the user configuration scope is the last scope searched and the ``compilers::`` line replaces information from all previous configuration files.
178-
If the same configuration file had a single colon instead of the double colon, it would add the GCC version 11.3.0 compiler to whatever other compilers were listed in other configuration files.
179+
$ spack config add config:aliases::{}
180+
$ spack config blame config
181+
182+
.. code-block:: yaml
183+
--- config:
184+
/home/spack/.spack/config.yaml:2 aliases: {}
185+
186+
The default write scope is the user scope, which overrides the defaults.
187+
You can undo this by editing the config section like:
188+
189+
.. code-block:: console
190+
191+
$ spack config edit config
179192
180193
A configuration section appears nearly the same when managed in an environment's ``spack.yaml`` file except that the section is nested 1 level underneath the top-level 'spack' key.
181-
For example the above ``compilers.yaml`` could be incorporated into an environment's ``spack.yaml`` like so:
194+
For example the above ``config.yaml`` could be incorporated into an environment's ``spack.yaml`` like so:
182195

183196
.. code-block:: yaml
184197
185198
spack:
186199
specs: []
187200
view: true
188-
compilers::
189-
- compiler:
190-
spec: gcc@11.4.0
191-
paths:
192-
cc: /usr/bin/gcc
193-
cxx: /usr/bin/g++
194-
f77: /usr/bin/gfortran
195-
fc: /usr/bin/gfortran
196-
flags: {}
197-
operating_system: ubuntu22.04
198-
target: x86_64
199-
modules: []
200-
environment: {}
201-
extra_rpaths: []
201+
config:
202+
aliases:: {}
202203
203204
204205
.. _configs-tutorial-compilers:
@@ -212,57 +213,42 @@ As discussed in the basic installation tutorial, we can also tell Spack where co
212213
However, in some circumstances, we want even more fine-grained control over the compilers available.
213214
This section will teach you how to exercise that control using the compilers configuration file.
214215

215-
We will start by opening the compilers configuration file:
216+
We will start by opening the compilers configuration (which lives in the packages section):
216217

217218
.. code-block:: console
218219
219-
$ spack config edit compilers
220+
$ spack config edit packages
220221
221222
222-
We start with no active environment, so this will open a ``compilers.yaml`` file for editing (you can also do this with an active environment):
223+
We start with no active environment, so this will open a ``packages.yaml`` file for editing (you can also do this with an active environment):
223224

224225
.. code-block:: yaml
225226
226-
compilers:
227-
- compiler:
228-
spec: clang@=14.0.0
229-
paths:
230-
cc: /usr/bin/clang
231-
cxx: /usr/bin/clang++
232-
f77:
233-
fc:
234-
flags: {}
235-
operating_system: ubuntu22.04
236-
target: x86_64
237-
modules: []
238-
environment: {}
239-
extra_rpaths: []
240-
- compiler:
241-
spec: gcc@=10.5.0
242-
paths:
243-
cc: /usr/bin/gcc-10
244-
cxx: /usr/bin/g++-10
245-
f77: /usr/bin/gfortran-10
246-
fc: /usr/bin/gfortran-10
247-
flags: {}
248-
operating_system: ubuntu22.04
249-
target: x86_64
250-
modules: []
251-
environment: {}
252-
extra_rpaths: []
253-
- compiler:
254-
spec: gcc@=11.4.0
255-
paths:
256-
cc: /usr/bin/gcc
257-
cxx: /usr/bin/g++
258-
f77: /usr/bin/gfortran
259-
fc: /usr/bin/gfortran
260-
flags: {}
261-
operating_system: ubuntu22.04
262-
target: x86_64
263-
modules: []
264-
environment: {}
265-
extra_rpaths: []
227+
packages:
228+
gcc:
229+
externals:
230+
- spec: gcc@10.5.0 languages:='c,c++,fortran'
231+
prefix: /usr
232+
extra_attributes:
233+
compilers:
234+
c: /usr/bin/gcc-10
235+
cxx: /usr/bin/g++-10
236+
fortran: /usr/bin/gfortran-10
237+
- spec: gcc@11.4.0 languages:='c,c++,fortran'
238+
prefix: /usr
239+
extra_attributes:
240+
compilers:
241+
c: /usr/bin/gcc
242+
cxx: /usr/bin/g++
243+
fortran: /usr/bin/gfortran
244+
llvm:
245+
externals:
246+
- spec: llvm@14.0.0+clang~flang~lld~lldb
247+
prefix: /usr
248+
extra_attributes:
249+
compilers:
250+
c: /usr/bin/clang
251+
cxx: /usr/bin/clang++
266252
267253
This specifies two versions of the GCC compiler and one version of the Clang compiler with no Flang compiler.
268254
Now suppose we have a code that we want to compile with the Clang compiler for C/C++ code, but with gfortran for Fortran components.

0 commit comments

Comments
 (0)