Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Alpine Linux #268

Open
seuf opened this issue Jul 17, 2017 · 32 comments · May be fixed by #4450
Open

Compatibility with Alpine Linux #268

seuf opened this issue Jul 17, 2017 · 32 comments · May be fixed by #4450
Labels
platform Any platform specific questions/issues can be tagged with this label Question Type:Enhancement

Comments

@seuf
Copy link

seuf commented Jul 17, 2017

Hi,
Alpine Linux use the musl library instead of the glibc.
Is it possible to make a musl compatible version of glusterfs ?
It would be awesome to have glusterfs in alpine linux.

@mchangir
Copy link
Contributor

Doesn't the musl-gcc wrapper provide the necessary magic to link to the platform specific 'C' Library on Alpine Linux ?

@seuf
Copy link
Author

seuf commented Jul 19, 2017

I think you're right, the musl-gcc wrapper provide some magic to link glic functions, but all the functions must be POSIX compliant. I read that glusterfs use not POSIX functions : https://bugs.alpinelinux.org/issues/2834 .

@mati865
Copy link

mati865 commented Nov 22, 2017

Portablexdr doesn't seem to work with glusterfs (usually rpcgen is provided by glibc but musl doesn't have it):

Making all in rpc/xdr/gen
glusterfs3-xdr.x:39: syntax error

Both 3.10.7 and master produce the same error.

@janreges
Copy link

+1

1 similar comment
@CrazyPandar
Copy link

+1

@kalebskeithley
Copy link
Contributor

kalebskeithley commented Mar 14, 2019

rpcgen is in its own separate package. At least in alpine 3.9.2. (Similar to Fedora28+ and RHEL8 where rpcgen has been removed from glibc. I expect other distributions will do the same eventually.)

I didn't look in any older versions.

apk update && apk add rpcgen

But there are other issues with this rpcgen that alpine ships. It's not the same as the unbundled rpcgen in Fedora and doesn't like the "hyper" data type in, e.g., glusterfs4-xdr.x

apk info rpcgen says it's built from the source from/git.linux-nfs.org which I presume is really git://git.linux-nfs.org/projects/steved/nfs-utils.git, and rpcgen in that repo is deprecated according to steved.

Alpine should probably use the rpcgen that's in Fedora from https://github.com/thkukuk/rpcsvc-proto.git, which supports the "hyper" data type (i.e. quad_t).

Without support for hyper, nobody is going to get very far building glusterfs.

Someone with a vested interest in Alpine should get them to update to a modern/current rpcgen. In the mean time anyone wanting to build gluster will absolutely have to build their own rpcgen from source.

@stale
Copy link

stale bot commented Apr 30, 2020

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label Apr 30, 2020
@J0WI
Copy link

J0WI commented Apr 30, 2020

Please keep this open to track it somewhere.

@sunnyku sunnyku removed the wontfix Managed by stale[bot] label Apr 30, 2020
@sunnyku
Copy link
Contributor

sunnyku commented Apr 30, 2020

Thanks for reply; removing tag.

@stale
Copy link

stale bot commented Nov 27, 2020

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label Nov 27, 2020
@J0WI
Copy link

J0WI commented Nov 27, 2020

bump

@amarts
Copy link
Member

amarts commented Nov 29, 2020

Two things here. I tried to get this done last year, and the changes in xdr lib was little too much, and there were discussions about newer network layer, and I left it off at that.

Considering we from kadalu.io would like to have a smaller footprint of glusterfs in container image, I will see if we can get this picked up. If anyone wants to volunteers, (with protobuf experience), happy to coordinate.

@stale stale bot removed the wontfix Managed by stale[bot] label Nov 29, 2020
@amarts
Copy link
Member

amarts commented Nov 29, 2020

Gave this a try... stuck with below error, and not sure how to go about that:

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../libglusterfs/src/.libs/libglusterfs.so: undefined reference to `swapcontext'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../libglusterfs/src/.libs/libglusterfs.so: undefined reference to `getcontext'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../libglusterfs/src/.libs/libglusterfs.so: undefined reference to `makecontext'
collect2: error: ld returned 1 exit status

