Skip to contentSkip to conversation

libkrb5: fix build on riscv

PATCH New Fabrice Fontaine 2 participants 7 messages Nov 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libkrb5: fix build on riscv

Define _REENTRANT otherwise pthread detection will fail

Fixes:
- http://autobuild.buildroot.org/results/39a51d0c3feab74edd8a17c9174d031ccc7ffe1d

---
 package/libkrb5/libkrb5.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
package/libkrb5/libkrb5.mk +8 -1
index d9d7160ae8..6534c069ee 100644
@@ -52,7 +52,14 @@ else
 LIBKRB5_CONF_OPTS += --without-readline
 endif
 
-ifneq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+# gcc on riscv doesn't define _REENTRANT when -pthread is passed while
+# it should. Compensate this deficiency here otherwise libkrb5 configure
+# script doesn't find that thread support is enabled.
+ifeq ($(BR2_riscv),y)
+LIBKRB5_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -D_REENTRANT"
+endif
+else
 LIBKRB5_CONF_OPTS += --disable-thread-support
 endif
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 libkrb5: fix build on riscv

Hello,

Quoted 16 lines · Fabrice Fontaine

Define _REENTRANT otherwise pthread detection will fail

Fixes:
- http://autobuild.buildroot.org/results/39a51d0c3feab74edd8a17c9174d031ccc7ffe1d

---
 package/libkrb5/libkrb5.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
package/libkrb5/libkrb5.mk +0 -0
index d9d7160ae8..6534c069ee 100644
@@ -52,7 +52,14 @@ else
 LIBKRB5_CONF_OPTS += --without-readline

package/libkrb5/libkrb5.mk else · line 61

Quoted 10 lines
package/libkrb5/libkrb5.mk +7 -1
 endif
 
-ifneq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+# gcc on riscv doesn't define _REENTRANT when -pthread is passed while
+# it should. Compensate this deficiency here otherwise libkrb5 configure
+# script doesn't find that thread support is enabled.
+ifeq ($(BR2_riscv),y)
+LIBKRB5_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -D_REENTRANT"
+endif

You did a similar change in libmicrothttpd, for which the same fix was already done for ARC. Any idea why libmicrohttpd needs this hack for both ARC and RISC-V, while libkrb5 would need it only for RISC-V ?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 libkrb5: fix build on riscv

Dear Thomas,
Le dim. 11 nov. 2018 ? 20:53, Thomas Petazzoni
<[email protected]> a ?crit :

Quoted 22 lines

Hello,

Quoted 18 lines · Fabrice Fontaine

Define _REENTRANT otherwise pthread detection will fail

Fixes:
- http://autobuild.buildroot.org/results/39a51d0c3feab74edd8a17c9174d031ccc7ffe1d

---
 package/libkrb5/libkrb5.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
package/libkrb5/libkrb5.mk +0 -0
index d9d7160ae8..6534c069ee 100644
@@ -52,7 +52,14 @@ else
 LIBKRB5_CONF_OPTS += --without-readline
 endif
 
Quoted 12 lines

package/libkrb5/libkrb5.mk else · line 61

Quoted 8 lines
package/libkrb5/libkrb5.mk +7 -1
-ifneq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+# gcc on riscv doesn't define _REENTRANT when -pthread is passed while
+# it should. Compensate this deficiency here otherwise libkrb5 configure
+# script doesn't find that thread support is enabled.
+ifeq ($(BR2_riscv),y)
+LIBKRB5_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -D_REENTRANT"
+endif

You did a similar change in libmicrothttpd, for which the same fix was already done for ARC. Any idea why libmicrohttpd needs this hack for both ARC and RISC-V, while libkrb5 would need it only for RISC-V ?

I didn't try to build libkrb5 on ARC but I found that back in 2016, for libmicrohttpd, you were writing that "Fixing the compilers is definitely the right thing to do":
https://patchwork.ozlabs.org/patch/643857.
Perhaps since that time, the ARC toolchains have been fixed?

Quoted 8 lines

Thanks,

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Best Regards,

Fabrice

#3 lore raw

PATCH 1/1 libkrb5: fix build on riscv

Hello,

Quoted 8 lines · Fabrice Fontaine
Quoted 3 lines

You did a similar change in libmicrothttpd, for which the same fix was already done for ARC. Any idea why libmicrohttpd needs this hack for both ARC and RISC-V, while libkrb5 would need it only for RISC-V ?

I didn't try to build libkrb5 on ARC but I found that back in 2016, for libmicrohttpd, you were writing that "Fixing the compilers is definitely the right thing to do":
https://patchwork.ozlabs.org/patch/643857.
Perhaps since that time, the ARC toolchains have been fixed?

Indeed! It was fixed in the following gcc commit:

commit de4c7f60f2891193bf3f5da823b17fa0d7fd4830

Author: claziss <claziss@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Mar 28 08:56:44 2017 +0000

[ARC] Define _REENTRANT when -pthread is passed.

The compiler is supposed to have the builtin defined _REENTRANT defined when -pthread is passed, which wasn't done on the ARC architecture.

