You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial_configuration.rst
+62-76Lines changed: 62 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,58 +147,59 @@ YAML Format
147
147
-----------
148
148
149
149
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.
151
151
Spack generally maintains a separate file for each section, although environments keep them together (in ``spack.yaml``).
152
152
153
153
When Spack checks its configuration, the configuration scopes are updated as dictionaries in increasing order of precedence, allowing higher precedence files to override lower.
154
154
YAML dictionaries use a colon ":" to specify key-value pairs.
155
155
Spack extends YAML syntax slightly to allow a double-colon "::" to specify a key-value pair.
156
156
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:
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
179
192
180
193
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:
182
195
183
196
.. code-block:: yaml
184
197
185
198
spack:
186
199
specs: []
187
200
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:: {}
202
203
203
204
204
205
.. _configs-tutorial-compilers:
@@ -212,57 +213,42 @@ As discussed in the basic installation tutorial, we can also tell Spack where co
212
213
However, in some circumstances, we want even more fine-grained control over the compilers available.
213
214
This section will teach you how to exercise that control using the compilers configuration file.
214
215
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):
216
217
217
218
.. code-block:: console
218
219
219
-
$ spack config edit compilers
220
+
$ spack config edit packages
220
221
221
222
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):
223
224
224
225
.. code-block:: yaml
225
226
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++
266
252
267
253
This specifies two versions of the GCC compiler and one version of the Clang compiler with no Flang compiler.
268
254
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