Skip to content

Commit 5ed3ec5

Browse files
Initial FTS support (#522)
Close #520 Add FTS implementation derived from musl-fts with a few modifications. The compiled fts.o is included in the libc.a archive, and the fts.h header is installed in the sysroot (`include/fts.h`). * fts/musl-fts: Add a copy of the musl-fts sources with modifications. * fts/patches: A set of patches to apply to the musl-fts sources. * Upstream pull request: void-linux/musl-fts#14 * fts/update-musl-fts.sh: A script to update the musl-fts sources with the patches applied. * fts/config.h: A configuration header included by the musl-fts sources. * test/smoke: Add a test suite for wasi-libc specific features that libc-test does not cover.
1 parent 7d4d3b8 commit 5ed3ec5

22 files changed

+1989
-1
lines changed

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dlmalloc/ - CC0; see the notice in malloc.c for details
1010
emmalloc/ - MIT; see the notice in emmalloc.c for details
1111
libc-bottom-half/cloudlibc/ - BSD-2-Clause; see the LICENSE file for details
1212
libc-top-half/musl/ - MIT; see the COPYRIGHT file for details
13+
fts/musl-fts/ - BSD-3-Clause; see the COPYING file for details
1314

1415
wasi-libc's changes to these files are multi-licensed under the
1516
Apache License v2.0 with LLVM Exceptions, the Apache License v2.0,

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ LIBC_TOP_HALF_ALL_SOURCES = \
384384
$(LIBC_TOP_HALF_MUSL_SOURCES) \
385385
$(sort $(shell find $(LIBC_TOP_HALF_SOURCES) -name \*.[cs]))
386386

387+
FTS_SRC_DIR = fts
388+
MUSL_FTS_SRC_DIR = $(FTS_SRC_DIR)/musl-fts
389+
FTS_SOURCES = $(MUSL_FTS_SRC_DIR)/fts.c
390+
387391
# Add any extra flags
388392
CFLAGS = $(EXTRA_CFLAGS)
389393
# Set the target.
@@ -457,6 +461,7 @@ DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES))
457461
EMMALLOC_OBJS = $(call objs,$(EMMALLOC_SOURCES))
458462
LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES))
459463
LIBC_TOP_HALF_ALL_OBJS = $(call asmobjs,$(call objs,$(LIBC_TOP_HALF_ALL_SOURCES)))
464+
FTS_OBJS = $(call objs,$(FTS_SOURCES))
460465
ifeq ($(WASI_SNAPSHOT), p2)
461466
LIBC_OBJS += $(OBJDIR)/wasip2_component_type.o
462467
endif
@@ -475,6 +480,7 @@ ifeq ($(BUILD_LIBC_TOP_HALF),yes)
475480
# libc-top-half is musl.
476481
LIBC_OBJS += $(LIBC_TOP_HALF_ALL_OBJS)
477482
endif
483+
LIBC_OBJS += $(FTS_OBJS)
478484
MUSL_PRINTSCAN_OBJS = $(call objs,$(MUSL_PRINTSCAN_SOURCES))
479485
MUSL_PRINTSCAN_LONG_DOUBLE_OBJS = $(patsubst %.o,%.long-double.o,$(MUSL_PRINTSCAN_OBJS))
480486
MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS = $(patsubst %.o,%.no-floating-point.o,$(MUSL_PRINTSCAN_OBJS))
@@ -756,6 +762,10 @@ $(LIBC_TOP_HALF_ALL_OBJS) $(LIBC_TOP_HALF_ALL_SO_OBJS) $(MUSL_PRINTSCAN_LONG_DOU
756762
-Wno-dangling-else \
757763
-Wno-unknown-pragmas
758764

765+
$(FTS_OBJS): CFLAGS += \
766+
-I$(MUSL_FTS_SRC_DIR) \
767+
-I$(FTS_SRC_DIR) # for config.h
768+
759769
$(LIBWASI_EMULATED_PROCESS_CLOCKS_OBJS) $(LIBWASI_EMULATED_PROCESS_CLOCKS_SO_OBJS): CFLAGS += \
760770
-I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
761771

@@ -784,6 +794,8 @@ include_dirs:
784794
cp -r "$(LIBC_TOP_HALF_MUSL_DIR)"/arch/generic/bits/* "$(SYSROOT_INC)/bits"
785795
cp -r "$(LIBC_TOP_HALF_MUSL_DIR)"/arch/wasm32/bits/* "$(SYSROOT_INC)/bits"
786796

797+
cp "$(MUSL_FTS_SRC_DIR)/fts.h" "$(SYSROOT_INC)/fts.h"
798+
787799
# Remove selected header files.
788800
$(RM) $(patsubst %,$(SYSROOT_INC)/%,$(MUSL_OMIT_HEADERS))
789801
ifeq ($(WASI_SNAPSHOT), p2)

expected/wasm32-wasip1-threads/defined-symbols.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,11 @@ ftello64
714714
ftime
715715
ftruncate
716716
ftrylockfile
717+
fts_children
718+
fts_close
719+
fts_open
720+
fts_read
721+
fts_set
717722
funlockfile
718723
futimens
719724
futimesat

expected/wasm32-wasip1-threads/include-all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include <float.h>
8787
#include <fmtmsg.h>
8888
#include <fnmatch.h>
89+
#include <fts.h>
8990
#include <ftw.h>
9091
#include <getopt.h>
9192
#include <glob.h>

expected/wasm32-wasip1-threads/predefined-macros.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,40 @@
384384
#define FSETLOCKING_BYCALLER 2
385385
#define FSETLOCKING_INTERNAL 1
386386
#define FSETLOCKING_QUERY 0
387+
#define FTS_AGAIN 1
388+
#define FTS_COMFOLLOW 0x001
389+
#define FTS_D 1
390+
#define FTS_DC 2
391+
#define FTS_DEFAULT 3
392+
#define FTS_DNR 4
393+
#define FTS_DONTCHDIR 0x01
394+
#define FTS_DOT 5
395+
#define FTS_DP 6
396+
#define FTS_ERR 7
397+
#define FTS_F 8
398+
#define FTS_FOLLOW 2
399+
#define FTS_INIT 9
400+
#define FTS_ISW 0x04
401+
#define FTS_LOGICAL 0x002
402+
#define FTS_NAMEONLY 0x100
403+
#define FTS_NOCHDIR 0x004
404+
#define FTS_NOINSTR 3
405+
#define FTS_NOSTAT 0x008
406+
#define FTS_NS 10
407+
#define FTS_NSOK 11
408+
#define FTS_OPTIONMASK 0x0ff
409+
#define FTS_PHYSICAL 0x010
410+
#define FTS_ROOTLEVEL 0
411+
#define FTS_ROOTPARENTLEVEL -1
412+
#define FTS_SEEDOT 0x020
413+
#define FTS_SKIP 4
414+
#define FTS_SL 12
415+
#define FTS_SLNONE 13
416+
#define FTS_STOP 0x200
417+
#define FTS_SYMFOLLOW 0x02
418+
#define FTS_W 14
419+
#define FTS_WHITEOUT 0x080
420+
#define FTS_XDEV 0x040
387421
#define FTW_CHDIR 4
388422
#define FTW_D 2
389423
#define FTW_DEPTH 8
@@ -2075,6 +2109,7 @@
20752109
#define _FLOAT_H
20762110
#define _FMTMSG_H
20772111
#define _FNMATCH_H
2112+
#define _FTS_H_
20782113
#define _FTW_H
20792114
#define _GETOPT_H
20802115
#define _GLOB_H
@@ -3031,6 +3066,13 @@
30313066
#define __alignof_is_defined 1
30323067
#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8))
30333068
#define __bool_true_false_are_defined 1
3069+
#define __fts_dev_t dev_t
3070+
#define __fts_ino_t ino_t
3071+
#define __fts_length_t unsigned int
3072+
#define __fts_level_t int
3073+
#define __fts_nlink_t nlink_t
3074+
#define __fts_number_t int64_t
3075+
#define __fts_stat_t struct stat
30343076
#define __inline inline
30353077
#define __restrict restrict
30363078
#define __tg_complex(fun,x) (__RETCAST_CX(x)( __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : __LDBLCX((x)+I) ? fun ## l (x) : fun(x) ))

expected/wasm32-wasip1/defined-symbols.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,11 @@ ftello
648648
ftello64
649649
ftime
650650
ftruncate
651+
fts_children
652+
fts_close
653+
fts_open
654+
fts_read
655+
fts_set
651656
futimens
652657
futimesat
653658
fwide

expected/wasm32-wasip1/include-all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include <float.h>
8787
#include <fmtmsg.h>
8888
#include <fnmatch.h>
89+
#include <fts.h>
8990
#include <ftw.h>
9091
#include <getopt.h>
9192
#include <glob.h>

expected/wasm32-wasip1/predefined-macros.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,40 @@
384384
#define FSETLOCKING_BYCALLER 2
385385
#define FSETLOCKING_INTERNAL 1
386386
#define FSETLOCKING_QUERY 0
387+
#define FTS_AGAIN 1
388+
#define FTS_COMFOLLOW 0x001
389+
#define FTS_D 1
390+
#define FTS_DC 2
391+
#define FTS_DEFAULT 3
392+
#define FTS_DNR 4
393+
#define FTS_DONTCHDIR 0x01
394+
#define FTS_DOT 5
395+
#define FTS_DP 6
396+
#define FTS_ERR 7
397+
#define FTS_F 8
398+
#define FTS_FOLLOW 2
399+
#define FTS_INIT 9
400+
#define FTS_ISW 0x04
401+
#define FTS_LOGICAL 0x002
402+
#define FTS_NAMEONLY 0x100
403+
#define FTS_NOCHDIR 0x004
404+
#define FTS_NOINSTR 3
405+
#define FTS_NOSTAT 0x008
406+
#define FTS_NS 10
407+
#define FTS_NSOK 11
408+
#define FTS_OPTIONMASK 0x0ff
409+
#define FTS_PHYSICAL 0x010
410+
#define FTS_ROOTLEVEL 0
411+
#define FTS_ROOTPARENTLEVEL -1
412+
#define FTS_SEEDOT 0x020
413+
#define FTS_SKIP 4
414+
#define FTS_SL 12
415+
#define FTS_SLNONE 13
416+
#define FTS_STOP 0x200
417+
#define FTS_SYMFOLLOW 0x02
418+
#define FTS_W 14
419+
#define FTS_WHITEOUT 0x080
420+
#define FTS_XDEV 0x040
387421
#define FTW_CHDIR 4
388422
#define FTW_D 2
389423
#define FTW_DEPTH 8
@@ -2070,6 +2104,7 @@
20702104
#define _FLOAT_H
20712105
#define _FMTMSG_H
20722106
#define _FNMATCH_H
2107+
#define _FTS_H_
20732108
#define _FTW_H
20742109
#define _GETOPT_H
20752110
#define _GLOB_H
@@ -3021,6 +3056,13 @@
30213056
#define __alignof_is_defined 1
30223057
#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8))
30233058
#define __bool_true_false_are_defined 1
3059+
#define __fts_dev_t dev_t
3060+
#define __fts_ino_t ino_t
3061+
#define __fts_length_t unsigned int
3062+
#define __fts_level_t int
3063+
#define __fts_nlink_t nlink_t
3064+
#define __fts_number_t int64_t
3065+
#define __fts_stat_t struct stat
30243066
#define __inline inline
30253067
#define __restrict restrict
30263068
#define __tg_complex(fun,x) (__RETCAST_CX(x)( __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : __LDBLCX((x)+I) ? fun ## l (x) : fun(x) ))

expected/wasm32-wasip2/defined-symbols.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,11 @@ ftello
736736
ftello64
737737
ftime
738738
ftruncate
739+
fts_children
740+
fts_close
741+
fts_open
742+
fts_read
743+
fts_set
739744
futimens
740745
futimesat
741746
fwide

expected/wasm32-wasip2/include-all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include <float.h>
8787
#include <fmtmsg.h>
8888
#include <fnmatch.h>
89+
#include <fts.h>
8990
#include <ftw.h>
9091
#include <getopt.h>
9192
#include <glob.h>

0 commit comments

Comments
 (0)