nirbheek: Another thing that would be a Very Nice Thing that ensures that stuff like this doesn't break the Intel compiler in the future is to find a way to add the latest version of ICC to the Docker instance that we use for running [Linux tests on the CI](https://github.com/mesonbuild/meson/blob/master/.travis.yml). Then we can run the tests against it in the same way that we run clang tests.
asartori86: > find a way to add the latest version of ICC to the Docker instance

don't you have to pay to have the intel compiler?
nirbheek: > don't you have to pay for intel compiler?

I believe you can get a free version for open source use: https://software.intel.com/en-us/qualify-for-free-software/opensourcecontributor

I remember getting it for FOSS use 1-2 years ago when I was implementing it for Meson, but I don't remember how.
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index b62155b7b..af3e2c4a1 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -866,12 +866,29 @@ class CCompiler(Compiler):
         return patterns
 
     @staticmethod
-    def _get_trials_from_pattern(pattern, directory, libname):
+    def _sort_shlibs_openbsd(libs):
+        filtered = []
+        for lib in libs:
+            # Validate file as a shared library of type libfoo.so.X.Y
+            ret = lib.rsplit('.so.', maxsplit=1)
+            if len(ret) != 2:
+                continue
+            try:
+                float(ret[1])
+            except ValueError:
+                continue
+            filtered.append(lib)
+        float_cmp = lambda x: float(x.rsplit('.so.', maxsplit=1)[1])
+        return sorted(filtered, key=float_cmp, reverse=True)
+
+    @classmethod
+    def _get_trials_from_pattern(cls, pattern, directory, libname):
         f = os.path.join(directory, pattern.format(libname))
+        # Globbing for OpenBSD
         if '*' in pattern:
             # NOTE: globbing matches directories and broken symlinks
             # so we have to do an isfile test on it later
-            return glob.glob(f)
+            return cls._sort_shlibs_openbsd(glob.glob(f))
         return [f]
 
     @staticmethod
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 21aab1163..25835a32d 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1561,6 +1561,9 @@ class IntelCompiler:
         else:
             return ['-openmp']
 
+    def get_link_whole_for(self, args):
+        return GnuCompiler.get_link_whole_for(self, args)
+
 
 class ArmCompiler:
     # Functionality that is common to all ARM family compilers.

intel compiler doesn't implement link_whole
Hi,
I got an error when including PETSc as external dependency. Here is my `meson.build`
```
project('xxx', 'cpp', default_options : ['cpp_std=c++11'])

pdep = dependency('PETSc')
```
this is what I get when I run meson

```The Meson build system
Version: 0.47.0
Source dir: /some/path/
Build dir: /some/path/build
Build type: native build
Project name: xxx
Project version: undefined
Native C++ compiler: icpc (intel 17.0.4 "icpc (ICC) 17.0.4 20170411")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.27.1)

meson.build:5:0: ERROR:  Language C++ does not support linking whole archives.

A full log can be found at /some/path/build/meson-logs/meson-log.txt
```
and the log is
```
Build started at 2018-07-10T11:48:00.454242
Main binary: /bin/python3
Python system: Linux
The Meson build system
Version: 0.47.0
Source dir: /some/path
Build dir: /some/path/build
Build type: native build
Project name: xxx
Project version: undefined
Sanity testing C++ compiler: icpc
Is cross compiler: False.
Sanity check compiler command line: icpc /some/path/build/meson-private/sanitycheckcpp.cc -o /some/path/build/meson-private/sanitycheckcpp.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command: /some/path/build/meson-private/sanitycheckcpp.exe
Native C++ compiler: icpc (intel 17.0.4 "icpc (ICC) 17.0.4 20170411")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.27.1)
Determining dependency 'PETSc' with pkg-config executable '/usr/bin/pkg-config'
Called `/usr/bin/pkg-config --modversion PETSc` -> 0
3.9.2
Called `/usr/bin/pkg-config --cflags PETSc` -> 0
-I/...../petsc-3.9.2/arch-linux-c-dbg-g-real-avx-2-512-int64/include
Called `/usr/bin/pkg-config PETSc --libs` -> 0
-L/...../petsc-3.9.2/arch-linux-c-dbg-g-real-avx-2-512-int64/lib -lpetsc
Called `/usr/bin/pkg-config PETSc --libs` -> 0
-L/......./petsc-3.9.2/arch-linux-c-dbg-g-real-avx-2-512-int64/lib -lpetsc

meson.build:5:0: ERROR:  Language C++ does not support linking whole archives.
```

