Repository: spack/spack

Issue:
Unsolicited warnings related to Intel compilers
I observe unsolicited warnings related to Intel compilers even though I don't specify anything like `%intel` on the command line.

### Steps to reproduce the issue

<details>
<summary>
<strong><code>spack solve</code></strong>
</summary>

```
==> Warning: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
==> Best of 1 considered solutions.
==> Optimization Criteria:
  Priority  Criterion                                            Value
  1         version weight                                           0
  2         number of non-default variants (roots)                   0
  3         multi-valued variants + preferred providers for roots    0
  4         number of non-default variants (non-roots)               0
  5         number of non-default providers (non-roots)              0
  6         count of non-root multi-valued variants                  0
  7         compiler matches + number of nodes                       0
  8         version badness                                          0
  9         non-preferred compilers                                  0
  10        target matches                                           0
  11        non-preferred targets                                    0
```
</details>

### Error Message

<!-- If Spack reported an error, provide the error message. If it did not report an error but the output appears incorrect, provide the incorrect output. If there was no error message and no output but the result is incorrect, describe how it does not match what you expect. -->

<details>
<summary>
<strong><code>spack --debug --stacktrace solve</code></strong>
</summary>

```
lib/spack/spack/util/executable.py:182 ==> [2021-04-05-14:22:59.744364] '/bin/bash' '--norc' '--noprofile' '-lc' 'echo $CRAY_CPU_TARGET'
lib/spack/spack/platforms/cray.py:154 ==> [2021-04-05-14:22:59.763458] default to front-end architecture
lib/spack/spack/cmd/__init__.py:122 ==> [2021-04-05-14:23:00.906830] Imported solve from built-in commands
lib/spack/spack/cmd/__init__.py:122 ==> [2021-04-05-14:23:00.909005] Imported solve from built-in commands
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:01.219739] Reading config file /dev/shm/spack/test/etc/spack/compilers.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:03.008165] Reading config file /dev/shm/spack/test/etc/spack/defaults/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:03.080323] Reading config file /dev/shm/spack/test/etc/spack/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:03.090397] Reading config file /u/staff/mbelkin/.spack/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:03.139487] Reading config file /dev/shm/spack/test/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:03.249287] Reading config file /dev/shm/spack/test/etc/spack/packages.yaml
dev/shm/spack/test/lib/spack/spack/main.py:431 ==> [2021-04-05-14:23:04.206624] Warning: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:04.937888] Reading config file /dev/shm/spack/test/etc/spack/defaults/repos.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-14:23:04.944837] Reading config file /dev/shm/spack/test/etc/spack/repos.yaml
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.083208] opt_criterion(15, version weight)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.083743] opt_criterion(14, number of non-default variants (roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.084143] opt_criterion(13, multi-valued variants + preferred providers for roots)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.084539] opt_criterion(11, number of non-default variants (non-roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.084935] opt_criterion(9, number of non-default providers (non-roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.085343] opt_criterion(8, count of non-root multi-valued variants)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.085914] opt_criterion(7, compiler matches + number of nodes)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.086292] opt_criterion(6, version badness)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.086648] opt_criterion(5, non-preferred compilers)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.087000] opt_criterion(4, target matches)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-14:23:06.087361] opt_criterion(3, non-preferred targets)
lib/spack/spack/cmd/solve.py:123 ==> [2021-04-05-14:23:06.099240] Best of 1 considered solutions.
lib/spack/spack/cmd/solve.py:124 ==> [2021-04-05-14:23:06.099658] Optimization Criteria:
  Priority  Criterion                                            Value
  1         version weight                                           0
  2         number of non-default variants (roots)                   0
  3         multi-valued variants + preferred providers for roots    0
  4         number of non-default variants (non-roots)               0
  5         number of non-default providers (non-roots)              0
  6         count of non-root multi-valued variants                  0
  7         compiler matches + number of nodes                       0
  8         version badness                                          0
  9         non-preferred compilers                                  0
  10        target matches                                           0
  11        non-preferred targets                                    0

```
</details>

When I comment out line 
```python
warnings.showwarning = send_warning_to_tty
```
 in `lib/spack/spack/main.py`, I get:

```
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:262: UserWarning: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
```

<details>
<summary>
<strong><code>spack --debug --stacktrace solve</code> (complete output)</strong>
</summary>

