Skip to contentSkip to conversation

toolchain/wrapper: fix building without glibc

PATCH New Marcin Chojnacki 3 participants 3 messages Dec 31, 2016 – Jan 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain/wrapper: fix building without glibc

toolchain-wrapper.c now uses program_invocation_short_name, which is a glibc specific extension. This causes build to fail when using a system with libc different than glibc (musl, BSD libc, etc.)

This change makes toolchain-wrapper.c portable, by setting it's value to getprogname() when __GLIBC__ is not defined, and thus makes running buildroot possible on glibc-less systems.

---
 toolchain/toolchain-wrapper.c | 3 +++
 1 file changed, 3 insertions(+)
toolchain/toolchain-wrapper.c +3 -0
index 100aa18..8eb0aca 100644
@@ -141,6 +141,9 @@ static void check_unsafe_path(const char *arg,
 			      int arg_has_path)
 {
 	const struct str_len_s *p;
+#ifndef __GLIBC__
+	const char *program_invocation_short_name = getprogname();
+#endif
 
 	for (p=unsafe_paths; p->str; p++) {
 		if (strncmp(path, p->str, p->len))
Signature · 1 line
2.10.1 (Apple Git-78)
#1 lore raw

PATCH 1/1 toolchain/wrapper: fix building without glibc

Hi Marcin,

Quoted 7 lines · Marcin Chojnacki

toolchain-wrapper.c now uses program_invocation_short_name, which is a glibc specific extension. This causes build to fail when using a system with libc different than glibc (musl, BSD libc, etc.)

This change makes toolchain-wrapper.c portable, by setting it's value to getprogname() when __GLIBC__ is not defined, and thus makes running buildroot possible on glibc-less systems.

getprogname() is BSD specific[1]. None of the major Linux libcs (glibc, uclibc-ng, musl) provide it.

[1] https://www.freebsd.org/cgi/man.cgi?query=getprogname&sektion=3

baruch

Quoted 19 lines
---
 toolchain/toolchain-wrapper.c | 3 +++
 1 file changed, 3 insertions(+)
toolchain/toolchain-wrapper.c +3 -0
index 100aa18..8eb0aca 100644
@@ -141,6 +141,9 @@ static void check_unsafe_path(const char *arg,
 			      int arg_has_path)
 {
 	const struct str_len_s *p;
+#ifndef __GLIBC__
+	const char *program_invocation_short_name = getprogname();
+#endif
 
 	for (p=unsafe_paths; p->str; p++) {
 		if (strncmp(path, p->str, p->len))
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#2 lore raw

PATCH 1/1 toolchain/wrapper: fix building without glibc

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Hi Marcin,

Quoted 4 lines · Marcin Chojnacki

toolchain-wrapper.c now uses program_invocation_short_name, which is a glibc specific extension. This causes build to fail when using a system with libc different than glibc (musl, BSD libc, etc.)

Quoted 8 lines
Quoted 3 lines

This change makes toolchain-wrapper.c portable, by setting it's value to getprogname() when __GLIBC__ is not defined, and thus makes running buildroot possible on glibc-less systems.

getprogname() is BSD specific[1]. None of the major Linux libcs (glibc, uclibc-ng, musl) provide it.

[1] https://www.freebsd.org/cgi/man.cgi?query=getprogname&sektion=3

Out of interest, what system are you trying to use Buildroot on? A BSD variant? I would imagine a number of other things breaking on !Linux systems.

Signature · 1 line
Bye, Peter Korsgaard