Skip to contentSkip to conversation

package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

PATCH New Yann E. MORIN 2 participants 7 messages Jul 10, 2016 – Aug 28, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

This toolchain uses glibc-2.18, which is tool old to provide O_TMPFILE, which was added only in glibc-2.19.

---
 package/systemd/Config.in | 6 ++++++
 1 file changed, 6 insertions(+)
package/systemd/Config.in +6 -0
index 4a2aa33..48e6c45 100644
@@ -145,6 +145,8 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 	bool "enable import daemon"
 	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_11 # O_TMPFILE
+	# This toolchain has glibc-2.18, too old to provide O_TMPFILE
+	depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM
 	select BR2_PACKAGE_LIBCURL
 	select BR2_PACKAGE_LIBGCRYPT
 	select BR2_PACKAGE_BZIP2
@@ -160,8 +162,12 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 
 comment "import daemon needs a toolchain w/ headers >= 3.11"
 	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM
 	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_11
 
+comment "import daemon broken on Sourcery CodeBench ARM 2014.05"
+	depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM
+
 config BR2_PACKAGE_SYSTEMD_KDBUS
 	bool "enable kdbus support"
 	help
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

Hello,

Quoted 13 lines · Yann E. MORIN

This toolchain uses glibc-2.18, which is tool old to provide O_TMPFILE, which was added only in glibc-2.19.

---
 package/systemd/Config.in | 6 ++++++
 1 file changed, 6 insertions(+)
package/systemd/Config.in +0 -0
index 4a2aa33..48e6c45 100644

package/systemd/Config.in config BR2_PACKAGE_SYSTEMD_IMPORTD · line 149

Quoted 5 lines
package/systemd/Config.in +2 -0
@@ -145,6 +145,8 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 	bool "enable import daemon"
 	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_11 # O_TMPFILE
+	# This toolchain has glibc-2.18, too old to provide O_TMPFILE
+	depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM

So is the problem a kernel headers problem, or a glibc version problem ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

Thomas, All,

On 2016-07-11 11:02 +0200, Thomas Petazzoni spake thusly:

Quoted 9 lines · Yann E. MORIN
Quoted 8 lines

This toolchain uses glibc-2.18, which is tool old to provide O_TMPFILE, which was added only in glibc-2.19.

---
 package/systemd/Config.in | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 12 lines

package/systemd/Config.in config BR2_PACKAGE_SYSTEMD_IMPORTD · line 149

Quoted 10 lines
package/systemd/Config.in +2 -0
index 4a2aa33..48e6c45 100644
@@ -145,6 +145,8 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 	bool "enable import daemon"
 	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_11 # O_TMPFILE
+	# This toolchain has glibc-2.18, too old to provide O_TMPFILE
+	depends on !BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM

So is the problem a kernel headers problem, or a glibc version problem ?

Both. O_TMPFILE was introduced in Linux 3.11, so we need at least those headers. Also, glibc-2.18 did not provide it in fcntl.h; it only appeared in glibc-2.19.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

Hello,

Quoted 5 lines · Yann E. MORIN
Quoted 1 line

So is the problem a kernel headers problem, or a glibc version problem ?

Both. O_TMPFILE was introduced in Linux 3.11, so we need at least those headers. Also, glibc-2.18 did not provide it in fcntl.h; it only appeared in glibc-2.19.

I'm still not sure to understand why both are needed.

In any case, this fix is not correct, since the issue appears with other toolchains as well:

http://autobuild.buildroot.net/results/e6f/e6f8189029487155a784b4e664178adfd92f8884/build-end.log

This one is an ARM toolchain, that uses 3.12 kernel headers, so most likely it's a glibc version issue.

http://autobuild.buildroot.net/results/339/33912eebb5f4ee3f73be078ba2035f48d76a6a46/build-end.log

This one is a PowerPC toolchain.

I see two possibilities only:

* Introduce some glibc version dependency config knobs.

* Add a workaround in the systemd code to define O_TMPFILE to the proper value when not provided by the C library.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

Thomas, All,

On 2016-08-27 23:32 +0200, Thomas Petazzoni spake thusly:

Quoted 7 lines · Yann E. MORIN
Quoted 4 lines
Quoted 1 line

So is the problem a kernel headers problem, or a glibc version problem ?

Both. O_TMPFILE was introduced in Linux 3.11, so we need at least those headers. Also, glibc-2.18 did not provide it in fcntl.h; it only appeared in glibc-2.19.

I'm still not sure to understand why both are needed.

Well, indeed, both are not needed. glibc-2.19 is enough, as it does provide it if not defined by the kernel headers.

And if the kernel headers provide it but not glibc, then it is not available. (Weird).

Quoted 7 lines

In any case, this fix is not correct, since the issue appears with other toolchains as well:

http://autobuild.buildroot.net/results/e6f/e6f8189029487155a784b4e664178adfd92f8884/build-end.log

This one is an ARM toolchain, that uses 3.12 kernel headers, so most likely it's a glibc version issue.

glibc-2.18, so too old.

Quoted 3 lines

http://autobuild.buildroot.net/results/339/33912eebb5f4ee3f73be078ba2035f48d76a6a46/build-end.log

This one is a PowerPC toolchain.

glibc-2.18 too.

Quoted 3 lines

I see two possibilities only:

* Introduce some glibc version dependency config knobs.

That's unfortunately the only sane solution, I'm araid.

But that just for systemd is big a gun... :-/

Quoted 2 lines

* Add a workaround in the systemd code to define O_TMPFILE to the proper value when not provided by the C library.

At the same time, I'm not really happy with patching systemd...

O_TMPFILE is not the same value on all archs: generic, alpha, parisc and sparc.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

Hello,

Quoted 5 lines · Yann E. MORIN
Quoted 1 line

* Introduce some glibc version dependency config knobs.

That's unfortunately the only sane solution, I'm araid.

But that just for systemd is big a gun... :-/

Yes, it sucks :-/

Quoted 7 lines
Quoted 2 lines

* Add a workaround in the systemd code to define O_TMPFILE to the proper value when not provided by the C library.

At the same time, I'm not really happy with patching systemd...

O_TMPFILE is not the same value on all archs: generic, alpha, parisc and sparc.

I must say I still don't understand the overlap of the kernel headers and glibc here.

In the kernel, we have:

include/uapi/asm-generic/fcntl.h:#define __O_TMPFILE 020000000

In glibc, we have:

sysdeps/unix/sysv/linux/bits/fcntl-linux.h:# define __O_TMPFILE (020000000 | __O_DIRECTORY)

Which is not even the same value.

Same for SPARC.

I'd still say that patching systemd is the easiest solution, and we will be able to remove this patch once we get rid of those too old toolchains (which we will have to do at some point, when they become too annoying / irrelevant).

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#6 lore raw

PATCH 1/1 package/systemd: importd broken on Sourcery CodeBench ARM 2014.05

Thomas, All,

On 2016-08-28 09:29 +0200, Thomas Petazzoni spake thusly:

Quoted 13 lines
Quoted 7 lines
Quoted 2 lines

* Add a workaround in the systemd code to define O_TMPFILE to the proper value when not provided by the C library.

At the same time, I'm not really happy with patching systemd...

O_TMPFILE is not the same value on all archs: generic, alpha, parisc and sparc.

I must say I still don't understand the overlap of the kernel headers and glibc here.

In the kernel, we have:

Quoted 7 lines

include/uapi/asm-generic/fcntl.h:#define __O_TMPFILE 020000000

In glibc, we have:

sysdeps/unix/sysv/linux/bits/fcntl-linux.h:# define __O_TMPFILE (020000000 | __O_DIRECTORY)

Which is not even the same value.

Ah, I got the answer to that one! :-)

O_TMPFILE is defined as such to be sure to break at runtime on old kernels that do not have O_TMPFILE, becasue open() silently ignores unknown flags. So, a userland app may request O_TMPFILE but silently not get it:

    https://lwn.net/Articles/558940/
Quoted 4 lines

I'd still say that patching systemd is the easiest solution, and we will be able to remove this patch once we get rid of those too old toolchains (which we will have to do at some point, when they become too annoying / irrelevant).

Fact is, upstream has a missing.h header that defines O_TMPFILE if not already defined.

But they do it only for __i386__ and __x86_64__:

https://github.com/systemd/systemd/blob/master/src/basic/missing.h#L540

So the fix will be two-fold:

- use missing.h from importd,

- enhance missing.h to also define O_TMPFILE for other archs.

I'll be doing that shortly (first already done).

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'