Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/markdown/Builtin-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ available on all platforms or with all compilers:
| b_pgo | off | off, generate, use | Use profile guided optimization |
| b_sanitize | none | see below | Code sanitizer to use |
| b_staticpic | true | true, false | Build static libraries as position independent |
| b_time64 | false | true, false | Enable 64-bit time handling for 32-bit platforms (via `_TIME_BITS=64`) |
| b_pie | false | true, false | Build position-independent executables (since 0.49.0) |
| b_vscrt | from_buildtype | none, md, mdd, mt, mtd, from_buildtype, static_from_buildtype | VS runtime library to use (since 0.48.0) (static_from_buildtype since 0.56.0) |

Expand Down
12 changes: 12 additions & 0 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ def get_base_compile_args(target: 'BuildTarget', compiler: 'Compiler', env: 'Env
pass
except KeyError:
pass
try:
if env.coredata.get_option_for_target(target, 'b_time64'):
args += compiler.get_time64_args()
except (KeyError, AttributeError):
pass
return args

def get_base_link_args(target: 'BuildTarget',
Expand Down Expand Up @@ -1095,6 +1100,13 @@ def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
"""
return []

def get_time64_args(self) -> T.List[str]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually implement these as something like:

def get_time64_args(self, enable: bool) -> T.List[str]:
    return ['-D_TIME_BITS=64'] if enable else []

So that you don't have to have the check in every caller.

"""Get arguments to enable 64-bit time handling for 32-bit platforms.

:return: A list of string arguments for this compiler
"""
return []

def get_crt_val(self, crt_val: str, buildtype: str) -> str:
if crt_val in options.MSCRT_VALS:
return crt_val
Expand Down
3 changes: 3 additions & 0 deletions mesonbuild/compilers/mixins/clike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,9 @@ def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
return ['-DNDEBUG']
return []

def get_time64_args(self) -> T.List[str]:
return ['-D_TIME_BITS=64']

@functools.lru_cache(maxsize=None)
def can_compile(self, src: 'mesonlib.FileOrString') -> bool:
# Files we preprocess can be anything, e.g. .in
Expand Down
5 changes: 5 additions & 0 deletions mesonbuild/modules/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu
if are_asserts_disabled_for_subproject(state.subproject, state.environment):
clang_args.append('-DNDEBUG')

time64 = state.get_option('b_time64', state.subproject)
assert isinstance(time64, bool), 'for mypy'
if time64:
clang_args.append('-D_TIME_BITS=64')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a recent change here that with the _FILE_OFFSET bits maybe we can add this to the same block? (it uses the CCompiler instance so we avoid the need to copy the define here)


for de in kwargs['dependencies']:
for i in de.get_include_dirs():
clang_args.extend([f'-I{x}' for x in i.to_string_list(
Expand Down
1 change: 1 addition & 0 deletions mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ def option_to_argparse(option: AnyOptionType, name: OptionKey, parser: argparse.
UserComboOption(
'b_ndebug', 'Disable asserts', 'false', choices=['true', 'false', 'if-release']),
UserBooleanOption('b_staticpic', 'Build static libraries as position independent', True),
UserBooleanOption('b_time64', 'Set _TIME_BITS=64', False),
UserBooleanOption('b_pie', 'Build executables as position independent', False),
UserBooleanOption('b_bitcode', 'Generate and embed bitcode (only macOS/iOS/tvOS)', False),
UserComboOption(
Expand Down
Loading