[PATCH] build: support building static library

Chen Linxuan me at black-desk.cn
Thu Jun 6 13:06:16 AEST 2024


On 2024/6/6 10:45, Gao Xiang wrote:
> 
> 
> On 2024/6/6 10:25, Chen Linxuan wrote:
>> Hi,
>>
>> On 2024/6/6 10:22, Gao Xiang wrote:
>>> Hi,
>>>
>>> On 2024/6/6 10:13, Chen Linxuan wrote:
>>>> Hi Xiang!
>>>>
>>>> On 2024/5/23 16:05, Gao Xiang wrote:
>>>>> Hi Comix!
>>>>>
>>>>> On 2024/5/23 15:31, ComixHe wrote:
>>>>>> In some cases, developer may need to integrate erofs-utils into their
>>>>>> proejct as a static library to reduce package dependencies and
>>>>>> have more finer control over the feature used by the project.
>>>>>
>>>>> Thanks for sharing this.
>>>>>
>>>>>>
>>>>>> For exapmle, squashfuse provides a static library 
>>>>>> `libsquashfuse.a` and
>>>>
>>>> We want a static library for running fuse-erofs, maybe liberofsfuse 
>>>> or something like that, to make a appimage like bundle with erofs.
>>>>
>>>> For quite a long time, Appimage guys patch the fuse program of 
>>>> squashfs to get such a static library, and this patch is accepted by 
>>>> Debian.
>>>>
>>>> https://github.com/AppImageCommunity/libappimage/blob/master/src/patches/squashfuse.patch
>>>>
>>>> https://salsa.debian.org/sgmoore/squashfuse/-/commit/489b04eb7f5e45478f2ba5cd8d7173bb96
>>>>
>>>> The patch just make a binary to be a static library by changing 
>>>> `main` to `fusefs_main`.
>>>>
>>>
>>> Since squashfs don't have any offical libsquashfs, so I guess they tried
>>> export the squashfuse project as a library.
>>>
>>> But erofs-utils is quite another story since we already have an offical
>>> `liberofs` concept.   If you'd like to export some FUSE interface, would
>>> you mind moving some logic in fuse/ to lib/?  Does this way also work
>>> for you?
>>
>> Sure.
>>
>> We will send other patches later.
> 
> Err, sorry, a second thought.. If you just would like
> to move all code from fuse/main.c to lib/,  I also think
> it's somewhat strange.
> 
> So just address your requirement (erofsfuse_main), would
> you mind just export liberofsfuse static library instead?
> Since it's a bit tangled with libfuse version, so I'm now
> hesitated to move into lib/...

So you mean that I should export a static library call "liberofsfuse".
And the only function it has is erofsfuse_main. Am I right?

But where should I place the source code of this new library? 
"liberofsfuse/", "lib/fuse" or somewhere else?

Thanks,
Chen Linxuan

> 
> For mkfs, I guess we will have offical API interfaces for
> users to build images later, so libmkerofs is not worthwhile.
> 
> I'm not sure dump.erofs is useful too since low-level APIs
> are provided. As for fsck, it's similar to mkfs in the future.
> 
> 
> Thanks,
> Gao Xiang
> 
>>
>> Thanks,
>> Chen Linxuan
>>
>>>
>>> Thanks,
>>> Gao Xiang
>>>
>>>
>>>> We just want to do the same thing appimage guys do to squashfs.
>>>>
>>>>>> exposes some useful functions, Appimage uses this static library 
>>>>>> to build
>>>>>> image. It could ensure that the executable image can be executed 
>>>>>> directly
>>>>>> on most linux platforms and the user doesn't need to install 
>>>>>> squashfuse
>>>>>> in order to execute the image.
>>>>>>
>>>>>> Signed-off-by: ComixHe <heyuming at deepin.org>
>>>>>> ---
>>>>>>   configure.ac     | 28 ++++++++++++++++++++++++++++
>>>>>>   dump/Makefile.am | 10 ++++++++++
>>>>>>   fsck/Makefile.am | 10 ++++++++++
>>>>>>   fuse/Makefile.am | 10 ++++++++++
>>>>>>   mkfs/Makefile.am | 10 ++++++++++
>>>>>>   5 files changed, 68 insertions(+)
>>>>>>
>>>>>> diff --git a/configure.ac b/configure.ac
>>>>>> index 1989bca..16ddb7c 100644
>>>>>> --- a/configure.ac
>>>>>> +++ b/configure.ac
>>>>>> @@ -147,6 +147,30 @@ AC_ARG_ENABLE(fuse,
>>>>>>      [AS_HELP_STRING([--enable-fuse], [enable erofsfuse 
>>>>>> @<:@default=no@:>@])],
>>>>>>      [enable_fuse="$enableval"], [enable_fuse="no"])
>>>>>> +AC_ARG_ENABLE([static-fuse],
>>>>>> +    [AS_HELP_STRING([--enable-static-fuse],
>>>>>> +                    [build erofsfuse as a static library 
>>>>>> @<:@default=no@:>@])],
>>>>>> +    [enable_static_fuse="$enableval"],
>>>>>> +    [enable_static_fuse="no"])
>>>>>> +
>>>>>> +AC_ARG_ENABLE([static-dump],
>>>>>> +    [AS_HELP_STRING([--enable-static-dump],
>>>>>> +                    [build dump.erofs as a static library 
>>>>>> @<:@default=no@:>@])],
>>>>>> +    [enable_static_dump="$enableval"],
>>>>>> +    [enable_static_dump="no"])
>>>>>> +
>>>>>> +AC_ARG_ENABLE([static-mkfs],
>>>>>> +    [AS_HELP_STRING([--enable-static-mkfs],
>>>>>> +                    [build mkfs.erofs as a static library 
>>>>>> @<:@default=no@:>@])],
>>>>>> +    [enable_static_mkfs="$enableval"],
>>>>>> +    [enable_static_mkfs="no"])
>>>>>> +
>>>>>> +AC_ARG_ENABLE([static-fsck],
>>>>>> +    [AS_HELP_STRING([--enable-static-fsck],
>>>>>> +                    [build fsck.erofs as a static library 
>>>>>> @<:@default=no@:>@])],
>>>>>> +    [enable_static_fsck="$enableval"],
>>>>>> +    [enable_static_fsck="no"])
>>>>>
>>>>> But how could we support static libraries from binaries?
>>>>>
>>>>> I guess you need static liberofs instead?
>>>>>
>>>>> Thanks,
>>>>> Gao Xiang
>>>>>
>>>
> 



More information about the Linux-erofs mailing list