Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix link error with LLD 17 #1051

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

yasuhirokimura
Copy link

Developers of FreeBSD base system are currently working to upgrade its LLVM/Clang/LLDB/LLD to 17. As a part of it they tried building all ports in FreeBSD ports collections to check if build of them succeeds with LLVM/Clang/LLD 17. As a result there are some ports that fail to be built with it and unfortunately security/clamav is one of them. The build of it fails with link error as following.

  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_cvdunpack' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_dbgmsg_internal' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'init_domainlist' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'init_whitelist' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_parse_add' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_bytecode_context_clear' failed: symbol not defined
  cc: error: linker command failed with exit code 1 (use -v to see invocation)

According to the investigation of ClamAV's source code, cli_cvdunpack is a static function so it isn't visible to external consumers. And other mentioned symbols aren't found anywhere. So fix link error by removing all of them from linker version script.

Developers of FreeBSD base system are currently working to upgrade its
LLVM/Clang/LLDB/LLD to 17. As a part of it they tried building all
ports in FreeBSD ports collections to check if build of them succeeds
with LLVM/Clang/LLD 17. As a result there are some ports that fail to
be built with it and unfortunately `security/clamav` is one of
them. The build of it fails with link error as following.

```
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_cvdunpack' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_dbgmsg_internal' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'init_domainlist' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'init_whitelist' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_parse_add' failed: symbol not defined
  ld: error: version script assignment of 'CLAMAV_PRIVATE' to symbol 'cli_bytecode_context_clear' failed: symbol not defined
  cc: error: linker command failed with exit code 1 (use -v to see invocation)
```

According to the investigation of ClamAV's source code,
`cli_cvdunpack` is a static function so it isn't visible to external
consumers. And other mentioned symbols aren't found anywhere. So fix
link error by removing all of them from linker version script.
@micahsnyder
Copy link
Contributor

Thanks @yasuhirokimura these changes make sense to me. Will run through the test pipelines and merge if all goes well.

I imagine we should backport this change to other versions as well.

@micahsnyder micahsnyder added the 🍒cherry-pick-candidate A PR that should be backported once approved. label Oct 13, 2023
@micahsnyder
Copy link
Contributor

The code change makes sense to me. Functions that either don't exist (or are static and happen to not be used) should not be exported in the libclamav.map file.

We can backport this as far as 1.0.x. And probably should, because 1.0.x is LTS and will be used for a long a couple more years.

We could backport to 0.103.x as well if we remove the change to cli_cvdunpack because that function is used outside libclamav in 0.103. However, I don't think it's worth the effort. 0.103 has less than 1 year of life left and systems running clang-17 should be able to use the newer clamav.

I tried testing with clang-17/clang++-17/lld-17 on ubuntu:22.04 to verify the failure and fix. I did not see any failure, so I'm unsure why it's failing on FreeBSD. But the change still makes sense so I'm not going to fuss about it.

@micahsnyder micahsnyder merged commit 14d7d21 into Cisco-Talos:main Oct 17, 2023
23 checks passed
@yasuhirokimura yasuhirokimura deleted the fix_build_with_lld_17 branch October 19, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒cherry-pick-candidate A PR that should be backported once approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants