diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-12-15 07:40:43 -0500 |
---|---|---|
committer | Michael Hirsch, Ph.D <10931741+scivision@users.noreply.github.com> | 2019-12-19 12:03:55 -0500 |
commit | 5695dc0f1674211049b3952f8005cccc78411cdd (patch) | |
tree | 7bed9e714d54caa0c018bedcfeb41596bf6197b8 /docs/markdown/Compiler-properties.md | |
parent | 06821755d253a930ebe29bb27f55b442c1790fed (diff) | |
download | meson-5695dc0f1674211049b3952f8005cccc78411cdd.zip meson-5695dc0f1674211049b3952f8005cccc78411cdd.tar.gz meson-5695dc0f1674211049b3952f8005cccc78411cdd.tar.bz2 |
add compiler.get_linker_id() method
this can be useful for if/elif where linker behaviors must be
considered.
For example, clang with "link" vs gcc with "ld.bfd" etc.
ci for compiler.get_linker_id() method
doc
add @FeatureNew check
Co-Authored-By: Daniel Mensinger <daniel@mensinger-ka.de>
Diffstat (limited to 'docs/markdown/Compiler-properties.md')
-rw-r--r-- | docs/markdown/Compiler-properties.md | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/docs/markdown/Compiler-properties.md b/docs/markdown/Compiler-properties.md index 4f5ebdb..5d29dd1 100644 --- a/docs/markdown/Compiler-properties.md +++ b/docs/markdown/Compiler-properties.md @@ -25,13 +25,16 @@ know the operating system your code will run on, issue this command: host_machine.system() ``` -Compiler id -== +## Compiler id -The compiler object has a method called `get_id`, which returns a -lower case string describing the "family" of the compiler. +The compiler object method `get_id` returns a +lower case string describing the "family" of the compiler. Since 0.53.0 +`get_linker_id` returns a lower case string with the linker name. Since +compilers can often choose from multiple linkers depending on operating +system, `get_linker_id` can be useful for handling or mitigating effects +of particular linkers. -The compiler object also has a method `get_argument_syntax` which +The compiler object also has a method `get_argument_syntax` which returns a lower case string of `gcc`, `msvc`, or another undefined string value; identifying whether the compiler arguments use the same syntax as either `gcc` or `msvc`, or that its arguments are not like either. This should @@ -41,11 +44,14 @@ with `has_argument`. See [reference tables](Reference-tables.md#compiler-ids) for a list of supported compiler ids and their argument type. -Does code compile? -== +## Does code compile? Sometimes the only way to test the system is to try to compile some -sample code and see if it works. This is a two-phase operation. First +sample code and see if it works. For example, this can test that a +"C++17" compiler actually supports a particular C++17 feature, +without resorting to maintaining a feature list vs. compiler vendor, +compiler version and operating system. +Testing that a code snippet runs is a two-phase operation. First we define some code using the multiline string operator: ```meson @@ -65,8 +71,7 @@ depending on whether the compilation succeeded or not. The keyword argument `name` is optional. If it is specified, Meson will write the result of the check to its log. -Does code compile and link? -== +## Does code compile and link? Sometimes it is necessary to check whether a certain code fragment not only compiles, but also links successfully, e.g. to check if a symbol @@ -90,11 +95,11 @@ depending on whether the compilation and linking succeeded or not. The keyword argument `name` is optional. If it is specified, Meson will write the result of the check to its log. - -Compile and run test application -== +## Compile and run test application Here is how you would compile and run a small test application. +Testing if a code snippets **runs** versus merely that it links +is particularly important for some dependencies such as MPI. ```meson code = '''#include<stdio.h> @@ -126,9 +131,7 @@ if result.stdout().strip() == 'some_value' endif ``` - -Does a header exist? -== +## Does a header exist? Header files provided by different platforms vary quite a lot. Meson has functionality to detect whether a given header file is available @@ -142,8 +145,7 @@ if compiler.has_header('sys/fstat.h') endif ``` -Expression size -== +## Expression size Often you need to determine the size of a particular element (such as `int`, `wchar_t` or `char*`). Using the `compiler` variable mentioned @@ -163,8 +165,7 @@ In older versions (<= 0.30) meson would error out if the size could not be determined. Since version 0.31 it returns -1 if the size could not be determined. -Does a function exist? -== +## Does a function exist? Just having a header doesn't say anything about its contents. Sometimes you need to explicitly check if some function @@ -192,8 +193,7 @@ report the function as missing. Without the header however, it would lack the necessary availability information and incorrectly report the function as available. -Does a structure contain a member? -== +## Does a structure contain a member? Some platforms have different standard structures. Here's how one would check if a struct called `mystruct` from header `myheader.h` @@ -205,8 +205,7 @@ if compiler.has_member('struct mystruct', 'some_member', prefix : '#include<myhe endif ``` -Type alignment -== +## Type alignment Most platforms can't access some data types at any address. For example it is common that a `char` can be at any address but a 32 bit |