Bug 1697870

Summary: fails to build with llvm/clang/lld on musl
Product: [Community] LVM and device-mapper Reporter: David Demelier <markand>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: libdevmapper QA Contact: cluster-qe <cluster-qe>
Status: POST --- Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, heinzm, i, jbrassow, msnitzer, prajnoha, sam, zkabelac
Version: 2.02.183, 0-beta1Flags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Demelier 2019-04-09 08:31:24 UTC
Description of problem:

Impossible to build lvm2 with llvm/clang/lld 8.0.0

Version-Release number of selected component (if applicable):

2.02..183

Steps to Reproduce:

Try to build using CC=clang (clang being compiled to use ld.lld by default)

Actual results:

Fails with:

    [CC] ioctl/libdevmapper.so.1.02
ld.lld: error: duplicate symbol 'dm_bitset_parse_list' in version script
ld.lld: error: duplicate symbol 'dm_stats_create_region' in version script
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [../make.tmpl:469: ioctl/libdevmapper.so.1.02] Error 1
make[1]: Leaving directory '/usr/src/vanilla/core/lvm2/LVM2.2.02.183/libdm'
make: *** [make.tmpl:356: libdm.device-mapper] Error 2

Comment 1 Zdenek Kabelac 2019-07-11 10:36:16 UTC
No aware of any issues so far.

Using  clang-8.0.0-3.fc31.x86_64
and compiling  current git  stable-2.02  branch   2.02.186(2)-git (2019-05-13)

works for me just fine   (aka   'make CC=clang' passed)

So can we get more logs ?

What do I need for better reproduction ?

Comment 2 David Demelier 2019-07-11 12:03:11 UTC
I think you have used the default linker. Your fedora uses GNU binutils ld while in my report I've reported that the linker is lld (from LLVM) so CC=clang was not sufficient. My bad I've not mentioned that my clang is built to use lld by default rather than binutils.

I don't have a machine to test right now but maybe you can try something like:

make CC=clang CFLAGS="-fuse-ld=lld" or LDFLAGS="-fuse-ld=lld" maybe?

Cheers

Comment 3 Zdenek Kabelac 2019-07-12 13:19:23 UTC
Ok - I guess patch like this fixes the issue for this moment.

It's not completely nice - but gives you workable building tree.


diff --git a/libdm/.exported_symbols.DM_1_02_107 b/libdm/.exported_symbols.DM_1_02_107
index 89d3464ac..258883c14 100644
--- a/libdm/.exported_symbols.DM_1_02_107
+++ b/libdm/.exported_symbols.DM_1_02_107
@@ -9,7 +9,6 @@ dm_histogram_get_bin_width
 dm_histogram_get_nr_bins
 dm_histogram_get_sum
 dm_histogram_to_string
-dm_stats_create_region
 dm_stats_driver_supports_histogram
 dm_stats_get_histogram
 dm_stats_get_region_nr_histogram_bins
diff --git a/libdm/.exported_symbols.DM_1_02_129 b/libdm/.exported_symbols.DM_1_02_129
index 88d3f1b6b..6ae173a83 100644
--- a/libdm/.exported_symbols.DM_1_02_129
+++ b/libdm/.exported_symbols.DM_1_02_129
@@ -1,4 +1,3 @@
-dm_bitset_parse_list
 dm_stats_create_group
 dm_stats_current_object_type
 dm_stats_delete_group
--

Comment 4 Fangrui Song 2019-07-12 14:52:52 UTC
See https://reviews.llvm.org/D64549 I think this is a bug (duplicate version assignments) in lvm2, though ld.bfd doesn't warn.

In the generated lvm2/libdm/.export.sym

DM_1_02_138 { global: ... dm_bitset_parse_list; ... };
DM_1_02_129 { global: ... dm_bitset_parse_list; ... };   // dm_bitset_parse_list should be removed from the list

D64549 will be included in lld 9.0.0 . It will give a friendly warning.

Comment 5 David Demelier 2019-07-13 14:05:31 UTC
Thanks it works fine with that patch. But just curious, why do you think it is not nice as proposed?

Comment 6 Jonathan Earl Brassow 2019-08-06 00:56:02 UTC
fixed?  if so, what version?