@xhernandez According to this link below is mentioned:

With the incorporation of the ISO/IEC 9899:1999 standard into this specification it was found that the ISO C standard (Subclause 6.11.6) specifies that the use of function declarators with empty parentheses is an obsolescent feature. Therefore, using the function prototype:

void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);

is making use of an obsolescent feature of the ISO C standard. Therefore, a strictly conforming POSIX application cannot use this form. Therefore, use of getcontext(), makecontext(), and swapcontext() is marked obsolescent.

Looks like its not supported in musl-dev at all, and hence glusterfs is not able to link fine.

To get to this, I needed to do few changes in code, including not building gfapi (more errors seen). I will update later about all dependencies and changes done. The rpcgen issues etc are gone now, and libtirpc-dev also is available. So all good there.

amarts added a commit to amarts/glusterfs_fork that referenced this issue Nov 29, 2020
Fixes: gluster#268
Change-Id: I1468de97cc38479d09a16ea41eb2aa346e4457cf
Signed-off-by: Amar Tumballi <[email protected]>
amarts added a commit to amarts/glusterfs_fork that referenced this issue Nov 29, 2020
Fixes: gluster#268
Change-Id: I1468de97cc38479d09a16ea41eb2aa346e4457cf
Signed-off-by: Amar Tumballi <[email protected]>
@amarts
Copy link
Member

amarts commented Nov 29, 2020

With below dockerfile

FROM alpine:latest

RUN apk add git automake autoconf libtool build-base rpcgen flex bison openssl-dev
RUN apk add libuuid util-linux-dev acl-dev zlib-dev python3-dev libxml2-dev argp-standalone
RUN apk add libtirpc-dev userspace-rcu-dev fuse-dev

RUN git clone --depth 1 https://github.com/amarts/glusterfs_fork --branch alpine_compile --single-branch glusterfs

RUN cd glusterfs && ./autogen.sh && GF_LDFLAGS="/usr/lib/libargp.a" ./configure --without-gfapi && make

# Debugging, Comment the above line and
# uncomment below line
ENTRYPOINT ["tail", "-f", "/dev/null"]

and docker build -t glusterfs-alpine -f ./Dockerfile.alpine . as command I was able to test this.

@amarts amarts added Type:Enhancement platform Any platform specific questions/issues can be tagged with this label labels Nov 29, 2020
amarts added a commit to amarts/glusterfs_fork that referenced this issue Nov 29, 2020
Fixes: gluster#268
Change-Id: I1468de97cc38479d09a16ea41eb2aa346e4457cf
Signed-off-by: Amar Tumballi <[email protected]>
@xhernandez
Copy link
Contributor

Gave this a try... stuck with below error, and not sure how to go about that:

/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../libglusterfs/src/.libs/libglusterfs.so: undefined reference to `swapcontext'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../libglusterfs/src/.libs/libglusterfs.so: undefined reference to `getcontext'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../libglusterfs/src/.libs/libglusterfs.so: undefined reference to `makecontext'
collect2: error: ld returned 1 exit status

@xhernandez According to this link below is mentioned:

With the incorporation of the ISO/IEC 9899:1999 standard into this specification it was found that the ISO C standard (Subclause 6.11.6) specifies that the use of function declarators with empty parentheses is an obsolescent feature. Therefore, using the function prototype:
void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);
is making use of an obsolescent feature of the ISO C standard. Therefore, a strictly conforming POSIX application cannot use this form. Therefore, use of getcontext(), makecontext(), and swapcontext() is marked obsolescent.

Looks like its not supported in musl-dev at all, and hence glusterfs is not able to link fine.

Without support for makecontext() and similar functions, it will be hard to make gluster run on this platform. One possibility is to use a setjmp()/longjmp() with some tricks for stack allocation to simulate those functions, but creation of synctasks will probably be slow if we want to use a portable method.

