Repository navigation
Conversation
Add system/libarchive. It downloads libarchive 3.7.7 when the build is configured, applies 0001-fix-conflict-libarchive-for-nuttx.patch to it, and builds it for the Make and the CMake build. The library and some of its programs can be enabled in Kconfig. Assisted-by: Claude Code:claude-sonnet-5.5 Signed-off-by: anjiahao <anjiahao@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Define HAVE_LIBLZMA and HAVE_LIBLZMADEC in config.h when CONFIG_UTILS_XZ is set, and HAVE_LIBZ when CONFIG_LIB_ZLIB is set, so that libarchive uses the compression libraries that are enabled. Assisted-by: Claude Code:claude-sonnet-5.5 Signed-off-by: anjiahao <anjiahao@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
libarchive needs the locale support of the C library, so UTILS_LIBARCHIVE depends on LIBC_LOCALE. Assisted-by: Claude Code:claude-sonnet-5.5 Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
1. add UTILS_LIBARCHIVE_UNICODE_NORMALIZATION
Enable Unicode NFC/NFD normalization for filename handling.
Disabling it can reduce the size of about 17K code (under LTO),
or 29K without LTO.
2. disable HAVE_LANGINFO, HAVE_ICONV according to CONFIG_LIBC_LOCALE
Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Reformat config.h to follow the NuttX coding style: add the Included Files and Pre-processor Definitions sections, and write the comments in the NuttX style. Assisted-by: Claude Code:claude-sonnet-5.5 Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Add a config which enables error strings, and default it to n. This saves flash size of about 4K when enabling libarchive. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Add config of ppmd and default to n. This saves flash size of about 6K when enabling libarchive. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.11K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 1.38K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 2.2K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.35K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.44K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.18K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
libarchive unconditionally compiles libarchive_fe/*.c (line_reader.c, err.c) and core archive_read_open_file.c / archive_write_open_file.c which use FILE* / fopen / stdin. When CONFIG_FILE_STREAM is disabled, the lib_get_stream() prototype in nuttx/lib/lib.h is hidden, so the stdin macro (stdio.h) expands to a call to an undeclared function returning int, triggering -Werror=int-conversion in line_reader.c. Add an explicit dependency so UTILS_LIBARCHIVE only appears when CONFIG_FILE_STREAM is enabled, preventing the invalid config combo. Signed-off-by: haopengxiang <haopengxiang@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
The iso9660 writer passes an enum parameter to va_start(), which undergoes default argument promotion. Clang treats this as an error with -Werror,-Wvarargs. Add -Wno-varargs to both CMakeLists.txt and Makefile to suppress it. Signed-off-by: cuiziwei <cuiziwei@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
The sources of libarchive are downloaded at build time, and only 0001-fix-conflict-libarchive-for-nuttx.patch was applied to them. Apply all the files that match 0*.patch in name order, in the Make and in the CMake build, so that further patches can be added next to it. Assisted-by: Claude Code:claude-sonnet-5.5 Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
add UTILS_LIBARCHIVE_UNICODE_NORMALIZATION Enable Unicode NFC/NFD normalization for filename handling. Disabling it can reduce the size of about 17K code (under LTO), or about 29K without LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Add a config which enables error strings, and default it to n. This saves flash size of about 4K when enabling libarchive. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Add config of ppmd and default to n. This saves flash size of about 6K when enabling libarchive. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disable the entire archive_string_normalize_C and archive_string_normalize_D functions instead of only their internal implementations. Otherwise the converter is still executed, leaving variables uninitialized and causing null pointer dereference and memfault. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Problem: After mounting, files could not be found due to a failure in string conversion. This issue occurred when `CONFIG_UTILS_LIBARCHIVE_UNICODE_NORMALIZATION` is disabled: - The `SCONV_NORMALIZATION_C` and `SCONV_NORMALIZATION_D` flags were still being set in some cases, even though `archive_string_normalize_C` and `archive_string_normalize_D` are disabled. - This caused the `setup_converter` function to skip adding the `strncat_from_utf8_to_utf8` converter. - As a result, no converter was added, and `nconverter` was set to 0, leading to the failure. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.11K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 1.38K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 2.2K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.35K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.44K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Disabling it saves 0.18K under LTO. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
Newer Clang versions emit -Werror on the INT_MIN <= O_NOFOLLOW comparison because INT_MIN (negative) gets implicitly converted to unsigned. Simplify the check to O_NOFOLLOW > INT_MAX which is logically equivalent and avoids the diagnostic. Signed-off-by: cuiziwei <cuiziwei@xiaomi.com> Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
libarchive, and nuttx-apps has no libarchive. The nuttx pull request is !fs/zipfs: Read zip files with libarchive and add the wzipfs writer. nuttx#21950.
CMakeLists.txt, Make.defs and config.h files, and 13 patch files.
enabled, the Make build downloads libarchive-3.7.7.zip at the context
step, and the CMake build fetches it with FetchContent. Then every file
that matches 0*.patch is applied, in the order of its name.
0002 to 0013 make parts of libarchive optional (Unicode normalization,
error strings, PPMd, Windows paths, Mac extensions, encryption, symbolic
links, ZIP64, the ZIP xl field), fix the handling of the normalization
flags, and remove a signed/unsigned comparison warning of newer clang.
Patch files are used because the source is downloaded.
(bsdunzip, bsdtar, bsdcat, cpio, minitar, tarfilter) are separate
options.
of the Kconfig, config.h and build files, commit 16 makes the build apply
every numbered patch, and commits 17 to 28 add the patch files 0002 to
0013. Their subjects repeat those of the Kconfig commits.
port.
Impact
No existing option or code changes.
off by default.
configurations. YES when UTILS_LIBARCHIVE is enabled, because the build
downloads libarchive from GitHub. After a build, changing the configuration
and running "make" again can fail, because the Makefile extracts the zip file
again and applies the patches a second time. "make distclean" and removing
the extracted libarchive directory fix it.
request documents zipfs.
party code that parses archives, and the option for encrypted entries is off
by default.
should depend on ALLOW_BSD_COMPONENTS was asked in system/libarchive: build libarchive support #3318, and I did not
find an answer. The Kconfig does not have that dependency.
Testing
I confirm that changes are verified on local setup and works as intended:
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0, GNU Make 4.3, CMake 3.28.3,
Ninja 1.11.1.
tested.
e9eefaa0e9a plus the nuttx pull request. Make and CMake with Ninja both
download libarchive and zlib, apply the 13 patches, and build sim:zipfs
without errors or warnings. In the CMake build, libarchive has 1442 files,
no .rej file, and the string UTILS_LIBARCHIVE_ZIP64 appears 7 times in
libarchive/archive_read_support_format_zip.c.
Testing logs before change: not applicable, the directory is new.
Testing logs after change (the nuttx binary built by CMake with Ninja), NSH
session as printed:
after
Not tested: real hardware, ostest, other architectures, the command line
programs (they were not built or run), and an encrypted archive. The nine
libarchive options (default, all on, each alone) were built before the last
rebase onto the current master, and the default and the all-on builds read an
archive in the simulator.
PR verification Self-Check
🤖 Generated with Claude Code