forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compilers: Convert b_sanitize to a freeform array option
There are a lot of sanitizers these days, and trying to keep up with them would be entirely too much work. Instead we'll do a compile check to see if the option is valid. A list makes more sense than a string, since users could just write `address,undefined` or they could write `undefined,address`. With the list we get to handle that ourselves and users writing code know that it's not safe to simply do a check like ```meson if get_option('b_sanitize') == 'address,undefined' ... endif ``` instead they need to do something like ```meson opt = get_option('b_sanitize') if opt.contains('address') and opt.contains('undefined') ... endif ``` To ensure backwards compatibility, a special check has been added to the get_option() call for `b_sanitize`, which converts it to a list if the compatibility is < 0.62, with a warning that the behavior will change in the future. Fixes mesonbuild#8283 Fixes mesonbuild#7761 Fixes mesonbuild#5154 Fixes mesonbuild#1582
- Loading branch information
Showing
15 changed files
with
178 additions
and
118 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,17 @@ | ||
## Changes to the b_sanitize option | ||
|
||
In meson <= 0.61 the b_sanitize option is a combo, which is an enumerated set of | ||
values. One picks one of the values as provided by that enumeration. In 0.62 | ||
this was changed to a free array of options, and a compiler check for the | ||
validity of those options. | ||
|
||
This solves a number of longstanding issues such as: | ||
- sanitizers may be supported by a compiler, but not on a specific platform (OpenBSD) | ||
- new sanitizers are not recognized by Meson | ||
- using sanitizers in different combinations | ||
|
||
In order to not break backwards compatibility, meson will make continue to | ||
return `get_option('b_sanitize')` as a string if the requested meson version is | ||
`< 0.62`. In addition, it alphabetically sorts the values so that | ||
`undefined,address` will still be presented as `address,undefined`. When the | ||
minimum version is changed to >= 0.62, then it will return an array of strings. |
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
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,4 @@ | ||
project('sanitizer', 'c') | ||
|
||
subproject('new_behavior') | ||
subproject('old_behavior') |
10 changes: 10 additions & 0 deletions
10
test cases/common/250 sanitizer/subprojects/new_behavior/meson.build
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,10 @@ | ||
project( | ||
'sanitizer-new-behavior', | ||
'c', | ||
# XXX: this should be 0.62, but there's no way to test it until we actuall bump to 0.62… | ||
meson_version : '>= 0.61.99', | ||
) | ||
|
||
sanitize = get_option('b_sanitize') | ||
|
||
assert(sanitize == ['undefined', 'address'], ','.join(sanitize)) |
9 changes: 9 additions & 0 deletions
9
test cases/common/250 sanitizer/subprojects/old_behavior/meson.build
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 @@ | ||
project( | ||
'sanitizer-old-behavior', | ||
'c', | ||
meson_version : '>= 0.55', | ||
) | ||
|
||
sanitize = get_option('b_sanitize') | ||
|
||
assert(sanitize == 'address,undefined', sanitize) |
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