Another way is to implement those functions ourselves, but it's not trivial because we would need to do it at very low level (probably assembly) and we'll need to do it for each machine type we want to be able to run Gluster. Probably this is not the right approach.

@amarts
Copy link
Member

amarts commented Nov 30, 2020

Ack, I agree. Currently a lot of logic depends on syncop* logic. I wouldn't pursue this further now, but happy if anyone has a way to get this resolved in alpine. As per basic searches, even openssl had issue, but they run in minimal no-async mode on alpine. We can't even run our server only version too.

I will keep the issue open, and keep the branch alive, so anyone interested can pick it up and take it forward. For now, focusing on few other things.

amarts added a commit to amarts/glusterfs_fork that referenced this issue Dec 15, 2020
Fixes: gluster#268
Change-Id: I1468de97cc38479d09a16ea41eb2aa346e4457cf
Signed-off-by: Amar Tumballi <[email protected]>
@stale stale bot removed the wontfix Managed by stale[bot] label Jun 29, 2021
@stale
Copy link

stale bot commented Jan 26, 2022

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label Jan 26, 2022
@J0WI
Copy link

J0WI commented Jan 27, 2022

bump

@stale stale bot removed the wontfix Managed by stale[bot] label Jan 27, 2022
@cpdef
Copy link

cpdef commented Mar 3, 2022

The problem wit make/swap/getcontext and a similar with argp_parse functions etc. can be solved by the following commands:

apk add libucontext-dev
apk add argp_standalone
export LIBS="-lucontext -largp "
./configure

Though there are some more issues, when compiling on alpine,
for example that __offt64 is not defined and _PART_MOUNTED is not defined and one more i don't remember.
I will try to make some work arounds for this and post it here again ...

I tested this with the release-10 branch

@cpdef
Copy link

cpdef commented Mar 3, 2022

Ok i could now compile glusterfs with musl-libc on alpine 3.15 and gcc 10.3.
I made some minor changes to files, where something was undefined.

At least i added
#define _PATH_MOUNTED "/etc/mtab" in some files, idk why it wasn't defined.
also in /contrib/fuse-lib/mount-common.c strncmp was undefined. so i added #include <string.h>
I think i did one more thing i don't remember at moment, but i'll make a diff later, to find it.

Next step is to test on my little cluster, if the setup of a filesystem works also.

@cpdef
Copy link

cpdef commented Mar 4, 2022

So here are all changes:

--- ../glusterfs-release-10/contrib/fuse-lib/mount-common.c                                                                                                                                                       
+++ contrib/fuse-lib/mount-common.c                                                                                                                                                                               
@@ -8,7 +8,12 @@                                                                                                                                                                                                  
 */                                                                                                                                                                                                               
                                                                                                                                                                                                                  
 #include "mount-gluster-compat.h"                                                                                                                                                                                
+#ifndef _PATH_MOUNTED                                                                                                                                                                                            
+#define _PATH_MOUNTED "/etc/mtab"                                                                                                                                                                                
+#endif                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                     
+#include <string.h>

--- ../glusterfs-release-10/api/src/glfs.h                                                                                                                                                                        
+++ api/src/glfs.h                                                                                                                                                                                                
@@ -67,6 +67,7 @@                                                                                                                                                                                                 
  * is false and __USE_FILE_OFFSET64 is true, then go on to define                                                                                                                                                
  * off64_t using __off64_t.                                                                                                                                                                                      
  */                                                                                                                                                                                                              
+#define __off64_t_defined                                                                                                                                                                                        
 #ifndef GF_BSD_HOST_OS                                                                                                                                                                                           
 #if defined(__USE_FILE_OFFSET64) && !defined(__off64_t_defined)                                                                                                                                                  
 typedef __off64_t off64_t; 