When _REENTRANT is not passed, the C library will not use reentrant functions, and the latest version of ax_pthread.m4 from the autoconf-archive will no longer detect that thread support is available (see https://savannah.gnu.org/patch/?8186).

gcc/
2017-03-28 Claudiu Zissulescu <[email protected]>
Thomas Petazzoni <[email protected]>

* config/arc/arc.h (CPP_SPEC): Add subtarget_cpp_spec. (EXTRA_SPECS): Define. (SUBTARGET_EXTRA_SPECS): Likewise. (SUBTARGET_CPP_SPEC): Likewise.
* config/arc/elf.h (EXTRA_SPECS): Renamed to SUBTARGET_EXTRA_SPECS.
* config/arc/linux.h (SUBTARGET_CPP_SPEC): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk at 246524 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/config/arc/linux.h +5 -0
index 6e1a96efc23..83e5a1d61f2 100644
@@ -78,3 +78,8 @@ along with GCC; see the file COPYING3.  If not see
 /* Linux toolchains use r25 as the thread pointer register.  */
 #undef TARGET_ARC_TP_REGNO_DEFAULT
 #define TARGET_ARC_TP_REGNO_DEFAULT 25
+
+#undef SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC "\
+   %{pthread:-D_REENTRANT} \
+"

This commit is in gcc upstream since gcc 7.1.0. So I guess we could drop the ARC-specific workaround on libmicrohttpd, since we don't really support "old" gcc versions on ARC anyway.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 libkrb5: fix build on riscv

Dear Thomas,
Le dim. 11 nov. 2018 ? 21:31, Thomas Petazzoni
<[email protected]> a ?crit :

Quoted 58 lines

Hello,

Quoted 8 lines · Fabrice Fontaine
Quoted 3 lines

You did a similar change in libmicrothttpd, for which the same fix was already done for ARC. Any idea why libmicrohttpd needs this hack for both ARC and RISC-V, while libkrb5 would need it only for RISC-V ?

I didn't try to build libkrb5 on ARC but I found that back in 2016, for libmicrohttpd, you were writing that "Fixing the compilers is definitely the right thing to do":
https://patchwork.ozlabs.org/patch/643857.
Perhaps since that time, the ARC toolchains have been fixed?

Indeed! It was fixed in the following gcc commit:

commit de4c7f60f2891193bf3f5da823b17fa0d7fd4830

Author: claziss <claziss@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Mar 28 08:56:44 2017 +0000

[ARC] Define _REENTRANT when -pthread is passed.

The compiler is supposed to have the builtin defined _REENTRANT defined when -pthread is passed, which wasn't done on the ARC architecture.

When _REENTRANT is not passed, the C library will not use reentrant functions, and the latest version of ax_pthread.m4 from the autoconf-archive will no longer detect that thread support is available (see https://savannah.gnu.org/patch/?8186).

gcc/
2017-03-28 Claudiu Zissulescu <[email protected]>
Thomas Petazzoni <[email protected]>

* config/arc/arc.h (CPP_SPEC): Add subtarget_cpp_spec. (EXTRA_SPECS): Define. (SUBTARGET_EXTRA_SPECS): Likewise. (SUBTARGET_CPP_SPEC): Likewise.
* config/arc/elf.h (EXTRA_SPECS): Renamed to SUBTARGET_EXTRA_SPECS.
* config/arc/linux.h (SUBTARGET_CPP_SPEC): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk at 246524 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/config/arc/linux.h +5 -0
index 6e1a96efc23..83e5a1d61f2 100644
@@ -78,3 +78,8 @@ along with GCC; see the file COPYING3.  If not see
 /* Linux toolchains use r25 as the thread pointer register.  */
 #undef TARGET_ARC_TP_REGNO_DEFAULT
 #define TARGET_ARC_TP_REGNO_DEFAULT 25
+
+#undef SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC "\
+   %{pthread:-D_REENTRANT} \
+"
Quoted 3 lines

This commit is in gcc upstream since gcc 7.1.0. So I guess we could drop the ARC-specific workaround on libmicrohttpd, since we don't really support "old" gcc versions on ARC anyway.

OK, are you ok to do this patch? I assume that the patch on libmicrohttpd for riscv is still valid or do you want that I made a patch serie on libmicrohttpd?

Quoted 8 lines

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Best Regards,

Fabrice

#5 lore raw

PATCH 1/1 libkrb5: fix build on riscv

Hello,

Quoted 6 lines · Fabrice Fontaine
Quoted 3 lines

This commit is in gcc upstream since gcc 7.1.0. So I guess we could drop the ARC-specific workaround on libmicrohttpd, since we don't really support "old" gcc versions on ARC anyway.

OK, are you ok to do this patch? I assume that the patch on libmicrohttpd for riscv is still valid or do you want that I made a patch serie on libmicrohttpd?

I applied your libmicrohttpd patch, and I'll do the same with the libkrb5 patch. We can drop the libmicrohttpd work-around for ARC at a later point.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

PATCH 1/1 libkrb5: fix build on riscv

In reply to Fabrice Fontaine

Hello,

Quoted 9 lines · Fabrice Fontaine

Define _REENTRANT otherwise pthread detection will fail

Fixes:
- http://autobuild.buildroot.org/results/39a51d0c3feab74edd8a17c9174d031ccc7ffe1d

---
 package/libkrb5/libkrb5.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com