however, if I issue from the command line

```
icpc $(pkg-config --cflags --libs PETSc) meson-private/sanitycheckcpp.cc
```
it compiles and links..

What happens inside the call to `dependency`? Why I get that error and how can I solve it?

thanks


diff --git a/run_unittests.py b/run_unittests.py
index df4603e3a..f4e95a302 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -522,12 +522,28 @@ class InternalTests(unittest.TestCase):
         self.assertEqual(p, shr)
         p = cc.get_library_naming(env, 'static')
         self.assertEqual(p, stc)
-        p = cc.get_library_naming(env, 'default')
-        self.assertEqual(p, shr + stc)
-        p = cc.get_library_naming(env, 'shared-static')
-        self.assertEqual(p, shr + stc)
         p = cc.get_library_naming(env, 'static-shared')
         self.assertEqual(p, stc + shr)
+        p = cc.get_library_naming(env, 'shared-static')
+        self.assertEqual(p, shr + stc)
+        p = cc.get_library_naming(env, 'default')
+        self.assertEqual(p, shr + stc)
+        # Test find library by mocking up openbsd
+        if platform != 'openbsd':
+            return
+        with tempfile.TemporaryDirectory() as tmpdir:
+            with open(os.path.join(tmpdir, 'libfoo.so.6.0'), 'w') as f:
+                f.write('')
+            with open(os.path.join(tmpdir, 'libfoo.so.5.0'), 'w') as f:
+                f.write('')
+            with open(os.path.join(tmpdir, 'libfoo.so.54.0'), 'w') as f:
+                f.write('')
+            with open(os.path.join(tmpdir, 'libfoo.so.66a.0b'), 'w') as f:
+                f.write('')
+            with open(os.path.join(tmpdir, 'libfoo.so.70.0.so.1'), 'w') as f:
+                f.write('')
+            found = cc.find_library_real('foo', env, [tmpdir], '', 'default')
+            self.assertEqual(os.path.basename(found[0]), 'libfoo.so.54.0')
 
     def test_find_library_patterns(self):
         '''

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
iniconfig==2.1.0
-e git+https://github.com/mesonbuild/meson.git@09ad29ec560f2a05108694d909de30b5e3e58357#egg=meson
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
tomli==2.2.1

name: meson
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - tomli==2.2.1
prefix: /opt/conda/envs/meson

run_unittests.py::InternalTests::test_find_library_patterns
run_unittests.py::AllPlatformTests::test_absolute_prefix_libdir run_unittests.py::AllPlatformTests::test_all_forbidden_targets_tested run_unittests.py::AllPlatformTests::test_always_prefer_c_compiler_for_asm run_unittests.py::AllPlatformTests::test_array_option_bad_change run_unittests.py::AllPlatformTests::test_array_option_change run_unittests.py::AllPlatformTests::test_array_option_empty_equivalents run_unittests.py::AllPlatformTests::test_build_by_default run_unittests.py::AllPlatformTests::test_check_module_linking run_unittests.py::AllPlatformTests::test_command_line run_unittests.py::AllPlatformTests::test_compiler_detection run_unittests.py::AllPlatformTests::test_compiler_options_documented run_unittests.py::AllPlatformTests::test_compiler_run_command run_unittests.py::AllPlatformTests::test_configure_file_warnings run_unittests.py::AllPlatformTests::test_conflicting_d_dash_option run_unittests.py::AllPlatformTests::test_cpu_families_documented run_unittests.py::AllPlatformTests::test_cross_file_system_paths run_unittests.py::AllPlatformTests::test_custom_target_changes_cause_rebuild run_unittests.py::AllPlatformTests::test_custom_target_exe_data_deterministic run_unittests.py::AllPlatformTests::test_dash_d_dedup run_unittests.py::AllPlatformTests::test_default_options_prefix run_unittests.py::AllPlatformTests::test_default_options_prefix_dependent_defaults run_unittests.py::AllPlatformTests::test_dirs run_unittests.py::AllPlatformTests::test_dist_git run_unittests.py::AllPlatformTests::test_dist_hg run_unittests.py::AllPlatformTests::test_feature_check_usage_subprojects run_unittests.py::AllPlatformTests::test_flock run_unittests.py::AllPlatformTests::test_forcefallback run_unittests.py::AllPlatformTests::test_free_stringarray_setting run_unittests.py::AllPlatformTests::test_guessed_linker_dependencies run_unittests.py::AllPlatformTests::test_identical_target_name_in_subdir_flat_layout run_unittests.py::AllPlatformTests::test_identical_target_name_in_subproject_flat_layout run_unittests.py::AllPlatformTests::test_install_introspection run_unittests.py::AllPlatformTests::test_internal_include_order run_unittests.py::AllPlatformTests::test_libdir_must_be_inside_prefix run_unittests.py::AllPlatformTests::test_markdown_files_in_sitemap run_unittests.py::AllPlatformTests::test_ndebug_if_release_disabled run_unittests.py::AllPlatformTests::test_ndebug_if_release_enabled run_unittests.py::AllPlatformTests::test_permitted_method_kwargs run_unittests.py::AllPlatformTests::test_pkgconfig_gen_escaping run_unittests.py::AllPlatformTests::test_pkgconfig_static run_unittests.py::AllPlatformTests::test_prebuilt_object run_unittests.py::AllPlatformTests::test_prebuilt_shared_lib run_unittests.py::AllPlatformTests::test_prebuilt_static_lib run_unittests.py::AllPlatformTests::test_prefix_dependent_defaults run_unittests.py::AllPlatformTests::test_preprocessor_checks_CPPFLAGS run_unittests.py::AllPlatformTests::test_rpath_uses_ORIGIN run_unittests.py::AllPlatformTests::test_run_target_files_path run_unittests.py::AllPlatformTests::test_same_d_option_twice run_unittests.py::AllPlatformTests::test_same_d_option_twice_configure run_unittests.py::AllPlatformTests::test_same_dash_option_twice run_unittests.py::AllPlatformTests::test_same_dash_option_twice_configure run_unittests.py::AllPlatformTests::test_same_project_d_option_twice run_unittests.py::AllPlatformTests::test_same_project_d_option_twice_configure run_unittests.py::AllPlatformTests::test_source_changes_cause_rebuild run_unittests.py::AllPlatformTests::test_static_compile_order run_unittests.py::AllPlatformTests::test_static_library_lto run_unittests.py::AllPlatformTests::test_static_library_overwrite run_unittests.py::AllPlatformTests::test_subproject_promotion run_unittests.py::AllPlatformTests::test_suite_selection run_unittests.py::AllPlatformTests::test_templates run_unittests.py::AllPlatformTests::test_testsetup_selection run_unittests.py::AllPlatformTests::test_testsetups run_unittests.py::AllPlatformTests::test_uninstall run_unittests.py::AllPlatformTests::test_warning_location run_unittests.py::FailureTests::test_apple_frameworks_dependency run_unittests.py::FailureTests::test_boost_BOOST_ROOT_dependency run_unittests.py::FailureTests::test_boost_notfound_dependency run_unittests.py::FailureTests::test_dependency run_unittests.py::FailureTests::test_dependency_invalid_method run_unittests.py::FailureTests::test_dict_forbids_duplicate_keys run_unittests.py::FailureTests::test_dict_forbids_integer_key run_unittests.py::FailureTests::test_dict_requires_key_value_pairs run_unittests.py::FailureTests::test_exception_exit_status run_unittests.py::FailureTests::test_gnustep_notfound_dependency run_unittests.py::FailureTests::test_llvm_dependency run_unittests.py::FailureTests::test_objc_cpp_detection run_unittests.py::FailureTests::test_sdl2_notfound_dependency run_unittests.py::FailureTests::test_subproject_variables run_unittests.py::FailureTests::test_using_recent_feature run_unittests.py::FailureTests::test_using_too_recent_feature run_unittests.py::FailureTests::test_using_too_recent_feature_dependency run_unittests.py::FailureTests::test_wx_dependency run_unittests.py::FailureTests::test_wx_notfound_dependency run_unittests.py::WindowsTests::test_find_program run_unittests.py::WindowsTests::test_ignore_libs run_unittests.py::WindowsTests::test_rc_depends_files run_unittests.py::LinuxlikeTests::test_apple_bitcode run_unittests.py::LinuxlikeTests::test_apple_bitcode_modules run_unittests.py::LinuxlikeTests::test_basic_soname run_unittests.py::LinuxlikeTests::test_build_rpath run_unittests.py::LinuxlikeTests::test_compiler_c_stds run_unittests.py::LinuxlikeTests::test_compiler_check_flags_order run_unittests.py::LinuxlikeTests::test_compiler_cpp_stds run_unittests.py::LinuxlikeTests::test_coverage run_unittests.py::LinuxlikeTests::test_cpp_std_override run_unittests.py::LinuxlikeTests::test_cross_find_program run_unittests.py::LinuxlikeTests::test_custom_soname run_unittests.py::LinuxlikeTests::test_install_umask run_unittests.py::LinuxlikeTests::test_installed_modes run_unittests.py::LinuxlikeTests::test_installed_modes_extended run_unittests.py::LinuxlikeTests::test_installed_soname run_unittests.py::LinuxlikeTests::test_introspect_dependencies run_unittests.py::LinuxlikeTests::test_old_gnome_module_codepaths run_unittests.py::LinuxlikeTests::test_order_of_l_arguments run_unittests.py::LinuxlikeTests::test_pch_with_address_sanitizer run_unittests.py::LinuxlikeTests::test_pic run_unittests.py::LinuxlikeTests::test_pkg_unfound run_unittests.py::LinuxlikeTests::test_pkgconfig_formatting run_unittests.py::LinuxlikeTests::test_pkgconfig_gen run_unittests.py::LinuxlikeTests::test_pkgconfig_gen_deps run_unittests.py::LinuxlikeTests::test_pkgconfig_internal_libraries run_unittests.py::LinuxlikeTests::test_pkgconfig_usage run_unittests.py::LinuxlikeTests::test_qt5dependency_pkgconfig_detection run_unittests.py::LinuxlikeTests::test_qt5dependency_qmake_detection run_unittests.py::LinuxlikeTests::test_reconfigure run_unittests.py::LinuxlikeTests::test_run_installed run_unittests.py::LinuxlikeTests::test_soname run_unittests.py::LinuxlikeTests::test_unity_subproj run_unittests.py::LinuxlikeTests::test_usage_external_library run_unittests.py::LinuxlikeTests::test_vala_c_warnings run_unittests.py::LinuxlikeTests::test_vala_generated_source_buildir_inside_source_tree run_unittests.py::LinuxArmCrossCompileTests::test_cflags_cross_environment_pollution run_unittests.py::LinuxArmCrossCompileTests::test_cross_file_overrides_always_args run_unittests.py::PythonTests::test_versions run_unittests.py::RewriterTests::test_basic run_unittests.py::RewriterTests::test_subdir
run_unittests.py::InternalTests::test_compiler_args_class run_unittests.py::InternalTests::test_extract_as_list run_unittests.py::InternalTests::test_listify run_unittests.py::InternalTests::test_mode_symbolic_to_bits run_unittests.py::InternalTests::test_needs_exe_wrapper_override run_unittests.py::InternalTests::test_pkgconfig_module run_unittests.py::InternalTests::test_snippets run_unittests.py::InternalTests::test_string_templates_substitution run_unittests.py::InternalTests::test_version_number
mesonbuild/compilers/compilers.py mesonbuild/compilers/c.py
mesonbuild/compilers/compilers.py mesonbuild/compilers/c.py