Skip to content

Fix symbol versioning with LLD#326

Merged
janbrummer merged 1 commit intomainfrom
map-file-check
Jun 27, 2025
Merged

Fix symbol versioning with LLD#326
janbrummer merged 1 commit intomainfrom
map-file-check

Conversation

@janbrummer
Copy link
Copy Markdown
Contributor

Fixes: #320

@janbrummer
Copy link
Copy Markdown
Contributor Author

@DimStar77 A little bit different as we have discussed, but maybe this is a better solution?

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.37%. Comparing base (08069f7) to head (1b8b504).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #326   +/-   ##
=======================================
  Coverage   69.37%   69.37%           
=======================================
  Files          18       18           
  Lines         937      937           
  Branches      267      267           
=======================================
  Hits          650      650           
  Misses        174      174           
  Partials      113      113           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DimStar77
Copy link
Copy Markdown
Contributor

@DimStar77 A little bit different as we have discussed, but maybe this is a better solution?

Could probably work. Not sure though if just disarming stricter (not wrong) compiler behaviour for our own sake is the right approach

@janbrummer
Copy link
Copy Markdown
Contributor Author

Ok, because the proposed empty map check just fails on my system

@eli-schwartz
Copy link
Copy Markdown

@DimStar77 A little bit different as we have discussed, but maybe this is a better solution?

Has this in fact been checked at all?

Because it very plainly CANNOT have any effect on the reported bug at all, which was about the line

if cc.has_multi_link_arguments(vscript)

producing the word "NO". Therefore the build is configured to not use symbol versions.

This PR still reports that LLD does not support version scripts (the map file fails to test-link) at configuration time and then passes an unused (no version file is being used) -Wl,--undefined-version argument at compilation time

$ LDFLAGS="-fuse-ld=lld" meson setup builddir/

[...]

Compiler for C supports link arguments -Wl,--undefined-version: YES 
Compiler for C supports link arguments -Wl,--version-script,/tmp/libproxy/src/libproxy/libproxy.map: NO 

@eli-schwartz
Copy link
Copy Markdown

eli-schwartz commented Jun 4, 2025

As I said in the linked issue:

This is a configure probe check. It is checking to see if the linker (LLD) understands how to interpret a --version-script. That's entirely fine, as long as the version map is also passed when compiling the libproxy.so shared library.

Unfortunately LLD has decided to do the linker equivalent of compiling with -Werror=unused-function. Specifically, ld.bfd's -Wl,--no-undefined-version is the default for LLD. [...]

@jpalus
Copy link
Copy Markdown

jpalus commented Jun 4, 2025

You could possibly go with just:

if cc.has_link_argument(vscript) or cc.has_multi_link_arguments([vscript, '-Wl,--undefined-version'])
  vflag += vscript
endif

Maybe not the most pretty to have double check but works.

@TijlCoosemans
Copy link
Copy Markdown

Ok, because the proposed empty map check just fails on my system

Can you give some information about this failure? The empty.map file should look like this:

LIBPROXY_0.4.16 {
};

LIBPROXY_0.5.5 {
} LIBPROXY_0.4.16;

@janbrummer
Copy link
Copy Markdown
Contributor Author

I do not have this linker on my system, so i proposed this PR and asked for feedback. I'm sorry that it does not fit your needs, but I'm sure we will come up with a good solution. Is the solutions from @jpalus fine then?

@TijlCoosemans I actually had a real empty file as we have just pushed in the last PR.

@eli-schwartz
Copy link
Copy Markdown

Is the solutions from @jpalus fine then?

Yes. And you do need both parts of the "or", due to binutils < 2.40: https://github.com/bminor/binutils-gdb/commit/27fb6a1a7fcd047e7d01bef8e3c12ed67bc7aed0

@TijlCoosemans
Copy link
Copy Markdown

@TijlCoosemans I actually had a real empty file as we have just pushed in the last PR.

That gives the error ld: error: .../src/libproxy/test.map:1: unexpected EOF. It works if you add TEST {}; to test.map.

@janbrummer
Copy link
Copy Markdown
Contributor Author

@trisk Could you please check whether the suggested change is also fine for Solaris?

@trisk
Copy link
Copy Markdown
Contributor

trisk commented Jun 17, 2025

@trisk Could you please check whether the suggested change is also fine for Solaris?

It works if I put TEST { local: *; }; in the mapfile.
Otherwise the default disposition of symbols is unspecified:

Undefined                       first referenced
 symbol                             in file
main                                /var/tmp/testfile-2c26bd.o  (symbol has no version assigned)

@TijlCoosemans
Copy link
Copy Markdown

@trisk Could you please check whether the suggested change is also fine for Solaris?

It works if I put TEST { local: *; }; in the mapfile. Otherwise the default disposition of symbols is unspecified:

TEST { local: *; }; is okay here as well.

@janbrummer
Copy link
Copy Markdown
Contributor Author

I've pushed a new version, could everybody please check their systems? In case this one is ready I'm going to release a new version

@trisk
Copy link
Copy Markdown
Contributor

trisk commented Jun 25, 2025

Looks good to me.

@TijlCoosemans
Copy link
Copy Markdown

Works here too, but you can remove or cc.has_multi_link_arguments([vscript_test, '-Wl,--undefined-version']). There are no undefined versions or unknown symbols in test.map.

@jpalus
Copy link
Copy Markdown

jpalus commented Jun 25, 2025

Works fine for me too with both lld and mold, although variant with '-Wl,--undefined-version' worked fine in both cases as well.

@janbrummer janbrummer merged commit 0420c50 into main Jun 27, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

symbol versioning fails with LLD

6 participants