Commit Graph

11 Commits

Author SHA1 Message Date
Christoph Reiter 2d538c58cb Fix visibility attribute support check for GCC on Windows
has_function_attribute() depends on -Wattributes being emitted when an attribute
is not supported by the compiler. In case of GCC on Window (at least) there is no
warning in case the attribute is used on a declaration. Only once there is also a
function definition does it emit a warning like:

a.c: In function ‘foo’:
a.c:8:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    8 | }

To fix this add a dummy function definition to all visibility compiler checks in meson.

The tests in "197 function attributes" only checked for positive return result on on-msvc
compilers, except one special case for dllexport/dllimport. Refactor the tests a bit so
one can specify also a negative expected result, and add tests for all visibility attribute
variants.
2023-11-04 23:36:03 -04:00
Dudemanguy f2cb8e2ad5 add cc.has_function_attribute('vector_size') 2023-02-01 13:26:09 -08:00
Tristan Partin 8d918e0147 Add cc.has_function_attribute('sentinel') 2022-05-19 15:05:53 -04:00
Tristan Partin 5d438b6aed Add cc.has_function_attribute('section') 2022-05-19 15:05:53 -04:00
Arsen Arsenović 57ce83b396 compilers/c_function_attributes: add retain
retain is a relatively young attribute which has proven itself useful
for working with --gc-sections -z start-stop-gc.
2022-01-26 19:22:17 -05:00
Tim-Philipp Müller 246e5437aa compiler: add 'force_align_arg_pointer' function attribute 2020-06-21 23:34:11 +03:00
Nirbheek Chauhan dc19b13202 compilers: Silence warning about gnu_inline with clang
The warning is due to a change in behaviour in Clang 10 and newer:

https://releases.llvm.org/10.0.0/tools/clang/docs/ReleaseNotes.html#c-language-changes-in-clang

This was already fixed for clang++, but not for clang for some reason.
It was also fixed incorrectly; by adding `extern` instead of moving
from `-Werror` to `-Werror=attributes`.
2020-04-20 19:30:57 +03:00
Dylan Baker 66bc485646 compilers: Update gnu_inline test to work correctly with Clang >= 10
Which has changed the way it handles gnu_inline in C++.
2020-04-17 18:18:20 +03:00
Dylan Baker e2039da5d9 Split attribute visibility
* c_function_attributes: remove 'protected' from 'visibility'

This doesn't exist on macos with the apple compiler, which always causes
failures.

Fixes #5530

* compilers: Add split visibility checks to has_function_attribute

These check for a single visibility at a time, rather than all four at
once. This allows for finer grained searches, and should make using
these checks safer across operating systems.
2019-06-25 00:02:26 +03:00
Dylan Baker 21a7528b2f compilers/c_function_attributes: fix for ICC
ICC doesn't like the extra set of parens, GCC 8.2.1 and Clang 6.0.1
don't have a problem with this.
2018-11-15 18:42:25 -08:00
Dylan Baker 51e9db370a Add method to check for C/C++ function attributes
It's fairly common on Linux and *BSD platforms to check for these
attributes existence, so it makes sense to me to have this checking
build into meson itself. Autotools also has a builtin for handling
these, and by building them in we can short circuit cases that we know
that these don't exist (MSVC).

Additionally this adds support for two common MSVC __declspec
attributes, dllimport and dllexport. This implements the declspec
version (even though GCC has an __attribute__ version that both it and
clang support), since GCC and Clang support the MSVC version as well.
Thus it seems reasonable to assume that most projects will use the
__declspec version over teh __attribute__ version.
2018-09-07 11:52:15 -07:00