Repository: conan-io/conan-center-index

Issue:
[swig] swig/4.0.2: build fails with clang + libc++ on linux armv8
### Description

build fails with clang + libc++ under linux on armv8 as follows
```
clang++  -O3 -stdlib=libc++ -Wall -W -ansi -pedantic   -o eswig CParse/cscanner.o CParse/parser.o CParse/templ.o CParse/util.o DOH/base.o DOH/file.o DOH/fio.o DOH/hash.o DOH/list.o DOH/memory.o DOH/string.o DOH/void.o Doxygen/doxyentity.o Doxygen/doxyparser.o Doxygen/doxytranslator.o Doxygen/javadoc.o Doxygen/pydoc.o Modules/allocate.o Modules/browser.o Modules/contract.o Modules/csharp.o Modules/d.o Modules/directors.o Modules/emit.o Modules/go.o Modules/guile.o Modules/interface.o Modules/java.o Modules/javascript.o Modules/lang.o Modules/lua.o Modules/main.o Modules/mzscheme.o Modules/nested.o Modules/ocaml.o Modules/octave.o Modules/overload.o Modules/perl5.o Modules/php.o Modules/python.o Modules/r.o Modules/ruby.o Modules/scilab.o Modules/swigmain.o Modules/tcl8.o Modules/typepass.o Modules/utils.o Modules/xml.o Preprocessor/cpp.o Preprocessor/expr.o Swig/cwrap.o Swig/deprecate.o Swig/error.o Swig/extend.o Swig/fragment.o Swig/getopt.o Swig/include.o Swig/misc.o Swig/naming.o Swig/parms.o Swig/scanner.o Swig/stype.o Swig/symbol.o Swig/tree.o Swig/typemap.o Swig/typeobj.o Swig/typesys.o Swig/wrapfunc.o  -L"/root/.conan/data/bison/3.7.6/_/_/package/8331f68326a30f6076975c874febfaa87b551d23/lib" -L"/root/.conan/data/pcre/8.45/_/_/package/629b361cdd013749b6ce83f70759370dc40251f9/lib" -L"/root/.conan/data/bzip2/1.0.8/_/_/package/7792c60144dcff98ca81645d2bd4b4db9037424f/lib" -L"/root/.conan/data/zlib/1.2.12/_/_/package/0a726f3d11940273926199a81d004fd1f792cde2/lib" -l"y" -l"pcreposix" -l"pcre" -l"pcre16" -l"pcre32" -l"bz2" -l"z"
clang: warning: argument unused during compilation: '-ansi' [-Wunused-command-line-argument]
/usr/bin/ld: Modules/main.o: in function `SWIG_main(int, char**, TargetLanguageModule const*)':
main.cxx:(.text+0x11f8): undefined reference to `dladdr'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
use of dladdr is triggered by this conan patch
https://github.com/conan-io/conan-center-index/blob/master/recipes/swig/all/patches/0001-swig-linux-library-path.patch#L14

building with gcc (default) works fine

### Package and Environment Details

* Package Name/Version: **swig/4.0.2**
* Operating System+version: **Linux Ubuntu 20.04 armv8**
* Compiler+version: **clang 10**
* Conan version: **conan 1.52.0**
* Python version: **Python 3.8.10**


### Conan profile

[settings]
os=Linux
os_build=Linux
arch=armv8
arch_build=armv8
compiler=clang
compiler.version=10
compiler.libcxx=libc++
build_type=Release
[options]
[conf]
[build_requires]
[env]
CC=clang
CXX=clang++

### Steps to reproduce

conan install -pr clang swig/4.0.2@_/_ --build=missing

### Logs

<details><summary>Click to expand log</summary>

[conan_build_fail.log](https://github.com/conan-io/conan-center-index/files/9732441/conan_build_fail.log)

</details>



Discussion:
I don't see `-ldr` in Clang's link line. Likely, the package uses the system header and doesn't actually link against the library.
Yup:

```python
        if self.settings.compiler == 'gcc':
            args.append("LIBS=-ldl")
```

Resolving patch:
diff --git a/recipes/swig/all/conanfile.py b/recipes/swig/all/conanfile.py
--- a/recipes/swig/all/conanfile.py
+++ b/recipes/swig/all/conanfile.py
@@ -1,4 +1,6 @@
-from conans import ConanFile, tools, AutoToolsBuildEnvironment
+from conan import ConanFile
+from conan.tools.files import get
+from conans import AutoToolsBuildEnvironment, tools
 import contextlib
 import functools
 import os
@@ -40,8 +42,8 @@ def package_id(self):
         del self.info.settings.compiler
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version],
-                  destination=self._source_subfolder, strip_root=True)
+        get(self, **self.conan_data["sources"][self.version],
+            destination=self._source_subfolder, strip_root=True)
 
     @property
     def _user_info_build(self):
@@ -86,7 +88,7 @@ def _configure_autotools(self):
             "--host={}".format(self.settings.arch),
             "--with-swiglibdir={}".format(self._swiglibdir),
         ]
-        if self.settings.compiler == 'gcc':
+        if self.settings.os == "Linux":
             args.append("LIBS=-ldl")
 
         host, build = None, None


Test patch: