All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc)
@ 2014-12-13 14:35 Merlijn Wajer
  2014-12-17 16:49 ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Merlijn Wajer @ 2014-12-13 14:35 UTC (permalink / raw)
  To: linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 1800 bytes --]

Hi,

I've been experimenting with musl-libc Gentoo systems. I used the HEAD
of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git

I found that btrfs-progs does not compile with musl-libc, for a few reasons:

* It makes use of the private glibc __always_inline macro.

* Various headers that should be included are not included:
linux/limits.h and limits.h. (for XATTR_SIZE_MAX and PATH_MAX)

* backtrace() using execinfo.h is enabled by default; execinfo.h is
glibc-specific and thus does not work on other libc's. musl does not
support it, and I think uclibc also does not support it.

I have worked around the problems in the following way:

* Define __always_inline if __glibc__ is not defined. This is arguably
the most clean solution. It would be better to simply not use the
__always_inline macro (instead, use __attribute__) throughout
btrfs-progs, but I was not sure what the developers would prefer. This
is currently done in kerncompat.h, but you may want to move that to
another file.

* Include various headers where required.

* If __glibc__ is not defined, define BTRFS_DISABLE_BACKTRACE. Currently
the define magic happens in kerncompat, because that also where BTRFS
includes execinfo. Personally, I think it would make more sense to
always disable backtrace instead of enabling it by default -- but
perhaps in a testing phase, enabling it by default in the sensible choice.

Attached are the two patches generated with git format-patch. I am aware
that this may not be required format for submitting patches -- but
please give me some time to get used to the etiquette. :-)

Please let me know if musl-libc (or any other libc) is a supported
platform, and if so, if and how I can improve on said patches.

Regards,
Merlijn

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Include-headers-required-for-musl-libc.patch --]
[-- Type: text/x-patch; name="0001-Include-headers-required-for-musl-libc.patch", Size: 1315 bytes --]

From da43021732fab3f70c75f155bded8e5f35fdffe3 Mon Sep 17 00:00:00 2001
From: Merlijn Wajer <merlijn@wizzup.org>
Date: Sat, 13 Dec 2014 15:07:25 +0100
Subject: [PATCH 1/2] Include headers required for musl-libc.

This fixes various compilation errors where PATH_MAX and XATTR_SIZE_MAX
were missing. To my knowledge, this should have no bad side effects.
---
 btrfs-convert.c | 1 +
 help.c          | 1 +
 mkfs.c          | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/btrfs-convert.c b/btrfs-convert.c
index 02c5e94..7b69a13 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
+#include <linux/limits.h>
 
 #include "ctree.h"
 #include "disk-io.h"
diff --git a/help.c b/help.c
index fab942b..56aaf9c 100644
--- a/help.c
+++ b/help.c
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 
 #include "commands.h"
 #include "utils.h"
diff --git a/mkfs.c b/mkfs.c
index e10e62d..6343831 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -35,6 +35,8 @@
 #include <uuid/uuid.h>
 #include <ctype.h>
 #include <sys/xattr.h>
+#include <limits.h>
+#include <linux/limits.h>
 #include <blkid/blkid.h>
 #include <ftw.h>
 #include "ctree.h"
-- 
2.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-Disable-backtrace-and-define-__always_inline.patch --]
[-- Type: text/x-patch; name="0002-Disable-backtrace-and-define-__always_inline.patch", Size: 880 bytes --]

From 01d0bfe48dc78b66b6e86d4935d9b9d20194b135 Mon Sep 17 00:00:00 2001
From: Merlijn Wajer <merlijn@wizzup.org>
Date: Sat, 13 Dec 2014 15:08:43 +0100
Subject: [PATCH 2/2] Disable backtrace and define __always_inline

Disable backtrace and define __always_inline when glibc is not used as
libc. This, together with some header changes allows btrfs-progs to
compile with musl-libc.
---
 kerncompat.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kerncompat.h b/kerncompat.h
index 8afadc8..05823a7 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -29,6 +29,12 @@
 #include <stddef.h>
 #include <linux/types.h>
 #include <stdint.h>
+
+#ifndef __glibc__
+#define BTRFS_DISABLE_BACKTRACE
+#define __always_inline __inline __attribute__ ((__always_inline__))
+#endif
+
 #ifndef BTRFS_DISABLE_BACKTRACE
 #include <execinfo.h>
 #endif
-- 
2.0.4


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc)
  2014-12-13 14:35 [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc) Merlijn Wajer
@ 2014-12-17 16:49 ` David Sterba
  2014-12-17 18:46   ` Austin S Hemmelgarn
  2014-12-18 10:29   ` Merlijn Wajer
  0 siblings, 2 replies; 5+ messages in thread
From: David Sterba @ 2014-12-17 16:49 UTC (permalink / raw)
  To: Merlijn Wajer; +Cc: linux-btrfs

On Sat, Dec 13, 2014 at 03:35:09PM +0100, Merlijn Wajer wrote:
[snip]

> Attached are the two patches generated with git format-patch. I am aware
> that this may not be required format for submitting patches -- but
> please give me some time to get used to the etiquette. :-)

Thanks, there are minor things that I won't bother to point out to
occasional contributors and fix them myself. The only formal requirement
is the Signed-off-by tag, you can find the description eg. here

http://lxr.free-electrons.com/source/Documentation/SubmittingPatches#L358

> Please let me know if musl-libc (or any other libc) is a supported
> platform, and if so, if and how I can improve on said patches.

I'm not aware of non-glibc users, but I don't see any problem to add
support for more libc implementations. However, I won't regularly verify
that it builds so it might break.

Seems that only standardized library calls are used in btrfs-progs so
any kind of support is probably going to be satisfied by #ifdefs.

Your patches are simple so I'll try to schedule them to some 3.18.x
update.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc)
  2014-12-17 16:49 ` David Sterba
@ 2014-12-17 18:46   ` Austin S Hemmelgarn
  2014-12-18 10:29   ` Merlijn Wajer
  1 sibling, 0 replies; 5+ messages in thread
From: Austin S Hemmelgarn @ 2014-12-17 18:46 UTC (permalink / raw)
  To: dsterba, Merlijn Wajer, linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

On 2014-12-17 11:49, David Sterba wrote:
> On Sat, Dec 13, 2014 at 03:35:09PM +0100, Merlijn Wajer wrote:
> [snip]
>> Please let me know if musl-libc (or any other libc) is a supported
>> platform, and if so, if and how I can improve on said patches.
>
> I'm not aware of non-glibc users, but I don't see any problem to add
> support for more libc implementations. However, I won't regularly verify
> that it builds so it might break.
I know that buildroot has support for building btrfs-progs with uClibc, 
I don't know if they have any special patches for it though.  Although I 
haven't tried it myself, I think it is also possible to use buildroot 
with musl.


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2455 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc)
  2014-12-17 16:49 ` David Sterba
  2014-12-17 18:46   ` Austin S Hemmelgarn
@ 2014-12-18 10:29   ` Merlijn Wajer
  2014-12-18 17:43     ` David Sterba
  1 sibling, 1 reply; 5+ messages in thread
From: Merlijn Wajer @ 2014-12-18 10:29 UTC (permalink / raw)
  To: dsterba, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 1615 bytes --]

Hi,

On 17/12/14 17:49, David Sterba wrote:
> On Sat, Dec 13, 2014 at 03:35:09PM +0100, Merlijn Wajer wrote:
> [snip]
> 
>> Attached are the two patches generated with git format-patch. I am aware
>> that this may not be required format for submitting patches -- but
>> please give me some time to get used to the etiquette. :-)
> 
> Thanks, there are minor things that I won't bother to point out to
> occasional contributors and fix them myself. The only formal requirement
> is the Signed-off-by tag, you can find the description eg. here
> 
> http://lxr.free-electrons.com/source/Documentation/SubmittingPatches#L358

Alright, cool. I've rebased my two patches and used --signoff when
amending the commit. Please find the new patches attached.


>> Please let me know if musl-libc (or any other libc) is a supported
>> platform, and if so, if and how I can improve on said patches.
> 
> I'm not aware of non-glibc users, but I don't see any problem to add
> support for more libc implementations. However, I won't regularly verify
> that it builds so it might break.

That is fine; at this point there are not a lot of people using an
alternative libc, so this is common practice. I'll be here with a new
round of patches if it breaks in a future release; it shouldn't really
break too often. :)


> Seems that only standardized library calls are used in btrfs-progs so
> any kind of support is probably going to be satisfied by #ifdefs.
> Your patches are simple so I'll try to schedule them to some 3.18.x
> update.

That would be great; thank you.

Regards,
Merlijn

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Include-headers-required-for-musl-libc.patch --]
[-- Type: text/x-patch; name="0001-Include-headers-required-for-musl-libc.patch", Size: 1368 bytes --]

From 0109fd7ce62eee8b16aa5bdf78f3de54011e00f3 Mon Sep 17 00:00:00 2001
From: Merlijn Wajer <merlijn@wizzup.org>
Date: Sat, 13 Dec 2014 15:07:25 +0100
Subject: [PATCH 1/2] Include headers required for musl-libc.

This fixes various compilation errors where PATH_MAX and XATTR_SIZE_MAX
were missing. To my knowledge, this should have no bad side effects.

Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
---
 btrfs-convert.c | 1 +
 help.c          | 1 +
 mkfs.c          | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/btrfs-convert.c b/btrfs-convert.c
index 02c5e94..7b69a13 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
+#include <linux/limits.h>
 
 #include "ctree.h"
 #include "disk-io.h"
diff --git a/help.c b/help.c
index fab942b..56aaf9c 100644
--- a/help.c
+++ b/help.c
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 
 #include "commands.h"
 #include "utils.h"
diff --git a/mkfs.c b/mkfs.c
index e10e62d..6343831 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -35,6 +35,8 @@
 #include <uuid/uuid.h>
 #include <ctype.h>
 #include <sys/xattr.h>
+#include <limits.h>
+#include <linux/limits.h>
 #include <blkid/blkid.h>
 #include <ftw.h>
 #include "ctree.h"
-- 
2.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-Disable-backtrace-and-define-__always_inline.patch --]
[-- Type: text/x-patch; name="0002-Disable-backtrace-and-define-__always_inline.patch", Size: 933 bytes --]

From 5ae5cfa3af473625ef5b31daf5f229f12be753d2 Mon Sep 17 00:00:00 2001
From: Merlijn Wajer <merlijn@wizzup.org>
Date: Sat, 13 Dec 2014 15:08:43 +0100
Subject: [PATCH 2/2] Disable backtrace and define __always_inline

Disable backtrace and define __always_inline when glibc is not used as
libc. This, together with some header changes allows btrfs-progs to
compile with musl-libc.

Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
---
 kerncompat.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kerncompat.h b/kerncompat.h
index 8afadc8..05823a7 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -29,6 +29,12 @@
 #include <stddef.h>
 #include <linux/types.h>
 #include <stdint.h>
+
+#ifndef __glibc__
+#define BTRFS_DISABLE_BACKTRACE
+#define __always_inline __inline __attribute__ ((__always_inline__))
+#endif
+
 #ifndef BTRFS_DISABLE_BACKTRACE
 #include <execinfo.h>
 #endif
-- 
2.0.4


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc)
  2014-12-18 10:29   ` Merlijn Wajer
@ 2014-12-18 17:43     ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2014-12-18 17:43 UTC (permalink / raw)
  To: Merlijn Wajer; +Cc: dsterba, linux-btrfs

On Thu, Dec 18, 2014 at 11:29:40AM +0100, Merlijn Wajer wrote:
> That is fine; at this point there are not a lot of people using an
> alternative libc, so this is common practice. I'll be here with a new
> round of patches if it breaks in a future release; it shouldn't really
> break too often. :)

Good. I've put the patches to 3.18 queue.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-18 17:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-13 14:35 [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc) Merlijn Wajer
2014-12-17 16:49 ` David Sterba
2014-12-17 18:46   ` Austin S Hemmelgarn
2014-12-18 10:29   ` Merlijn Wajer
2014-12-18 17:43     ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.