Bug 11679 - "cannot make copy relocation for protected symbol" build errors with musl and ld-is-gold
Summary: "cannot make copy relocation for protected symbol" build errors with musl an...
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.4
Hardware: BeagleBone arm
: Medium+ major
Target Milestone: 2.4 M3
Assignee: Khem Raj
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-06-16 11:47 UTC by Ming Liu
Modified: 2017-08-16 16:23 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Workaround patch (10.60 KB, patch)
2017-06-16 11:47 UTC, Ming Liu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ming Liu 2017-06-16 11:47:55 UTC
Created attachment 3827 [details]
Workaround patch

I observed quite a few "cannot make copy relocation for protected symbol" build errors among recipes, with the following config:

MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"

to give a example, the errors looks like:
......
| /home/peter-liu/opensource/poky-upstream/build/tmp/work/cortexa8hf-neon-poky-linux-musleabi/kmod/23+gitAUTOINC+65a885df5f-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-musleabi/../../libexec/arm-poky-linux-musleabi/gcc/arm-poky-linux-musleabi/6.3.0/ld: error: tools/kmod.o: cannot make copy relocation for protected symbol 'program_invocation_short_name', defined in /home/peter-liu/opensource/poky-upstream/build/tmp/work/cortexa8hf-neon-poky-linux-musleabi/kmod/23+gitAUTOINC+65a885df5f-r0/recipe-sysroot/usr/lib/libc.so

......

I observed similar build errors with the following recipes:
 meta/recipes-core/coreutils/coreutils_8.27.bb
 meta/recipes-core/gettext/gettext_0.19.8.1.bb
 meta/recipes-core/glib-2.0/glib.inc
 meta/recipes-core/udev/eudev_3.2.1.bb
 meta/recipes-core/util-linux/util-linux.inc
 meta/recipes-devtools/m4/m4.inc
 meta/recipes-extended/diffutils/diffutils.inc
 meta/recipes-extended/grep/grep_3.0.bb
 meta/recipes-extended/iptables/iptables_1.6.1.bb
 meta/recipes-extended/procps/procps_3.3.12.bb
 meta/recipes-extended/xz/xz_5.2.3.bb
 meta/recipes-graphics/wayland/libinput_1.6.1.bb
 meta/recipes-graphics/xorg-xserver/xserver-xorg.inc
 meta/recipes-kernel/kmod/kmod.inc

and I noticed there is a workaround for libunwind recipe:
https://patchwork.openembedded.org/patch/132005/

So I made a patch also applying the same logic to other recipes, which seems fixed the building issues(see the attached), but it does not look like a real fix, could somebody give some input?
Comment 1 Ming Liu 2017-06-16 11:55:33 UTC
More information, I also tested with the following scenarios:
...
MACHINE = "genericx86-64"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

...
MACHINE = "beaglebone"
TCLIBC = "glibc"
DISTRO_FEATURES_append = " ld-is-gold"
...

...
MACHINE = "genericx86-64"
TCLIBC = "glibc"
DISTRO_FEATURES_append = " ld-is-gold"
...

bitbake core-image-minimal

the issue did not show up with any of the above configs, so it only impacts arm + bfd linker?
Comment 2 Khem Raj 2017-07-12 16:29:29 UTC
musl did not support lazy binding, which was added lately, however there could be issues. Although I would like you to try out the latest master where the latest musl is now in oe-core. And see if it still happens if so, I can work with community to narrow down the issue.

Meanwhile the workaround patch you posted look fine to me.
Comment 3 Ming Liu 2017-07-13 02:38:53 UTC
Hi, Khem:

I just tried out the latest poky.

In meta/recipes-core/musl/musl_git.bb:
SRCREV = "a08910fc2cc739f631b75b2d09b8d72a0d64d285"

it's the latest commit in musl as you said, but the issues are still there, I see same compiling errors as I tested last time.

I am planning to retest my workaround patch against the latest poky and send it OE mail list, to see if there is any chance it can be merged as a temporary fix before you and musl community figure out a real fix.
Comment 4 Khem Raj 2017-07-31 21:52:19 UTC
Can you test this patch please

diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index 53a8ba196a..93e3535c8d 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -36,6 +36,7 @@ CONFIGUREOPTS = " \
     --libdir=${libdir} \
     --includedir=${includedir} \
     --syslibdir=${base_libdir} \
+    --disable-visibility \
 "

 do_configure() {
Comment 5 Ming Liu 2017-08-01 02:26:49 UTC
Just tried applying this patch, but the error still could be observed, for instance:

| /home/peter-liu/opensource/poky-upstream/build/tmp/work/cortexa8hf-neon-poky-linux-musleabi/m4/1.4.18-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-musleabi/../../libexec/arm-poky-linux-musleabi/gcc/arm-poky-linux-musleabi/7.1.0/ld: error: ../lib/libm4.a(progname.o): cannot make copy relocation for protected symbol 'program_invocation_name', defined in /home/peter-liu/opensource/poky-upstream/build/tmp/work/cortexa8hf-neon-poky-linux-musleabi/m4/1.4.18-r0/recipe-sysroot/usr/lib/libc.so
| collect2: error: ld returned 1 exit status
| Makefile:1554: recipe for target 'm4' failed
Comment 6 Khem Raj 2017-08-01 07:52:26 UTC
I think I gave you converse. Can you try

--enable-visibility

instead?
Comment 7 Ming Liu 2017-08-01 08:05:41 UTC
Hi, Khem:

Just tried, still no lucky, I got the same error with:

diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index 31583de..a047ac6 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -35,6 +35,7 @@ CONFIGUREOPTS = " \
     --libdir=${libdir} \
     --includedir=${includedir} \
     --syslibdir=${base_libdir} \
+    --enable-visibility \
 "
Comment 8 Khem Raj 2017-08-01 08:09:58 UTC
(In reply to comment #6)
> I think I gave you converse. Can you try
> 
> --enable-visibility
> 
> instead?

try --disable-visibility and --enable-visibility one by one
btw you should use 

bitbake -ccleansstate musl m4
bitbake m4
Comment 9 Ming Liu 2017-08-01 08:19:30 UTC
Hi, Khem:

That exactly is what I have done.
Comment 10 Ming Liu 2017-08-01 08:23:26 UTC
> Hi, Khem:
> That exactly is what I have done.

Sorry, I just realized, I probably forgot to cleansstate when I was trying "--disable-visibility", will re-test that option.

I did cleansstate when trying "--enable-visibility" by the way.
Comment 11 Ming Liu 2017-08-01 08:50:40 UTC
Hi, Khem:

The problem seems resolved with your suggestion "--disable-visibility" if I run cleansstate musl beforehand, now I have built core-image-minimal successfully. But I would like to try to build from scratch one more time.

I am curious about the "cleansstate" thing, I do not understand why that is necessary? Since the CONFIGUREOPTS change will taint the do_configure hence will lead musl recompile, isn't that correct? If cleansstate is needed, does this mean the users would still get this problem even with your patch applied if they do not build from scratch?
Comment 12 Ming Liu 2017-08-01 12:43:50 UTC
Just tried build core-image-minimal from scratch with:

diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index 53a8ba196a..93e3535c8d 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -36,6 +36,7 @@ CONFIGUREOPTS = " \
     --libdir=${libdir} \
     --includedir=${includedir} \
     --syslibdir=${base_libdir} \
+    --disable-visibility \
 "

the problem seems fixed.
Comment 13 Khem Raj 2017-08-16 16:23:46 UTC
This is fixed by oe-core/5490efb7446196dce6a4be678263e8a73648446a