```
lib/spack/spack/util/executable.py:182 ==> [2021-04-05-16:32:02.572391] '/bin/bash' '--norc' '--noprofile' '-lc' 'echo $CRAY_CPU_TARGET'
lib/spack/spack/platforms/cray.py:154 ==> [2021-04-05-16:32:02.602351] default to front-end architecture
lib/spack/spack/cmd/__init__.py:122 ==> [2021-04-05-16:32:03.817520] Imported solve from built-in commands
lib/spack/spack/cmd/__init__.py:122 ==> [2021-04-05-16:32:03.819655] Imported solve from built-in commands
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:04.161790] Reading config file /dev/shm/spack/test/etc/spack/compilers.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:05.975858] Reading config file /dev/shm/spack/test/etc/spack/defaults/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:06.046715] Reading config file /dev/shm/spack/test/etc/spack/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:06.056981] Reading config file /u/staff/mbelkin/.spack/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:06.098538] Reading config file /dev/shm/spack/test/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:06.203973] Reading config file /dev/shm/spack/test/etc/spack/packages.yaml
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:262: UserWarning: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:07.882120] Reading config file /dev/shm/spack/test/etc/spack/defaults/repos.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:32:07.888863] Reading config file /dev/shm/spack/test/etc/spack/repos.yaml
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.114932] opt_criterion(15, version weight)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.115407] opt_criterion(14, number of non-default variants (roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.115763] opt_criterion(13, multi-valued variants + preferred providers for roots)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.116110] opt_criterion(11, number of non-default variants (non-roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.116466] opt_criterion(9, number of non-default providers (non-roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.116816] opt_criterion(8, count of non-root multi-valued variants)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.117166] opt_criterion(7, compiler matches + number of nodes)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.117514] opt_criterion(6, version badness)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.117859] opt_criterion(5, non-preferred compilers)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.118202] opt_criterion(4, target matches)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:32:09.118549] opt_criterion(3, non-preferred targets)
lib/spack/spack/cmd/solve.py:123 ==> [2021-04-05-16:32:09.129637] Best of 1 considered solutions.
lib/spack/spack/cmd/solve.py:124 ==> [2021-04-05-16:32:09.129963] Optimization Criteria:
  Priority  Criterion                                            Value
  1         version weight                                           0
  2         number of non-default variants (roots)                   0
  3         multi-valued variants + preferred providers for roots    0
  4         number of non-default variants (non-roots)               0
  5         number of non-default providers (non-roots)              0
  6         count of non-root multi-valued variants                  0
  7         compiler matches + number of nodes                       0
  8         version badness                                          0
  9         non-preferred compilers                                  0
  10        target matches                                           0
  11        non-preferred targets                                    0
```
</details>

Finally, when I add `warning_message = str(compiler_entry) + "\n" + warning_message` to `lib/spack/external/archspec/cpu/microarchitecture.py` like so:
```diff
                 if warning_message:
+                    warning_message = str(compiler_entry) + "\n" + warning_message
                     warnings.warn(warning_message)
```

I see a number of very similar warnings that look like this:

```console
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:263: UserWarning: {'versions': '16.0:', 'warnings': "Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors", 'flags': '-msse3', 'name': 'bulldozer'}
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
```
but for different "flags"


<details>
<summary>
<strong><code>spack --debug --stacktrace solve</code> (complete output)</strong>
</summary>

