D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.
Fixes#7082
This gives a significant speedup in large projects such as gst-build
since now we only search for the tool once. Speed-up on Windows:
```
meson install:
before: 15.3 seconds
after: 5.4 seconds
meson install --only-changed:
before: 11.6 seconds
after: 2.7 seconds
```
On macOS, we set the install_name for built libraries to
@rpath/libfoo.dylib, and when linking to the library, we set the RPATH
to its path in the build directory. This allows all built binaries to
be run as-is from the build directory (uninstalled).
However, on install, we have to strip all the RPATHs because they
point to the build directory, and we change the install_name of all
built libraries to the absolute path to the library. This causes the
install name in binaries to be out of date.
We now change that install name to point to the absolute path to each
built library after installation.
Fixes https://github.com/mesonbuild/meson/issues/3038
Fixes https://github.com/mesonbuild/meson/issues/3077
With this, the default workflow on macOS matches what everyone seems
to do, including Autotools and CMake. The next step is providing a way
for build files to override the install_name that is used after
installation for use with, f.ex., private libraries when combined with
the install_rpath: kwarg on targets.
The install name is used by consumers of the library to find the
library at runtime. If it's @rpath/libfoo.dylib, all consumers must
manually add the library path to RPATH, which is not what people
expect.
Almost everyone sets the library install name as the full path to the
library, and this is done at install time with install_name_tool.
Meson has a common pattern of using 'if len(foo) == 0:' or
'if len(foo) != 0:', however, this is a common anti-pattern in python.
Instead tests for emptiness/non-emptiness should be done with a simple
'if foo:' or 'if not foo:'
Consider the following:
>>> import timeit
>>> timeit.timeit('if len([]) == 0: pass')
0.10730923599840025
>>> timeit.timeit('if not []: pass')
0.030033907998586074
>>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass')
0.1154778649979562
>>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass")
0.08259823200205574
>>> timeit.timeit('if len("") == 0: pass')
0.089759664999292
>>> timeit.timeit('if not "": pass')
0.02340641999762738
>>> timeit.timeit('if len("foo") == 0: pass')
0.08848102600313723
>>> timeit.timeit('if not "foo": pass')
0.04032287199879647
And for the one additional case of 'if len(foo.strip()) == 0', which can
be replaced with 'if not foo.isspace()'
>>> timeit.timeit('if len(" ".strip()) == 0: pass')
0.15294511600222904
>>> timeit.timeit('if " ".isspace(): pass')
0.09413968399894657
>>> timeit.timeit('if len(" abc".strip()) == 0: pass')
0.2023209120015963
>>> timeit.timeit('if " abc".isspace(): pass')
0.09571301700270851
In other words, it's always a win to not use len(), when you don't
actually want to check the length.
At installation, if the executable is a ELF file, we try to fix the
dependencies in the binary section.
If a executable has been compiled with the --static flag, there is
no .dynamic section in the ELF binary and so we need to handle this case.
************* Module depfixer
E: 57,39: Instance of 'DynamicEntry' has no 'Sxword' member (no-member)
E: 57,63: Instance of 'DynamicEntry' has no 'SxwordSize' member (no-member)
E: 58,37: Instance of 'DynamicEntry' has no 'XWord' member (no-member)
E: 58,60: Instance of 'DynamicEntry' has no 'XWordSize' member (no-member)
E: 60,39: Instance of 'DynamicEntry' has no 'Sword' member (no-member)
E: 60,62: Instance of 'DynamicEntry' has no 'SwordSize' member (no-member)
E: 61,37: Instance of 'DynamicEntry' has no 'Word' member (no-member)
E: 61,59: Instance of 'DynamicEntry' has no 'WordSize' member (no-member)
E: 65,36: Instance of 'DynamicEntry' has no 'Sxword' member (no-member)
E: 66,36: Instance of 'DynamicEntry' has no 'XWord' member (no-member)
E: 68,36: Instance of 'DynamicEntry' has no 'Sword' member (no-member)
E: 69,36: Instance of 'DynamicEntry' has no 'Word' member (no-member)
E: 79,37: Instance of 'SectionHeader' has no 'Word' member (no-member)
E: 79,59: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E: 81,37: Instance of 'SectionHeader' has no 'Word' member (no-member)
E: 81,59: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E: 84,42: Instance of 'SectionHeader' has no 'XWord' member (no-member)
E: 84,65: Instance of 'SectionHeader' has no 'XWordSize' member (no-member)
E: 86,42: Instance of 'SectionHeader' has no 'Word' member (no-member)
E: 86,64: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E: 88,37: Instance of 'SectionHeader' has no 'Addr' member (no-member)
E: 88,59: Instance of 'SectionHeader' has no 'AddrSize' member (no-member)
E: 90,39: Instance of 'SectionHeader' has no 'Off' member (no-member)
E: 90,60: Instance of 'SectionHeader' has no 'OffSize' member (no-member)
E: 93,41: Instance of 'SectionHeader' has no 'XWord' member (no-member)
E: 93,64: Instance of 'SectionHeader' has no 'XWordSize' member (no-member)
E: 95,41: Instance of 'SectionHeader' has no 'Word' member (no-member)
E: 95,63: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E: 97,37: Instance of 'SectionHeader' has no 'Word' member (no-member)
E: 97,59: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E: 99,37: Instance of 'SectionHeader' has no 'Word' member (no-member)
E: 99,59: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E:102,46: Instance of 'SectionHeader' has no 'XWord' member (no-member)
E:102,69: Instance of 'SectionHeader' has no 'XWordSize' member (no-member)
E:104,46: Instance of 'SectionHeader' has no 'Word' member (no-member)
E:104,68: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E:107,44: Instance of 'SectionHeader' has no 'XWord' member (no-member)
E:107,67: Instance of 'SectionHeader' has no 'XWordSize' member (no-member)
E:109,44: Instance of 'SectionHeader' has no 'Word' member (no-member)
E:109,66: Instance of 'SectionHeader' has no 'WordSize' member (no-member)
E:148,36: Instance of 'Elf' has no 'Half' member (no-member)
E:148,60: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:149,39: Instance of 'Elf' has no 'Half' member (no-member)
E:149,63: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:150,39: Instance of 'Elf' has no 'Word' member (no-member)
E:150,63: Instance of 'Elf' has no 'WordSize' member (no-member)
E:151,37: Instance of 'Elf' has no 'Addr' member (no-member)
E:151,61: Instance of 'Elf' has no 'AddrSize' member (no-member)
E:152,37: Instance of 'Elf' has no 'Off' member (no-member)
E:152,60: Instance of 'Elf' has no 'OffSize' member (no-member)
E:153,37: Instance of 'Elf' has no 'Off' member (no-member)
E:153,60: Instance of 'Elf' has no 'OffSize' member (no-member)
E:154,37: Instance of 'Elf' has no 'Word' member (no-member)
E:154,61: Instance of 'Elf' has no 'WordSize' member (no-member)
E:155,38: Instance of 'Elf' has no 'Half' member (no-member)
E:155,62: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:156,41: Instance of 'Elf' has no 'Half' member (no-member)
E:156,65: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:157,37: Instance of 'Elf' has no 'Half' member (no-member)
E:157,61: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:158,41: Instance of 'Elf' has no 'Half' member (no-member)
E:158,65: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:159,37: Instance of 'Elf' has no 'Half' member (no-member)
E:159,61: Instance of 'Elf' has no 'HalfSize' member (no-member)
E:160,40: Instance of 'Elf' has no 'Half' member (no-member)
E:160,64: Instance of 'Elf' has no 'HalfSize' member (no-member)
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>