--- ../glusterfs-release-10/contrib/fuse-util/fusermount.c                                                                                                                                                        
+++ contrib/fuse-util/fusermount.c                                                                                                                                                                                
@@ -6,6 +6,9 @@                                                                                                                                                                                                   
   See the file COPYING.                                                                                                                                                                                          
 */                                                                                                                                                                                                               
 /* This program does the mounting and unmounting of FUSE filesystems */                                                                                                                                          
+#ifndef _PATH_MOUNTED                                                                                                                                                                                            
+#define _PATH_MOUNTED "/etc/mtab"                                                                                                                                                                                
+#endif                                                                                                                                                                                                           
                                                                                                                                                                                                                  
 #include <config.h> 

--- ../glusterfs-release-10/libglusterfs/src/glusterfs/dict.h                                                                                                                                                     
+++ libglusterfs/src/glusterfs/dict.h                                                                                                                                                                             
@@ -320,6 +320,7 @@                                                                                                                                                                                               
 dict_set_uint64(dict_t *this, char *key, uint64_t val);                                                                                                                                                          
                                                                                                                                                                                                                  
 /* POSIX-compliant systems requires the 'time_t' to be a signed integer. */                                                                                                                                      
+#define __WORDSIZE 64                                                                                                                                                                                            
 #if __WORDSIZE == 64                                                                                                                                                                                             
 #define dict_get_time(dict, key, val) dict_get_int64((dict), (key), (val))                                                                                                                                       
 #define dict_set_time(dict, key, val) dict_set_int64((dict), (key), (val)) 


--- ../glusterfs-release-10/xlators/mgmt/glusterd/src/glusterd-utils.c                                                                                                                                            
+++ xlators/mgmt/glusterd/src/glusterd-utils.c                                                                                                                                                                    
@@ -7,6 +7,9 @@                                                                                                                                                                                                   
    later), or the GNU General Public License, version 2 (GPLv2), in all                                                                                                                                          
    cases as published by the Free Software Foundation.                                                                                                                                                           
 */                                                                                                                                                                                                               
+#ifndef _PATH_MOUNTED                                                                                                                                                                                            
+#define _PATH_MOUNTED "/etc/mtab"                                                                                                                                                                                
+#endif                                                                                                                                                                                                           
 #include <inttypes.h>                                                                                                                                                                                            
                                                                                                                                                                                                                  
 #if defined(GF_LINUX_HOST_OS)

Maybe some of them make no sense, i just added them so that it can compile and to show where the problems are,
not to make it work correctly

Hint: The target-triplet of the gcc was aarch64-alpine-linux-musl

Update:
in musl-libcs unistd.h they define off64_t as following:

#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
....
#define off64_t off_t
#endif

so in api/src/glfs.h maybe that could be checked too?
like:

#if (defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)) && !defined(__off64_t_defined)
#define __off64_t_defined
#endif

Update2:
_PATH_MOUNTED is in glibc defined by <mntent.h>, which includes <path.h> where it is defined. But musl's <mntent.h> doesn't include <path.h>. So two ways of solving this are:

  1. use the MOUNTED macro but i think thats deprecated?
  2. replace <mntent.h> with/add #include <paths.h>

@cpdef
Copy link

cpdef commented Mar 5, 2022

rpic4:~# uname -a
Linux rpic4 5.15.4-0-rpi4 #1-Alpine SMP PREEMPT Mon Nov 22 10:43:31 UTC 2021 aarch64 GNU/Linux
rpic4:~# gluster peer status
Number of Peers: 3

Hostname: rpic2
Uuid: 2d5904f3-3dfe-47a8-b293-b373349721de
State: Peer in Cluster (Connected)

Hostname: rpic1
Uuid: 5e3b90cf-7fb0-4340-b09f-ebee503f0e95
State: Peer in Cluster (Connected)

Hostname: rpic3
Uuid: d2c27958-88de-4447-bc87-ba1eeaa88b4c
State: Peer in Cluster (Connected)
rpic4:~# gluster volume info

Volume Name: gluster1
Type: Replicate
Volume ID: 1e98d5ff-f28a-47b3-8ad0-64c2633055da
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 4 = 4
Transport-type: tcp
Bricks:
Brick1: rpic1:/cluster/gluster1/brick1/volume
Brick2: rpic2:/cluster/gluster1/brick2/volume
Brick3: rpic3:/cluster/gluster1/brick3/volume
Brick4: rpic4:/cluster/gluster1/brick4/volume
Options Reconfigured:
cluster.granular-entry-heal: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off
rpic4:~# gcc -dumpmachine
aarch64-alpine-linux-musl

@stale
Copy link

stale bot commented Oct 16, 2022

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label Oct 16, 2022
@J0WI
Copy link

J0WI commented Oct 17, 2022

bump

@stale stale bot removed the wontfix Managed by stale[bot] label Oct 17, 2022
@stale
Copy link

stale bot commented May 21, 2023

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label May 21, 2023
@wenerme
Copy link

wenerme commented May 21, 2023

😞

@stale stale bot removed the wontfix Managed by stale[bot] label May 21, 2023
@ADIX7
Copy link

ADIX7 commented May 23, 2023

Any info about this?

@pranithk
Copy link
Member

pranithk commented Jan 3, 2025

@amarts We are doing a triage of the bugs that we are going to fix. Do you have bandwidth to work on this? Otherwise we can go ahead and close it. If you have partial solution somewhere, please publish it, so that we can refer to this in the future if we want to pick it up.

@amarts
Copy link
Member

amarts commented Jan 3, 2025

No bandwidth. Will close.

@amarts amarts closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
kohlschuetter added a commit to kohlschuetter/glusterfs that referenced this issue Jan 15, 2025
Prerequisites:

sudo apk add alpine-sdk autoconf automake libtool rpcgen tcmalloc \
  tcmalloc-minimal flex bison openssl-dev util-linux-dev acl-dev \
  zlib-dev libxml2-dev argp-standalone liburing-dev linux-headers \
  userspace-rcu-dev libucontext-dev
sudo ln -s /usr/lib/libtcmalloc.so.4 \
  /usr/lib/libtcmalloc.so
sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 \
  /usr/lib/libtcmalloc_minimal.so

Fixes: gluster#268
@kohlschuetter kohlschuetter linked a pull request Jan 15, 2025 that will close this issue
kohlschuetter added a commit to kohlschuetter/glusterfs that referenced this issue Jan 15, 2025
Prerequisites:

sudo apk add alpine-sdk autoconf automake libtool rpcgen flex bison \
  gperftools-dev tcmalloc-minimal openssl-dev util-linux-dev acl-dev \
  zlib-dev libxml2-dev argp-standalone liburing-dev linux-headers \
  userspace-rcu-dev libucontext-dev

Fixes: gluster#268
kohlschuetter added a commit to kohlschuetter/glusterfs that referenced this issue Jan 15, 2025
Prerequisites:

sudo apk add alpine-sdk autoconf automake libtool rpcgen flex bison \
  gperftools-dev tcmalloc-minimal openssl-dev util-linux-dev acl-dev \
  zlib-dev libxml2-dev argp-standalone liburing-dev linux-headers \
  userspace-rcu-dev libucontext-dev

Fixes: gluster#268
kohlschuetter added a commit to kohlschuetter/glusterfs that referenced this issue Jan 15, 2025
Prerequisites:

sudo apk add alpine-sdk autoconf automake libtool rpcgen flex bison \
  gperftools-dev tcmalloc-minimal openssl-dev util-linux-dev acl-dev \
  zlib-dev libxml2-dev argp-standalone liburing-dev linux-headers \
  userspace-rcu-dev libucontext-dev libtirpc-dev

Fixes: gluster#268
@pranithk
Copy link
Member

I see that @kohlschuetter is working on this issue and sent PR for the same. Re-opening the issue.

@pranithk pranithk reopened this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform Any platform specific questions/issues can be tagged with this label Question Type:Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.