```
lib/spack/spack/util/executable.py:182 ==> [2021-04-05-16:41:15.100831] '/bin/bash' '--norc' '--noprofile' '-lc' 'echo $CRAY_CPU_TARGET'
lib/spack/spack/platforms/cray.py:154 ==> [2021-04-05-16:41:15.120326] default to front-end architecture
lib/spack/spack/cmd/__init__.py:122 ==> [2021-04-05-16:41:16.251029] Imported solve from built-in commands
lib/spack/spack/cmd/__init__.py:122 ==> [2021-04-05-16:41:16.253234] Imported solve from built-in commands
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:16.554406] Reading config file /dev/shm/spack/test/etc/spack/compilers.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:18.307166] Reading config file /dev/shm/spack/test/etc/spack/defaults/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:18.378508] Reading config file /dev/shm/spack/test/etc/spack/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:18.388623] Reading config file /u/staff/mbelkin/.spack/config.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:18.439507] Reading config file /dev/shm/spack/test/etc/spack/defaults/packages.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:18.543331] Reading config file /dev/shm/spack/test/etc/spack/packages.yaml
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:263: UserWarning: {'versions': '16.0:', 'warnings': "Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors", 'flags': '-msse3', 'name': 'bulldozer'}
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:263: UserWarning: {'versions': '16.0:', 'warnings': "Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors", 'name': 'core-avx2', 'flags': '-march={name} -mtune={name}'}
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:263: UserWarning: {'versions': '16.0:', 'warnings': "Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors", 'flags': '-msse4.2', 'name': 'steamroller'}
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:263: UserWarning: {'versions': '16.0:', 'warnings': "Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors", 'flags': '-msse3', 'name': 'piledriver'}
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
/dev/shm/spack/test/lib/spack/external/archspec/cpu/microarchitecture.py:263: UserWarning: {'versions': '16.0:', 'warnings': "Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors", 'flags': '-msse2', 'name': 'k10'}
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors
  warnings.warn(warning_message)
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:20.226405] Reading config file /dev/shm/spack/test/etc/spack/defaults/repos.yaml
lib/spack/spack/config.py:981 ==> [2021-04-05-16:41:20.233054] Reading config file /dev/shm/spack/test/etc/spack/repos.yaml
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.371765] opt_criterion(15, version weight)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.372239] opt_criterion(14, number of non-default variants (roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.372584] opt_criterion(13, multi-valued variants + preferred providers for roots)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.372921] opt_criterion(11, number of non-default variants (non-roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.373259] opt_criterion(9, number of non-default providers (non-roots))
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.373610] opt_criterion(8, count of non-root multi-valued variants)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.373955] opt_criterion(7, compiler matches + number of nodes)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.374295] opt_criterion(6, version badness)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.374632] opt_criterion(5, non-preferred compilers)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.374969] opt_criterion(4, target matches)
lib/spack/spack/solver/asp.py:1566 ==> [2021-04-05-16:41:21.375305] opt_criterion(3, non-preferred targets)
lib/spack/spack/cmd/solve.py:123 ==> [2021-04-05-16:41:21.387813] Best of 1 considered solutions.
lib/spack/spack/cmd/solve.py:124 ==> [2021-04-05-16:41:21.388228] Optimization Criteria:
  Priority  Criterion                                            Value
  1         version weight                                           0
  2         number of non-default variants (roots)                   0
  3         multi-valued variants + preferred providers for roots    0
  4         number of non-default variants (non-roots)               0
  5         number of non-default providers (non-roots)              0
  6         count of non-root multi-valued variants                  0
  7         compiler matches + number of nodes                       0
  8         version badness                                          0
  9         non-preferred compilers                                  0
  10        target matches                                           0
  11        non-preferred targets                                    0
```
</details>



### Information on your system

<!-- Please include the output of `spack debug report` -->

* **Spack:** 0.16.1-2041-1908e6834d
* **Python:** 3.7.9
* **Platform:** cray-suse_linux11-bulldozer
* **Concretizer:** clingo


<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have searched the issues of this repo and believe this is not a duplicate
- [x] I have run the failing commands in debug mode and reported the output

<!-- We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively!

If you want to ask a question about the tool (how to use it, what it can currently do, etc.), try the `#general` channel on our Slack first. We have a welcoming community and chances are you'll get your reply faster and without opening an issue.

Other than that, thanks for taking the time to contribute to Spack! -->



Discussion:
This appears to happen only with `clingo`, not with the original concretizer—even when `%gcc` is explicitly specified.

Resolving patch:
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -12,6 +12,7 @@
 import sys
 import time
 import types
+import warnings
 from six import string_types
 
 import archspec.cpu
@@ -1040,7 +1041,9 @@ def _supported_targets(self, compiler_name, compiler_version, targets):
 
         for target in targets:
             try:
-                target.optimization_flags(compiler_name, compiler_version)
+                with warnings.catch_warnings():
+                    warnings.simplefilter("ignore")
+                    target.optimization_flags(compiler_name, compiler_version)
                 supported.append(target)
             except archspec.cpu.UnsupportedMicroarchitecture:
                 continue


Test patch: