Skip to content
Open
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
10 changes: 9 additions & 1 deletion lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ elif build_machine.system() == 'freebsd'
else
# Linux and other systems
version_script_flags = '-Wl,--version-script=' + meson.current_source_dir() + '/libjose.map'
if not cc.links(code, args: version_script_flags, name: '-Wl,--version-script=...')
if cc.get_linker_id() != 'ld.lld' and not cc.links(
code,
args: version_script_flags,
name: '-Wl,--version-script=...',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both cc.links() calls use the same name: '-Wl,--version-script=...', so Meson's configure output doesn't distinguish which probe passed or failed. Maybe use different names like '-Wl,--version-script=... (plain)' and '-Wl,--version-script=... (--undefined-version)' to make build logs easier to read.

) or not cc.links(
code,
args: version_script_flags + ',--undefined-version',
name: '-Wl,--version-script=...',
)
Comment on lines +20 to +28

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In Meson, and binds tighter than or, so this condition parses as:

(cc.get_linker_id() != 'ld.lld' AND NOT cc.links(plain))
OR
(NOT cc.links(with_undefined_version))

The second clause applies to all linkers, not just lld. Since --undefined-version is an lld-only flag (introduced in LLD 16) and does not exist in GNU ld at all, the second probe will always fail on GNU ld, regressing version-script support on every GNU ld system.

Would it be better to split this into nested if/else for lld vs non-lld? That matches the FreeBSD branch pattern and avoids the precedence trap:

if cc.get_linker_id() == 'ld.lld'
  if not cc.links(code, args: version_script_flags + ',--undefined-version',
                  name: '-Wl,--version-script=... (lld)')
    flags = ['-export-symbols-regex=^jose_.*']
  else
    flags = [version_script_flags]
  endif
else
  if not cc.links(code, args: version_script_flags,
                  name: '-Wl,--version-script=...')
    flags = ['-export-symbols-regex=^jose_.*']
  else
    flags = [version_script_flags]
  endif
endif

flags = [ '-export-symbols-regex=^jose_.*' ]
else
flags = [version_script_flags]
Expand Down
Loading