Skip to content

Commit

Permalink
build: add some linker flags for optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Aug 24, 2024
1 parent 2978905 commit 7a7bd44
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ project_c_args = [
'-Wno-error=analyzer-va-arg-type-mismatch',
]
project_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
'-Wl,-z,relro', # Read-only segments after relocation
]

if get_option('buildtype') != 'plain'
Expand All @@ -117,13 +116,24 @@ endif

if get_option('optimization') in ['2', '3', 's']
project_c_args += ['-DG_DISABLE_CAST_CHECKS']
project_link_args += ['-Wl,-Bsymbolic']
project_link_args += [
'-Wl,-Bsymbolic', # Symbol visibility
'-Wl,-z,now', # Disable lazy binding (full RELRO)
'-flto', # Link-time optimization
'-fno-plt', # Avoid PLT for non-PIC code
]

if not get_option('tests')
release_args += ['-DG_DISABLE_ASSERT']
endif
endif

if get_option('b_sanitize') == 'none'
project_link_args += [
'-Wl,-z,defs', # Prevent underlinking
]
endif

if get_option('profile') == 'devel'
project_c_args += ['-Wno-error=deprecated-declarations']
endif
Expand Down

0 comments on commit 7a7bd44

Please sign in to comment.