forked from mesonbuild/meson
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: mesonbuild#3335.
- Loading branch information
Showing
7 changed files
with
150 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## has_link_argument() and friends | ||
|
||
A new set of methods has been added on compiler objects to test if the linker | ||
supports given arguments. | ||
|
||
- `has_link_argument()` | ||
- `has_multi_link_arguments()` | ||
- `get_supported_link_arguments()` | ||
- `first_supported_link_argument()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
project('has link arg', 'c', 'cpp') | ||
|
||
cc = meson.get_compiler('c') | ||
cpp = meson.get_compiler('cpp') | ||
|
||
if cc.get_id() == 'msvc' | ||
is_arg = '/OPT:REF' | ||
useless = '/DEBUG' | ||
isnt_arg = '/iambroken' | ||
else | ||
is_arg = '-Wl,-Lfoo' | ||
useless = '-Wl,-Lbar' | ||
isnt_arg = '-Wl,-iambroken' | ||
endif | ||
|
||
assert(cc.has_link_argument(is_arg), 'Arg that should have worked does not work.') | ||
assert(not cc.has_link_argument(isnt_arg), 'Arg that should be broken is not.') | ||
|
||
assert(cpp.has_link_argument(is_arg), 'Arg that should have worked does not work.') | ||
assert(not cpp.has_link_argument(isnt_arg), 'Arg that should be broken is not.') | ||
|
||
assert(cc.get_supported_link_arguments([is_arg, isnt_arg, useless]) == [is_arg, useless], 'Arg filtering returned different result.') | ||
assert(cpp.get_supported_link_arguments([is_arg, isnt_arg, useless]) == [is_arg, useless], 'Arg filtering returned different result.') | ||
|
||
# Have useless at the end to ensure that the search goes from front to back. | ||
l1 = cc.first_supported_link_argument([isnt_arg, is_arg, isnt_arg, useless]) | ||
l2 = cc.first_supported_link_argument(isnt_arg, isnt_arg, isnt_arg) | ||
|
||
assert(l1.length() == 1, 'First supported returned wrong result.') | ||
assert(l1.get(0) == is_arg, 'First supported returned wrong argument.') | ||
assert(l2.length() == 0, 'First supported did not return empty array.') | ||
|
||
l1 = cpp.first_supported_link_argument([isnt_arg, is_arg, isnt_arg, useless]) | ||
l2 = cpp.first_supported_link_argument(isnt_arg, isnt_arg, isnt_arg) | ||
|
||
assert(l1.length() == 1, 'First supported returned wrong result.') | ||
assert(l1.get(0) == is_arg, 'First supported returned wrong argument.') | ||
assert(l2.length() == 0, 'First supported did not return empty array.') | ||
|
||
assert(not cc.has_multi_link_arguments([isnt_arg, is_arg]), 'Arg that should be broken is not.') | ||
assert(cc.has_multi_link_arguments(is_arg), 'Arg that should have worked does not work.') | ||
assert(cc.has_multi_link_arguments([useless, is_arg]), 'Arg that should have worked does not work.') |