Skip to content

Comments

Fix build with musl and add Alpine buildnode to CI#174

Merged
ericcurtin merged 10 commits intoinotify-tools:masterfrom
kraj:largefile
Dec 30, 2022
Merged

Fix build with musl and add Alpine buildnode to CI#174
ericcurtin merged 10 commits intoinotify-tools:masterfrom
kraj:largefile

Conversation

@kraj
Copy link
Contributor

@kraj kraj commented Dec 20, 2022

These functions are not needed on 64bit systems at all and also on 32bit systems with 64bit off_t

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #174 (5e13d66) into master (f57005c) will increase coverage by 44.57%.
The diff coverage is 40.00%.

❗ Current head 5e13d66 differs from pull request most recent head 6e5e718. Consider uploading reports for the commit 6e5e718 to get more accurate results

@@             Coverage Diff             @@
##           master     #174       +/-   ##
===========================================
+ Coverage        0   44.57%   +44.57%     
===========================================
  Files           0        7        +7     
  Lines           0     2380     +2380     
===========================================
+ Hits            0     1061     +1061     
- Misses          0     1319     +1319     
Impacted Files Coverage Δ
src/common.c 38.98% <0.00%> (ø)
libinotifytools/src/inotifytools.c 49.82% <100.00%> (ø)
libinotifytools/src/redblack.c 65.97% <0.00%> (ø)
libinotifytools/src/test.c 96.29% <0.00%> (ø)
src/inotifywait.c 53.26% <0.00%> (ø)
libinotifytools/src/stats.c 11.92% <0.00%> (ø)
src/inotifywatch.c 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kraj
Copy link
Contributor Author

kraj commented Dec 20, 2022

The failure on ubuntu 20.04 seems to be unrelated. It runs clang-format on this file but the .clang-format policy in the repo wants to use 8-character tab and the files src/common.c and libinotifytools/src/inotifytools.c which are modified in this pull request does not seem to be formatted as per the policy even without the modification that this PR is doing to them.

@kraj kraj force-pushed the largefile branch 6 times, most recently from fac3ed2 to 10a2cb3 Compare December 21, 2022 01:01
@kraj kraj force-pushed the largefile branch 6 times, most recently from b35fcd2 to 2853b84 Compare December 21, 2022 01:45
@kraj kraj changed the title Replace stat64/lstat64 with stat/lstat Fix build with musl and add Alpine buildnode to CI Dec 21, 2022
@kraj kraj force-pushed the largefile branch 9 times, most recently from ebf87d4 to 5e13d66 Compare December 21, 2022 08:01
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup latest Alpine Linux
uses: jirutka/setup-alpine@v1
Copy link
Member

@ericcurtin ericcurtin Dec 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately avoid these plugins, to avoid vendor lock-in, in case I have to migrate to GitLab or some other similar service in the future. We depend soley on free infrastructure, because we have zero funding.

I think you have the hard part done. Could we instead wrap in a podman or docker container directly and run this in one of the shell scripts?

The less .yml and plugins, the better!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if [ -n "$TRAVIS" ] || [ -n "$CI" ]; then
if [ "$os" != "freebsd" ]; then
if [ "${ID:-linux}" = "ubuntu" ] || [ "${ID:-linux}" = "debian" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where I'd like the alpine package installs to go, just to keep everything in the same place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah if we do not use plugin.

inotifytools_inc2="$inotifytools_inc/inotifytools"
inc="-I$usr_inc -I$inotifytools_inc -I$inotifytools_inc2"

if [ "${ID:-linux}" = "alpine" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to fix the things pointed out as warnings instead of disabling the warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing is hard because for that it has to get definition of the structure which is the whole problem with sys/fanotify.h mess-up that various libc implementations have done. I tried to swap the elements as well but that has same problem. Because clang does not allow VLAIS it complains about it. Usually it should work ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix it? 94dfc73e7cf4a31da66b8843f0b9283ddd6b8381

index f1f89132d60e2..197df344307db 100644
--- a/include/uapi/linux/fanotify.h
+++ b/include/uapi/linux/fanotify.h
@@ -162,7 +162,7 @@ struct fanotify_event_info_fid {
         * Following is an opaque struct file_handle that can be passed as
         * an argument to open_by_handle_at(2).
         */
-       unsigned char handle[0];
+       unsigned char handle[];
 };

maybe it doesn't, but I noticed they made this change in the kernel. I think the empty brackets is the modern way of doing it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that fixes it alright, this is what should be done instead of ignoring that warning... I just tested it...

#define stat64 stat
#define lstat64 lstat
#ifdef ENABLE_FANOTIFY
#if defined(__FreeBSD__) && defined(ENABLE_FANOTIFY)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -13,11 +13,6 @@
#include <sys/syscall.h>
#include <unistd.h>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1,11 +1,6 @@
#ifndef _inotifytools_H
#define _inotifytools_H

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ericcurtin
Copy link
Member

ericcurtin commented Dec 28, 2022

So if you look at the latest commit f57005c I put together an alpine container for you without the plugin, you just need to uncomment the line that says "alpine" and it's good to go.

kraj added 7 commits December 28, 2022 23:21
This will define _FILE_OFFSET_BITS to be 64 if off_t is 64bit
and we do not need to define lfs64 functions

Signed-off-by: Khem Raj <[email protected]>
When build tree is outside source-tree its not able to find
fanotify-dfid-name.h, add needed include paths on compiler commandline

Signed-off-by: Khem Raj <[email protected]>
System detects to use sys/fnotify.h and then assumes glibc's definitions
but musl has definitions of its own. perhaps portable thing would be to
use linux/fnotify.h interface directly on linux irrespective of libc

See the differences discussion here [1]

[1] https://inbox.vuxu.org/musl/20191112220151.GC27331@x230/T/#ma8700992467200c8792e0fa8508eae656b81aeba

Signed-off-by: Khem Raj <[email protected]>
lfs64 functions are not needed when off_t is 64-bit
Additionally this fixes build with musl which does not
export these functions without defining _LARGEFILE64_SOURCE

Signed-off-by: Khem Raj <[email protected]>
Fixes
-Wno-gnu-variable-sized-type-not-at-end for musl clang-format

Signed-off-by: Khem Raj <[email protected]>
@ericcurtin ericcurtin merged commit 8367bdd into inotify-tools:master Dec 30, 2022
@ericcurtin
Copy link
Member

Merged, thanks for the contribution...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants