* [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains
@ 2016-08-30 9:29 Yann E. MORIN
2016-08-30 9:35 ` Baruch Siach
2016-09-18 14:05 ` Thomas Petazzoni
0 siblings, 2 replies; 4+ messages in thread
From: Yann E. MORIN @ 2016-08-30 9:29 UTC (permalink / raw)
To: buildroot
Toolchains using glibc-2.18 or older do not define O_TMPFILE, which
causes build failures on some archs.
systemd has a definition for O_TMPFILE if it is missing, but only
defines it for i386 or x86_64. Furthermore, the header defining it is
not included everywhere O_TMPFILE is used.
Fix that with three patches backported from upstream:
- include the needed header where it is needed (he!),
- define O_TMPFILE for all archs, according to linux-4.8rc3,
- no longer guard against undefined O_TMPFILE in fileio.
Upstream merge commit:
https://github.com/systemd/systemd/commit/4a13100c6a5a0a4b793e90bd43d21c3696c42d46
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
Changes v1 -> v2:
- backport patches as upstreamed
---
...-export-raw-needs-missing.h-for-O_TMPFILE.patch | 30 +++++++++++
...h-add-missing-definitions-for-__O_TMPFILE.patch | 62 +++++++++++++++++++++
...basic-fileio-we-always-have-O_TMPFILE-now.patch | 63 ++++++++++++++++++++++
3 files changed, 155 insertions(+)
create mode 100644 package/systemd/0004-importd-export-raw-needs-missing.h-for-O_TMPFILE.patch
create mode 100644 package/systemd/0005-missing.h-add-missing-definitions-for-__O_TMPFILE.patch
create mode 100644 package/systemd/0006-basic-fileio-we-always-have-O_TMPFILE-now.patch
diff --git a/package/systemd/0004-importd-export-raw-needs-missing.h-for-O_TMPFILE.patch b/package/systemd/0004-importd-export-raw-needs-missing.h-for-O_TMPFILE.patch
new file mode 100644
index 0000000..0232248
--- /dev/null
+++ b/package/systemd/0004-importd-export-raw-needs-missing.h-for-O_TMPFILE.patch
@@ -0,0 +1,30 @@
+From 4a6d35237f96d07f3a783c874933f87bf14f93e0 Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Date: Sun, 28 Aug 2016 16:26:04 +0200
+Subject: [PATCH] importd/export-raw: needs missing.h for O_TMPFILE
+
+O_TMPFILE may be missing from the system headers, so use our fallback
+definition.
+
+---
+Backported from upstream:
+ https://github.com/systemd/systemd/commit/4a6d35237f96d07f3a783c874933f87bf14f93e0
+---
+ src/import/export-raw.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/import/export-raw.c b/src/import/export-raw.c
+index db06e11..6136b67 100644
+--- a/src/import/export-raw.c
++++ b/src/import/export-raw.c
+@@ -34,6 +34,7 @@
+ #include "fd-util.h"
+ #include "fileio.h"
+ #include "import-common.h"
++#include "missing.h"
+ #include "ratelimit.h"
+ #include "string-util.h"
+ #include "util.h"
+--
+2.7.4
+
diff --git a/package/systemd/0005-missing.h-add-missing-definitions-for-__O_TMPFILE.patch b/package/systemd/0005-missing.h-add-missing-definitions-for-__O_TMPFILE.patch
new file mode 100644
index 0000000..301acef
--- /dev/null
+++ b/package/systemd/0005-missing.h-add-missing-definitions-for-__O_TMPFILE.patch
@@ -0,0 +1,62 @@
+From daad709a7c13c0fac73e407528f96cc876c09629 Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Date: Sun, 28 Aug 2016 17:26:42 +0200
+Subject: [PATCH] missing.h: add missing definitions for __O_TMPFILE
+
+Currently, a missing __O_TMPFILE was only defined for i386 and x86_64,
+leaving any other architectures with an "old" toolchain fail miserably
+at build time:
+ src/import/export-raw.c: In function 'reflink_snapshot':
+ src/import/export-raw.c:271:26: error: 'O_TMPFILE' undeclared (first use in this function)
+ new_fd = open(d, O_TMPFILE|O_CLOEXEC|O_NOCTTY|O_RDWR, 0600);
+ ^
+
+__O_TMPFILE (and O_TMPFILE) are available since glibc 2.19. However, a
+lot of existing toolchains are still using glibc-2.18, and some even
+before that, and it is not really possible to update those toolchains.
+
+Instead of defining it only for i386 and x86_64, define __O_TMPFILE
+with the specific values for those archs where it is different from the
+generic value. Use the values as found in the Linux kernel (v4.8-rc3,
+current as of time of commit).
+
+---
+Backported from upstream:
+ https://github.com/systemd/systemd/commit/daad709a7c13c0fac73e407528f96cc876c09629
+---
+ src/basic/missing.h | 17 +++++++++++++----
+ 1 file changed, 13 insertions(+), 4 deletions(-)
+
+diff --git a/src/basic/missing.h b/src/basic/missing.h
+index f8e0966..13ff51c 100644
+--- a/src/basic/missing.h
++++ b/src/basic/missing.h
+@@ -537,12 +537,21 @@ struct btrfs_ioctl_quota_ctl_args {
+ # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
+ #endif
+
+-#if defined(__i386__) || defined(__x86_64__)
+-
+-/* The precise definition of __O_TMPFILE is arch specific, so let's
+- * just define this on x86 where we know the value. */
++/* The precise definition of __O_TMPFILE is arch specific; use the
++ * values defined by the kernel (note: some are hexa, some are octal,
++ * duplicated as-is from the kernel definitions):
++ * - alpha, parisc, sparc: each has a specific value;
++ * - others: they use the "generic" value.
++ */
+
+ #ifndef __O_TMPFILE
++#if defined(__alpha__)
++#define __O_TMPFILE 0100000000
++#elif defined(__parisc__) || defined(__hppa__)
++#define __O_TMPFILE 0400000000
++#elif defined(__sparc__) || defined(__sparc64__)
++#define __O_TMPFILE 0x2000000
++#else
+ #define __O_TMPFILE 020000000
+ #endif
+
+--
+2.7.4
+
diff --git a/package/systemd/0006-basic-fileio-we-always-have-O_TMPFILE-now.patch b/package/systemd/0006-basic-fileio-we-always-have-O_TMPFILE-now.patch
new file mode 100644
index 0000000..da95254
--- /dev/null
+++ b/package/systemd/0006-basic-fileio-we-always-have-O_TMPFILE-now.patch
@@ -0,0 +1,63 @@
+From 1d9ed171788821c21ca900a921833a8e41bf22f3 Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Date: Mon, 29 Aug 2016 12:34:50 +0200
+Subject: [PATCH] basic/fileio: we always have O_TMPFILE now
+
+fileio makes use of O_TMPFILE when it is available.
+
+We now always have O_TMPFILE, defined in missing.h if missing
+from the toolchain headers.
+
+Have fileio include missing.h and drop the guards around the
+use of O_TMPFILE.
+---
+Backported from upstream:
+ https://github.com/systemd/systemd/commit/1d9ed171788821c21ca900a921833a8e41bf22f3
+---
+ src/basic/fileio.c | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/src/basic/fileio.c b/src/basic/fileio.c
+index d642f3d..a5920e7 100644
+--- a/src/basic/fileio.c
++++ b/src/basic/fileio.c
+@@ -37,6 +37,7 @@
+ #include "hexdecoct.h"
+ #include "log.h"
+ #include "macro.h"
++#include "missing.h"
+ #include "parse-util.h"
+ #include "path-util.h"
+ #include "random-util.h"
+@@ -1280,12 +1281,10 @@ int open_tmpfile_unlinkable(const char *directory, int flags) {
+
+ /* Returns an unlinked temporary file that cannot be linked into the file system anymore */
+
+-#ifdef O_TMPFILE
+ /* Try O_TMPFILE first, if it is supported */
+ fd = open(directory, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR);
+ if (fd >= 0)
+ return fd;
+-#endif
+
+ /* Fall back to unguessable name + unlinking */
+ p = strjoina(directory, "/systemd-tmp-XXXXXX");
+@@ -1313,7 +1312,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
+ * which case "ret_path" will be returned as NULL. If not possible a the tempoary path name used is returned in
+ * "ret_path". Use link_tmpfile() below to rename the result after writing the file in full. */
+
+-#ifdef O_TMPFILE
+ {
+ _cleanup_free_ char *dn = NULL;
+
+@@ -1329,7 +1327,6 @@ int open_tmpfile_linkable(const char *target, int flags, char **ret_path) {
+
+ log_debug_errno(errno, "Failed to use O_TMPFILE on %s: %m", dn);
+ }
+-#endif
+
+ r = tempfn_random(target, NULL, &tmp);
+ if (r < 0)
+--
+2.7.4
+
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains
2016-08-30 9:29 [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains Yann E. MORIN
@ 2016-08-30 9:35 ` Baruch Siach
2016-08-30 9:48 ` Yann E. MORIN
2016-09-18 14:05 ` Thomas Petazzoni
1 sibling, 1 reply; 4+ messages in thread
From: Baruch Siach @ 2016-08-30 9:35 UTC (permalink / raw)
To: buildroot
Hi Yann,
On Tue, Aug 30, 2016 at 11:29:37AM +0200, Yann E. MORIN wrote:
> Toolchains using glibc-2.18 or older do not define O_TMPFILE, which
> causes build failures on some archs.
>
> systemd has a definition for O_TMPFILE if it is missing, but only
> defines it for i386 or x86_64. Furthermore, the header defining it is
> not included everywhere O_TMPFILE is used.
>
> Fix that with three patches backported from upstream:
> - include the needed header where it is needed (he!),
> - define O_TMPFILE for all archs, according to linux-4.8rc3,
> - no longer guard against undefined O_TMPFILE in fileio.
This last patch is not a pure build fix, but more of a feature enhancement.
Don't know if it fits in master.
Also, your patches are missing sign-off.
An autobuild reference in the commit log would also be nice.
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains
2016-08-30 9:35 ` Baruch Siach
@ 2016-08-30 9:48 ` Yann E. MORIN
0 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2016-08-30 9:48 UTC (permalink / raw)
To: buildroot
Baruch, All,
On 2016-08-30 12:35 +0300, Baruch Siach spake thusly:
> Hi Yann,
>
> On Tue, Aug 30, 2016 at 11:29:37AM +0200, Yann E. MORIN wrote:
> > Toolchains using glibc-2.18 or older do not define O_TMPFILE, which
> > causes build failures on some archs.
> >
> > systemd has a definition for O_TMPFILE if it is missing, but only
> > defines it for i386 or x86_64. Furthermore, the header defining it is
> > not included everywhere O_TMPFILE is used.
> >
> > Fix that with three patches backported from upstream:
> > - include the needed header where it is needed (he!),
> > - define O_TMPFILE for all archs, according to linux-4.8rc3,
> > - no longer guard against undefined O_TMPFILE in fileio.
>
> This last patch is not a pure build fix, but more of a feature enhancement.
> Don't know if it fits in master.
Well, it's indeed not a _pure_ bug fix, but given that O_TMPFILE is now
always defined, the guards are no longer needed at all: they will never
be guarding anything now.
Besides, using O_TMPFILE is way better than not using it; it makes the
thing a little bit more secure.
> Also, your patches are missing sign-off.
Damn. Upstream is not using SoB lines (Lennart asked me to remove them
[0] and I fiorgot to re-add them when adding them in Buildroot; the
previosu iteration did have my SoB lines).
> An autobuild reference in the commit log would also be nice.
Damn, I also forgot that... :-/
Thanks!
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains
2016-08-30 9:29 [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains Yann E. MORIN
2016-08-30 9:35 ` Baruch Siach
@ 2016-09-18 14:05 ` Thomas Petazzoni
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2016-09-18 14:05 UTC (permalink / raw)
To: buildroot
Hello,
On Tue, 30 Aug 2016 11:29:37 +0200, Yann E. MORIN wrote:
> Toolchains using glibc-2.18 or older do not define O_TMPFILE, which
> causes build failures on some archs.
>
> systemd has a definition for O_TMPFILE if it is missing, but only
> defines it for i386 or x86_64. Furthermore, the header defining it is
> not included everywhere O_TMPFILE is used.
>
> Fix that with three patches backported from upstream:
> - include the needed header where it is needed (he!),
> - define O_TMPFILE for all archs, according to linux-4.8rc3,
> - no longer guard against undefined O_TMPFILE in fileio.
>
> Upstream merge commit:
> https://github.com/systemd/systemd/commit/4a13100c6a5a0a4b793e90bd43d21c3696c42d46
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> ---
> Changes v1 -> v2:
> - backport patches as upstreamed
> ---
> ...-export-raw-needs-missing.h-for-O_TMPFILE.patch | 30 +++++++++++
> ...h-add-missing-definitions-for-__O_TMPFILE.patch | 62 +++++++++++++++++++++
> ...basic-fileio-we-always-have-O_TMPFILE-now.patch | 63 ++++++++++++++++++++++
> 3 files changed, 155 insertions(+)
> create mode 100644 package/systemd/0004-importd-export-raw-needs-missing.h-for-O_TMPFILE.patch
> create mode 100644 package/systemd/0005-missing.h-add-missing-definitions-for-__O_TMPFILE.patch
> create mode 100644 package/systemd/0006-basic-fileio-we-always-have-O_TMPFILE-now.patch
I've applied, after adding the autobuild failure reference, and
re-adding your SoB lines from the patches (they were here in the
previous iteration).
Thanks,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-18 14:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-30 9:29 [Buildroot] [PATCHv2] package/systemd: fix build with old toolchains Yann E. MORIN
2016-08-30 9:35 ` Baruch Siach
2016-08-30 9:48 ` Yann E. MORIN
2016-09-18 14:05 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox