Repository: mesonbuild/meson

Issue:
`meson setup` takes 2.5 minutes for shared build (static takes 3 seconds)
**Describe the bug**

`meson setup` takes 2.5 minutes for a shared library build, compared to 3 seconds for a static library build.

This is `meson setup` step for a shared library build of a project taking nearly 2.5 minutes to complete.

```
CC="ccache clang" CXX="ccache clang++" CC_LD=lld CXX_LD=lld time strace -tt --string-limit=100 meson setup builddir --default-library shared 2>&1 | tee strace-shared.log
138.27user 1.77system 2:20.29elapsed 99%CPU (0avgtext+0avgdata 1280588maxresident)k
96inputs+28544outputs (30major+773158minor)pagefaults 0swaps
```

The same exact setup with static library configuration takes 3 seconds.

```
CC="ccache clang" CXX="ccache clang++" CC_LD=lld CXX_LD=lld time strace -tt --string-limit=100 meson setup builddir --default-library static 2>&1 | tee strace-static.log
<clipped>
2.25user 1.32system 0:03.59elapsed 99%CPU (0avgtext+0avgdata 88496maxresident)k
120inputs+25704outputs (58major+456678minor)pagefaults 0swaps
```

Looking at the strace output it seems that over 1 minute is spent repeating this:

```
08:45:41.412750 write(3, "detecting CPU family based on trial='x86_64'\n", 45) = 45
08:45:41.412822 write(3, "detecting CPU family based on trial='x86_64'\n", 45) = 45
<clipped>
08:46:48.017806 write(3, "detecting CPU family based on trial='x86_64'\n", 45) = 45
```

Then there is a second phase of this same pattern later in the trace. Together that accounts for over 2 minutes.

**To Reproduce**

Upon request. This is potentially difficult for our private build, but also perhaps unnecessary if this is as simple as perhaps adding in a new CPU family?

**Expected behavior**

Fast setup step.

**system parameters**

* meson: 1.0.0
* ninja: 1.10.2
* python: 3.11.1
* os: Fedora 37
* Cross build: no

```
processor       : 10                                                                                                                                                                                                                                                                                                                                                                          
vendor_id       : AuthenticAMD                                                                                                                                                                                                                                                                                                                                                                
cpu family      : 25                                                                                                                                                                                                                                                                                                                                                                          
model           : 97                                                                                                                                                                                                                                                                                                                                                                          
model name      : AMD Ryzen 9 7900X 12-Core Processor                                                                                                                                                                                                                                                                                                                                         
stepping        : 2                                                                                                                                                                                                                                                                                                                                                                           
microcode       : 0xa601203                                                                                                                                                                                                                                                                                                                                                                   
cpu MHz         : 3000.000                                                                                                                                                                                                                                                                                                                                                                    
cache size      : 1024 KB                                                                                                                                                                                                                                                                                                                                                                     
physical id     : 0                                                                                                                                                                                                                                                                                                                                                                           
siblings        : 24                                                                                                                                                                                                                                                                                                                                                                          
core id         : 12                                                                                                                                                                                                                                                                                                                                                                          
cpu cores       : 12                                                                                                                                                                                                                                                                                                                                                                          
apicid          : 24                                                                                                                                                                                                                                                                                                                                                                          
initial apicid  : 24                                                                                                                                                                                                                                                                                                                                                                          
fpu             : yes                                                                                                                                                                                                                                                                                                                                                                         
fpu_exception   : yes                                                                                                                                                                                                                                                                                                                                                                         
cpuid level     : 16                                                                                                                                                                                                                                                                                                                                                                          wp              : yes                                                                                                                                                                                                                                                                                                                                                                         flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm
_occup_llc cqm_mbm_total cqm_mbm_local avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca f
srm flush_l1d                                                                                                                                                                                                                                                                                                                                                                                 
bugs            : sysret_ss_attrs spectre_v1 spectre_v2 spec_store_bypass                                                                                                                                                                                                                                                                                                                     
bogomips        : 9382.11                                                                                                                                                                                                                                                                                                                                                                     
TLB size        : 3584 4K pages                                                                                                                                                                                                                                                                                                                                                               
clflush size    : 64                                                                                                                                                                                                                                                                                                                                                                          
cache_alignment : 64                                                                                                                                                                                                                                                                                                                                                                          
address sizes   : 48 bits physical, 48 bits virtual                                                                                                                                                                                                                                                                                                                                           
power management: ts ttp tm hwpstate cpb eff_freq_ro [13] [14]
```

* kernel info: `Linux panda 6.1.6-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Jan 14 16:55:06 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux`


Discussion:

Resolving patch:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -289,7 +289,6 @@ def detect_cpu_family(compilers: CompilersDict) -> str:
         trial = platform.processor().lower()
     else:
         trial = platform.machine().lower()
-    mlog.debug(f'detecting CPU family based on trial={trial!r}')
     if trial.startswith('i') and trial.endswith('86'):
         trial = 'x86'
     elif trial == 'bepc':


Test patch: