From patchwork Sat Dec 13 14:35:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Merlijn Wajer X-Patchwork-Id: 5486681 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C27439F1CD for ; Sat, 13 Dec 2014 15:00:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90FC120154 for ; Sat, 13 Dec 2014 15:00:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703FC20145 for ; Sat, 13 Dec 2014 15:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964870AbaLMOzR (ORCPT ); Sat, 13 Dec 2014 09:55:17 -0500 Received: from nala.villavu.com ([188.165.243.101]:47342 "EHLO nala.villavu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932705AbaLMOzQ (ORCPT ); Sat, 13 Dec 2014 09:55:16 -0500 X-Greylist: delayed 1152 seconds by postgrey-1.27 at vger.kernel.org; Sat, 13 Dec 2014 09:55:15 EST Received: from a82-161-36-93.adsl.xs4all.nl ([82.161.36.93] helo=[192.168.178.31]) by nala.villavu.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80.1) (envelope-from ) id 1Xznni-0007bh-QF for linux-btrfs@vger.kernel.org; Sat, 13 Dec 2014 15:36:06 +0100 Message-ID: <548C4E9D.2080309@wizzup.org> Date: Sat, 13 Dec 2014 15:35:09 +0100 From: Merlijn Wajer User-Agent: Mozilla/5.0 (X11; Linux armv7l; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: linux-btrfs@vger.kernel.org Subject: [RFC] btrfs-progs: Support for musl libc (and perhaps also uclibc) X-Enigmail-Version: 1.6 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 From 01d0bfe48dc78b66b6e86d4935d9b9d20194b135 Mon Sep 17 00:00:00 2001 From: Merlijn Wajer 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 #include #include + +#ifndef __glibc__ +#define BTRFS_DISABLE_BACKTRACE +#define __always_inline __inline __attribute__ ((__always_inline__)) +#endif + #ifndef BTRFS_DISABLE_BACKTRACE #include #endif -- 2.0.4