Skip to contentSkip to conversation

tclibc-musl.inc: fix bfd "cannot make copy relocation for protected symbol" issues

PATCH In review [email protected] 3 participants 6 messages Jul 22, 2017 – Aug 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tclibc-musl.inc: fix bfd "cannot make copy relocation for protected symbol" issues

From: Ming Liu <[email protected]>

Quite a few such compiling issues were found when I was building with following configs:
...
MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

fixed by adding bfd binding now ldflags.

---
 meta/conf/distro/include/tclibc-musl.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/conf/distro/include/tclibc-musl.inc +4 -0
index 3d3f6ac..99d52a1 100644
@@ -18,6 +18,10 @@ PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?= "nativesdk-glibc"
 
 CXXFLAGS += "-fvisibility-inlines-hidden"
 
+# Workaround for musl libc does not support bfd lazy binding well
+# Refer to: https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679
+LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '-Wl,-z,relro,-z,now -fuse-ld=bfd', '', d)}"
+
 IMAGE_LINGUAS = ""
 
 LIBC_DEPENDENCIES = "\
Signature · 1 line
2.7.4
#1 lore raw

If we're going to silently change the linker to bfd under musl if ld-is-gold is selected, wouldn't it be better just to throw an exception if both musl and ld-is-gold are selected? Better to tell the user so they can not do that than silently ignore what they asked.

Ross

Quoted 39 lines · On 22 July 2017 at 14:30, <[email protected]> wrote:

From: Ming Liu <[email protected]>

Quite a few such compiling issues were found when I was building with following configs:
...
MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

fixed by adding bfd binding now ldflags.

---
 meta/conf/distro/include/tclibc-musl.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/conf/distro/include/tclibc-musl.inc +0 -0
index 3d3f6ac..99d52a1 100644
@@ -18,6 +18,10 @@ PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?=

"nativesdk-glibc"

CXXFLAGS += "-fvisibility-inlines-hidden"

meta/conf/distro/include/tclibc-musl.inc +3 -0
+# Workaround for musl libc does not support bfd lazy binding well
+# Refer to: https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679
+LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold',

'-Wl,-z,relro,-z,now -fuse-ld=bfd', '', d)}"
+
IMAGE_LINGUAS = ""

LIBC_DEPENDENCIES = "\
--
2.7.4

#2 lore raw
Quoted 4 lines · Ross

If we're going to silently change the linker to bfd under musl if ld-is-gold is selected, wouldn't it be better just to throw an exception if both musl and ld-is-gold are selected? Better to tell the user so they can not do that than silently ignore what they asked.

yes, that would be better but I am skeptical of disabling it completely, we should
create testcase and report it to binutils bugzilla

Quoted 51 lines

Ross

Quoted 35 lines · On 22 July 2017 at 14:30, <[email protected]> wrote:

From: Ming Liu <[email protected]>

Quite a few such compiling issues were found when I was building with following configs:
...
MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

fixed by adding bfd binding now ldflags.

---
 meta/conf/distro/include/tclibc-musl.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/conf/distro/include/tclibc-musl.inc +0 -0
index 3d3f6ac..99d52a1 100644
@@ -18,6 +18,10 @@ PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?=

"nativesdk-glibc"

CXXFLAGS += "-fvisibility-inlines-hidden"

meta/conf/distro/include/tclibc-musl.inc +3 -0
+# Workaround for musl libc does not support bfd lazy binding well
+# Refer to: https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679
+LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold',

'-Wl,-z,relro,-z,now -fuse-ld=bfd', '', d)}"
+
IMAGE_LINGUAS = ""

Quoted 4 lines

LIBC_DEPENDENCIES = "\
--
2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#3 lore raw

Hi, Burton:

I also agree with you, your suggestion is better.

Hi, Khem:

But is this a bug of binutils? Or musl libc? Since I had only observed this error with musl libc only, it did not occur with glibc.

//Ming Liu

2017-07-24 15:39 GMT+02:00 Khem Raj <[email protected]>:

Quoted 66 lines
Quoted 1 line · Ross

If we're going to silently change the linker to bfd under musl if

ld-is-gold

Quoted 1 line

is selected, wouldn't it be better just to throw an exception if both

musl

Quoted 2 lines

and ld-is-gold are selected? Better to tell the user so they can not do that than silently ignore what they asked.

yes, that would be better but I am skeptical of disabling it completely, we should
create testcase and report it to binutils bugzilla

Quoted 51 lines

Ross

Quoted 35 lines · On 22 July 2017 at 14:30, <[email protected]> wrote:

From: Ming Liu <[email protected]>

Quite a few such compiling issues were found when I was building with following configs:
...
MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

fixed by adding bfd binding now ldflags.

---
 meta/conf/distro/include/tclibc-musl.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/conf/distro/include/tclibc-musl.inc +0 -0
index 3d3f6ac..99d52a1 100644
@@ -18,6 +18,10 @@ PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?=

"nativesdk-glibc"

CXXFLAGS += "-fvisibility-inlines-hidden"

meta/conf/distro/include/tclibc-musl.inc +3 -0
+# Workaround for musl libc does not support bfd lazy binding well
+# Refer to: https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679
+LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold',

'-Wl,-z,relro,-z,now -fuse-ld=bfd', '', d)}"
+
IMAGE_LINGUAS = ""

Quoted 4 lines

LIBC_DEPENDENCIES = "\
--
2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#4 lore raw
Quoted 9 lines · Ming Liu

Hi, Burton:

I also agree with you, your suggestion is better.

Hi, Khem:

But is this a bug of binutils? Or musl libc? Since I had only observed this error with musl libc only, it did not occur with glibc.

Please try out a tentative patch here
https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679#c4

Quoted 71 lines

//Ming Liu

2017-07-24 15:39 GMT+02:00 Khem Raj <[email protected]>:

Quoted 66 lines
Quoted 6 lines · Ross

If we're going to silently change the linker to bfd under musl if ld-is-gold
is selected, wouldn't it be better just to throw an exception if both musl
and ld-is-gold are selected? Better to tell the user so they can not do that than silently ignore what they asked.

yes, that would be better but I am skeptical of disabling it completely, we should
create testcase and report it to binutils bugzilla

Quoted 51 lines

Ross

Quoted 35 lines · On 22 July 2017 at 14:30, <[email protected]> wrote:

From: Ming Liu <[email protected]>

Quite a few such compiling issues were found when I was building with following configs:
...
MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

fixed by adding bfd binding now ldflags.

---
 meta/conf/distro/include/tclibc-musl.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/conf/distro/include/tclibc-musl.inc +0 -0
index 3d3f6ac..99d52a1 100644
@@ -18,6 +18,10 @@ PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?=

"nativesdk-glibc"

CXXFLAGS += "-fvisibility-inlines-hidden"

meta/conf/distro/include/tclibc-musl.inc +3 -0
+# Workaround for musl libc does not support bfd lazy binding well
+# Refer to: https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679
+LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold',

'-Wl,-z,relro,-z,now -fuse-ld=bfd', '', d)}"
+
IMAGE_LINGUAS = ""

Quoted 4 lines

LIBC_DEPENDENCIES = "\
--
2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#5 lore raw

Hi, Khem:

Just tried, but the error still could be observed with the patch applied, 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

//Ming Liu

2017-07-31 23:56 GMT+02:00 Khem Raj <[email protected]>:

Quoted 88 lines · Ming Liu
Quoted 7 lines

Hi, Burton:

I also agree with you, your suggestion is better.

Hi, Khem:

But is this a bug of binutils? Or musl libc? Since I had only observed

this

Quoted 2 lines

error with musl libc only, it did not occur with glibc.

Please try out a tentative patch here
https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679#c4

Quoted 11 lines

//Ming Liu

2017-07-24 15:39 GMT+02:00 Khem Raj <[email protected]>:

Quoted 8 lines
Quoted 5 lines · Ross

If we're going to silently change the linker to bfd under musl if ld-is-gold
is selected, wouldn't it be better just to throw an exception if both musl
and ld-is-gold are selected? Better to tell the user so they can not

do

Quoted 60 lines
Quoted 58 lines
Quoted 1 line

that than silently ignore what they asked.

yes, that would be better but I am skeptical of disabling it completely, we should
create testcase and report it to binutils bugzilla

Quoted 51 lines

Ross

Quoted 35 lines · On 22 July 2017 at 14:30, <[email protected]> wrote:

From: Ming Liu <[email protected]>

Quite a few such compiling issues were found when I was building with following configs:
...
MACHINE = "beaglebone"
TCLIBC = "musl"
DISTRO_FEATURES_append = " ld-is-gold"
...

fixed by adding bfd binding now ldflags.

---
 meta/conf/distro/include/tclibc-musl.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/conf/distro/include/tclibc-musl.inc +0 -0
index 3d3f6ac..99d52a1 100644
@@ -18,6 +18,10 @@ PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?=

"nativesdk-glibc"

CXXFLAGS += "-fvisibility-inlines-hidden"

meta/conf/distro/include/tclibc-musl.inc +3 -0
+# Workaround for musl libc does not support bfd lazy binding well
+# Refer to: https://bugzilla.yoctoproject.org/show_bug.cgi?id=11679
+LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold',

'-Wl,-z,relro,-z,now -fuse-ld=bfd', '', d)}"
+
IMAGE_LINGUAS = ""

Quoted 4 lines

LIBC_DEPENDENCIES = "\
--
2.7.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core