From fb65436e06f406f918daa385f89326c58780aded Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 12 Feb 2024 12:22:43 +0200 Subject: [PATCH 001/112] ci: Fix the check of `PNG_LIBPNG_VER_BUILD` in ci_verify_version.sh `PNG_LIBPNG_VER_BUILD` should be zero for public releases and non-zero for development versions. The ci_verify_version.sh script should check this requirement as such. --- ci/ci_verify_version.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ci/ci_verify_version.sh b/ci/ci_verify_version.sh index 8199d7935d..58408ba963 100755 --- a/ci/ci_verify_version.sh +++ b/ci/ci_verify_version.sh @@ -71,16 +71,22 @@ function ci_verify_version { else ci_err "mismatched: \$PNG_LIBPNG_VER_DLLNUM != $my_expect" fi - if [[ "$PNG_LIBPNG_VER_BUILD" == 1 ]] + if [[ "$PNG_LIBPNG_VER_BUILD" == [01] ]] then - ci_info "matched: \$PNG_LIBPNG_VER_BUILD == 1" + ci_info "matched: \$PNG_LIBPNG_VER_BUILD == [01]" else - ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD != 1" + ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD != [01]" fi ci_info "## VERIFYING: png.h build definitions ##" my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}" if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect" ]] then + if [[ $PNG_LIBPNG_VER_BUILD -eq 0 ]] + then + ci_info "matched: \$PNG_LIBPNG_VER_BUILD -eq 0" + else + ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -ne 0" + fi if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_STABLE ]] then ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_BETA" @@ -89,6 +95,12 @@ function ci_verify_version { fi elif [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect".git ]] then + if [[ $PNG_LIBPNG_VER_BUILD -ne 0 ]] + then + ci_info "matched: \$PNG_LIBPNG_VER_BUILD -ne 0" + else + ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -eq 0" + fi if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_BETA ]] then ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_BETA" From f74d5ecce84a6a77e4fa89e8403755c6f620dbfa Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 15 Feb 2024 14:37:24 +0200 Subject: [PATCH 002/112] ci: Pacify shellcheck version 0.8 and apply other linting improvements Work around a limitation in the `shellcheck source` directive, which does not recognize quotes in shellcheck versions older than 0.9. Also extend the checks for YAML files over the entire source tree, in preparation for the introduction of the GitHub Actions config file. --- ci/ci_lint.sh | 41 ++++++++++++++++++++------------------- ci/ci_shellify.sh | 2 +- ci/ci_verify_cmake.sh | 16 +++++++-------- ci/ci_verify_configure.sh | 2 +- ci/ci_verify_makefiles.sh | 20 +++++++++---------- ci/ci_verify_version.sh | 2 +- 6 files changed, 42 insertions(+), 41 deletions(-) diff --git a/ci/ci_lint.sh b/ci/ci_lint.sh index 9b9dc6bf26..2efe3714dd 100755 --- a/ci/ci_lint.sh +++ b/ci/ci_lint.sh @@ -8,7 +8,7 @@ set -o errexit -o pipefail -o posix # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" @@ -47,10 +47,10 @@ function ci_finish_lint { ci_info "## END OF LINTING ##" if [[ $CI_LINT_COUNTER -eq 0 ]] then - ci_info "success!" + ci_info "## SUCCESS ##" return 0 else - ci_warn "$CI_LINT_COUNTER failure(s)" + ci_info "linting failed" return 1 fi } @@ -61,14 +61,15 @@ function ci_lint_ci_scripts { return 0 } ci_info "## LINTING: CI scripts ##" - local my_file - ci_spawn "$CI_SHELLCHECK" --version - for my_file in ci/*.sh - do - ci_spawn "$CI_SHELLCHECK" -x "$my_file" || { - CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) - } - done + { + local my_file + ci_spawn "$CI_SHELLCHECK" --version + find ./ci -maxdepth 1 -name "*.sh" | + while IFS="" read -r my_file + do + ci_spawn "$CI_SHELLCHECK" -x "$my_file" + done + } || CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) } function ci_lint_text_files { @@ -77,7 +78,6 @@ function ci_lint_text_files { return 0 } ci_info "## LINTING: text files ##" - local my_file ci_spawn "$CI_EDITORCONFIG_CHECKER" --version ci_spawn "$CI_EDITORCONFIG_CHECKER" || { CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) @@ -90,14 +90,15 @@ function ci_lint_yaml_files { return 0 } ci_info "## LINTING: YAML files ##" - local my_file - ci_spawn "$CI_YAMLLINT" --version - for my_file in .*.yml - do - ci_spawn "$CI_YAMLLINT" --strict "$my_file" || { - CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) - } - done + { + local my_file + ci_spawn "$CI_YAMLLINT" --version + find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" | + while IFS="" read -r my_file + do + ci_spawn "$CI_YAMLLINT" --strict "$my_file" + done + } || CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) } function ci_lint { diff --git a/ci/ci_shellify.sh b/ci/ci_shellify.sh index bf6dd7ce6c..e6693af97a 100755 --- a/ci/ci_shellify.sh +++ b/ci/ci_shellify.sh @@ -8,7 +8,7 @@ set -o errexit -o pipefail -o posix # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh index 0985d5f84e..e3fd529dc3 100755 --- a/ci/ci_verify_cmake.sh +++ b/ci/ci_verify_cmake.sh @@ -8,7 +8,7 @@ set -o errexit -o pipefail -o posix # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" @@ -126,23 +126,23 @@ function ci_build { local all_cmake_build_flags=() local all_ctest_flags=() [[ $CI_CMAKE_TOOLCHAIN_FILE ]] && { - all_cmake_vars+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE") + all_cmake_vars+=("-DCMAKE_TOOLCHAIN_FILE=$CI_CMAKE_TOOLCHAIN_FILE") } [[ $CI_CC ]] && { - all_cmake_vars+=(-DCMAKE_C_COMPILER="$CI_CC") + all_cmake_vars+=("-DCMAKE_C_COMPILER=$CI_CC") } [[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && { [[ $CI_SANITIZERS ]] && CI_CC_FLAGS+="${CI_CC_FLAGS:+" "}-fsanitize=$CI_SANITIZERS" - all_cmake_vars+=(-DCMAKE_C_FLAGS="$CI_CC_FLAGS") + all_cmake_vars+=("-DCMAKE_C_FLAGS=$CI_CC_FLAGS") } [[ $CI_AR ]] && { - all_cmake_vars+=(-DCMAKE_AR="$CI_AR") + all_cmake_vars+=("-DCMAKE_AR=$CI_AR") } [[ $CI_RANLIB ]] && { - all_cmake_vars+=(-DCMAKE_RANLIB="$CI_RANLIB") + all_cmake_vars+=("-DCMAKE_RANLIB=$CI_RANLIB") } - all_cmake_vars+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE") - all_cmake_vars+=(-DCMAKE_VERBOSE_MAKEFILE=ON) + all_cmake_vars+=("-DCMAKE_BUILD_TYPE=$CI_CMAKE_BUILD_TYPE") + all_cmake_vars+=("-DCMAKE_VERBOSE_MAKEFILE=ON") all_cmake_vars+=($CI_CMAKE_VARS) all_cmake_build_flags+=($CI_CMAKE_BUILD_FLAGS) all_ctest_flags+=($CI_CTEST_FLAGS) diff --git a/ci/ci_verify_configure.sh b/ci/ci_verify_configure.sh index 0a2bd807a3..d73e80c266 100755 --- a/ci/ci_verify_configure.sh +++ b/ci/ci_verify_configure.sh @@ -8,7 +8,7 @@ set -o errexit -o pipefail -o posix # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" diff --git a/ci/ci_verify_makefiles.sh b/ci/ci_verify_makefiles.sh index a0db93879c..5b9217ad28 100755 --- a/ci/ci_verify_makefiles.sh +++ b/ci/ci_verify_makefiles.sh @@ -8,7 +8,7 @@ set -o errexit -o pipefail -o posix # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" @@ -97,33 +97,33 @@ function ci_build { all_make_flags+=($CI_MAKE_FLAGS) } [[ $CI_CC ]] && { - all_make_vars+=(CC="$CI_CC") + all_make_vars+=("CC=$CI_CC") } [[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && { [[ $CI_SANITIZERS ]] && CI_CC_FLAGS="${CI_CC_FLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS" - all_make_vars+=(CFLAGS="$CI_CC_FLAGS") + all_make_vars+=("CFLAGS=$CI_CC_FLAGS") } [[ $CI_CPP ]] && { - all_make_vars+=(CPP="$CI_CPP") + all_make_vars+=("CPP=$CI_CPP") } [[ $CI_CPP_FLAGS ]] && { - all_make_vars+=(CPPFLAGS="$CI_CPP_FLAGS") + all_make_vars+=("CPPFLAGS=$CI_CPP_FLAGS") } [[ $CI_AR ]] && { - all_make_vars+=(AR="$CI_AR") + all_make_vars+=("AR=$CI_AR") } [[ $CI_RANLIB ]] && { - all_make_vars+=(RANLIB="$CI_RANLIB") + all_make_vars+=("RANLIB=$CI_RANLIB") } [[ $CI_LD ]] && { - all_make_vars+=(LD="$CI_LD") + all_make_vars+=("LD=$CI_LD") } [[ $CI_LD_FLAGS || $CI_SANITIZERS ]] && { [[ $CI_SANITIZERS ]] && CI_LD_FLAGS+="${CI_LD_FLAGS:+" "}-fsanitize=$CI_SANITIZERS" - all_make_vars+=(LDFLAGS="$CI_LD_FLAGS") + all_make_vars+=("LDFLAGS=$CI_LD_FLAGS") } [[ $CI_LIBS ]] && { - all_make_vars+=(LIBS="$CI_LIBS") + all_make_vars+=("LIBS=$CI_LIBS") } all_make_vars+=($CI_MAKE_VARS) # And... build! diff --git a/ci/ci_verify_version.sh b/ci/ci_verify_version.sh index 58408ba963..c786f06acd 100755 --- a/ci/ci_verify_version.sh +++ b/ci/ci_verify_version.sh @@ -8,7 +8,7 @@ set -o errexit -o pipefail -o posix # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" From 42c8fcbff90925d47d780dcce23c53f205b42305 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 15 Feb 2024 15:43:54 +0200 Subject: [PATCH 003/112] Add a GitHub Action for linting --- .github/workflows/lint.yml | 27 +++++++++++++++++++++++++++ .yamllint.yml | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..b41c103287 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: Linting libpng + +on: + push: + branches: + - libpng16 + pull_request: + branches: + - libpng16 + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Set up the cache + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pip.txt') }} + restore-keys: ${{ runner.os }}-pip- + - name: Install yamllint + run: pip install yamllint + - name: Check out the code + uses: actions/checkout@v4 + - name: Run the linting script + run: bash ./ci/ci_lint.sh diff --git a/.yamllint.yml b/.yamllint.yml index 3829416280..9b7af5f2c3 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -3,3 +3,5 @@ rules: document-start: disable document-end: disable line-length: disable + truthy: + check-keys: false From 4191872d0dbd06ae7ff59cf06b02a7f9cbb5a790 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 15 Feb 2024 18:29:26 +0200 Subject: [PATCH 004/112] chore: Update the .editorconfig files and pacify editorconfig-checker --- .editorconfig | 23 +++- CMakeLists.txt | 4 +- contrib/.editorconfig | 8 +- contrib/examples/iccfrompng.c | 4 +- contrib/gregbook/rpng-x.c | 2 +- contrib/gregbook/rpng2-x.c | 2 +- contrib/pngminim/decoder/makefile | 2 +- contrib/visupng/.editorconfig | 22 ++++ loongarch/.editorconfig | 1 + mips/.editorconfig | 8 ++ png.c | 14 +-- powerpc/.editorconfig | 1 + projects/.editorconfig | 12 +-- scripts/pnglibconf.dfa | 169 +++++++++++++++++------------- tests/pngtest-all | 2 +- 15 files changed, 166 insertions(+), 108 deletions(-) create mode 100644 contrib/visupng/.editorconfig create mode 100644 mips/.editorconfig diff --git a/.editorconfig b/.editorconfig index 34a145d4c4..324bdf7d59 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,29 +10,44 @@ trim_trailing_whitespace = true # Traditionally, the end-of-line character has been platform-specific. end_of_line = unset +[*.txt] +indent_style = space + [*.[chS]] indent_style = space +max_doc_length = 80 max_line_length = 81 +# FIXME: max_line_length should be 80 -[*.{awk,cmake,dfa,in,sh}] +[*.dfa] indent_style = space +max_doc_length = 80 +max_line_length = 80 + +[*.{awk,cmake}] +indent_style = space +max_doc_length = 80 max_line_length = 100 -[*.txt] +[*.{in,sh}] indent_style = space -max_line_length = unset +max_doc_length = 100 +max_line_length = 100 [{Makefile.in,ltmain.sh}] indent_style = unset insert_final_newline = unset +max_doc_length = unset max_line_length = unset trim_trailing_whitespace = unset [*~] +end_of_line = unset indent_style = unset insert_final_newline = unset -max_line_length = unset trim_trailing_whitespace = unset [COMMIT_EDITMSG] +indent_style = space +max_doc_length = unset max_line_length = 72 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cf62ba836..8bff18ff6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,7 +265,7 @@ if(TARGET_ARCH MATCHES "^(loongarch)") if(COMPILER_SUPPORTS_LSX) set(libpng_loongarch_sources loongarch/loongarch_lsx_init.c - loongarch/filter_lsx_intrinsics.c) + loongarch/filter_lsx_intrinsics.c) set_source_files_properties(${libpng_loongarch_sources} PROPERTIES COMPILE_FLAGS "-mlsx") @@ -302,7 +302,7 @@ endif() # Set definitions and sources for LoongArch. if(TARGET_ARCH MATCHES "^(loongarch)") - add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) + add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) endif() endif(PNG_HARDWARE_OPTIMIZATIONS) diff --git a/contrib/.editorconfig b/contrib/.editorconfig index bd9b590d34..e1b551df73 100644 --- a/contrib/.editorconfig +++ b/contrib/.editorconfig @@ -2,12 +2,6 @@ root = false -[*] -charset = unset -end_of_line = unset -indent_size = unset -indent_style = unset -insert_final_newline = unset +[*.[ch]] max_doc_length = unset max_line_length = unset -trim_trailing_whitespace = unset diff --git a/contrib/examples/iccfrompng.c b/contrib/examples/iccfrompng.c index 00056abfd7..0f86714a81 100644 --- a/contrib/examples/iccfrompng.c +++ b/contrib/examples/iccfrompng.c @@ -80,7 +80,7 @@ extract(FILE *fp, png_uint_32 *proflen) } else - result = no_profile; + result = no_profile; } png_destroy_read_struct(&png_ptr, &info_ptr, NULL); @@ -155,7 +155,7 @@ extract_one_file(const char *filename) } else if (verbose && profile == no_profile) - printf("%s has no profile\n", filename); + printf("%s has no profile\n", filename); } else diff --git a/contrib/gregbook/rpng-x.c b/contrib/gregbook/rpng-x.c index 92effaa6d2..2fc9272c64 100644 --- a/contrib/gregbook/rpng-x.c +++ b/contrib/gregbook/rpng-x.c @@ -21,7 +21,7 @@ - 1.10: added support for non-default visuals; fixed X pixel-conversion - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed command-line parsing bug - - 1.12: fixed some small X memory leaks (thanks to François Petitjean) + - 1.12: fixed some small X memory leaks (thanks to François Petitjean) - 1.13: fixed XFreeGC() crash bug (thanks to Patrick Welche) - 1.14: added support for X resources (thanks to Gerhard Niklasch) - 2.00: dual-licensed (added GNU GPL) diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c index af944c0f2b..1375dc9a6d 100644 --- a/contrib/gregbook/rpng2-x.c +++ b/contrib/gregbook/rpng2-x.c @@ -27,7 +27,7 @@ - 1.11: added -usleep option for demos; fixed command-line parsing bug - 1.12: added -pause option for demos and testing - 1.20: added runtime MMX-enabling/disabling and new -mmx* options - - 1.21: fixed some small X memory leaks (thanks to François Petitjean) + - 1.21: fixed some small X memory leaks (thanks to François Petitjean) - 1.22: fixed XFreeGC() crash bug (thanks to Patrick Welche) - 1.23: added -bgpat 0 mode (std white/gray checkerboard, 8x8 squares) - 1.30: added -loop option for -bgpat (ifdef FEATURE_LOOP); fixed bpp = diff --git a/contrib/pngminim/decoder/makefile b/contrib/pngminim/decoder/makefile index 4acf3c1779..bbacea4bb8 100644 --- a/contrib/pngminim/decoder/makefile +++ b/contrib/pngminim/decoder/makefile @@ -54,7 +54,7 @@ ZOBJS = adler32$(O) crc32$(O) \ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \ pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \ pngset$(C) pngtrans$(C) - + # Standard headers PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h diff --git a/contrib/visupng/.editorconfig b/contrib/visupng/.editorconfig new file mode 100644 index 0000000000..d946b14461 --- /dev/null +++ b/contrib/visupng/.editorconfig @@ -0,0 +1,22 @@ +# https://editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = unset +indent_style = unset +insert_final_newline = true +max_doc_length = 80 +max_line_length = 100 +trim_trailing_whitespace = true + +[*.rc] +end_of_line = crlf +trim_trailing_whitespace = unset + +[*.ds[pw]] +end_of_line = crlf +max_doc_length = unset +max_line_length = unset +trim_trailing_whitespace = unset diff --git a/loongarch/.editorconfig b/loongarch/.editorconfig index b142d823b1..de2e98ab42 100644 --- a/loongarch/.editorconfig +++ b/loongarch/.editorconfig @@ -4,4 +4,5 @@ root = false # FIXME [*.[ch]] +max_doc_length = unset max_line_length = unset diff --git a/mips/.editorconfig b/mips/.editorconfig new file mode 100644 index 0000000000..de2e98ab42 --- /dev/null +++ b/mips/.editorconfig @@ -0,0 +1,8 @@ +# https://editorconfig.org + +root = false + +# FIXME +[*.[ch]] +max_doc_length = unset +max_line_length = unset diff --git a/png.c b/png.c index 997b8d4dc1..802c61e821 100644 --- a/png.c +++ b/png.c @@ -1821,14 +1821,14 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, } # ifdef PNG_WARNINGS_SUPPORTED else - { - char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */ + { + char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */ - pos = png_safecat(message, (sizeof message), pos, - png_format_number(number, number+(sizeof number), - PNG_NUMBER_FORMAT_x, value)); - pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */ - } + pos = png_safecat(message, (sizeof message), pos, + png_format_number(number, number+(sizeof number), + PNG_NUMBER_FORMAT_x, value)); + pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */ + } # endif /* The 'reason' is an arbitrary message, allow +79 maximum 195 */ pos = png_safecat(message, (sizeof message), pos, reason); diff --git a/powerpc/.editorconfig b/powerpc/.editorconfig index b142d823b1..de2e98ab42 100644 --- a/powerpc/.editorconfig +++ b/powerpc/.editorconfig @@ -4,4 +4,5 @@ root = false # FIXME [*.[ch]] +max_doc_length = unset max_line_length = unset diff --git a/projects/.editorconfig b/projects/.editorconfig index bd9b590d34..dc99bd001c 100644 --- a/projects/.editorconfig +++ b/projects/.editorconfig @@ -1,13 +1,3 @@ # https://editorconfig.org -root = false - -[*] -charset = unset -end_of_line = unset -indent_size = unset -indent_style = unset -insert_final_newline = unset -max_doc_length = unset -max_line_length = unset -trim_trailing_whitespace = unset +root = true diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index 739805d2d9..fe8e481238 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -204,26 +204,33 @@ option SET_OPTION disabled # These options are specific to the ARM NEON hardware optimizations. At present # these optimizations depend on GCC specific pre-processing of an assembler (.S) -# file so they probably won't work with other compilers. -# -# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by -# the compiler, typically as a result of specifying -# CC="gcc -mfpu=neon".) -# 0: disable (even if the CPU has a NEON FPU.) -# 1: check at run time (via ARM_NEON_{API,CHECK}) -# 2: switch on unconditionally (inadvisable - instead pass -# -mfpu=neon to GCC in CC) -# When building libpng avoid using any setting other than '0'; '1' is -# set automatically when either 'API' or 'CHECK' are configured in, -# '2' should not be necessary as -mfpu=neon will achieve the same -# effect as well as applying NEON optimizations to the rest of the -# libpng code. -# NOTE: any setting other than '0' requires ALIGNED_MEMORY -# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on -# with png_set_option -# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon -# extensions are supported. This is poorly supported and -# deprecated - use the png_set_option API. +# file, so they probably won't work with other compilers. +# +# ARM_NEON_OPT: +# unset: check at compile time +# (__ARM_NEON__ must be predefined by the compiler, as a result of +# passing "-mfpu=neon" to the compiler options) +# 0: disable (even if the CPU has a NEON FPU) +# 1: check at run time (via ARM_NEON_{API,CHECK}) +# 2: switch on unconditionally +# (inadvisable - instead, pass "-mfpu=neon" to the compiler) +# NOTE: +# When building libpng, avoid using any setting other than '0'; +# '1' is set automatically when either 'API' or 'CHECK' are configured in; +# '2' should not be necessary, as "-mfpu=neon" will achieve the same effect +# as well as applying the NEON optimizations to the rest of libpng. +# NOTE: +# Any setting other than '0' requires ALIGNED_MEMORY. +# +# ARM_NEON_API: +# (PNG_ARM_NEON == 1) +# Allow the optimization to be switched on with png_set_option. +# +# ARM_NEON_CHECK: +# (PNG_ARM_NEON == 1) +# Compile a run-time check to see if Neon extensions are supported. +# This is poorly supported and deprecated - use the png_set_option API. +# setting ARM_NEON_OPT option ARM_NEON_API disabled requires ALIGNED_MEMORY enables SET_OPTION, sets ARM_NEON_OPT 1 @@ -232,24 +239,29 @@ option ARM_NEON_CHECK disabled requires ALIGNED_MEMORY, # These options are specific to the PowerPC VSX hardware optimizations. # -# POWERPC_VSX_OPT: unset: check at compile time (__PPC64__,__ALTIVEC__,__VSX__ -# must be defined by the compiler, typically as a result -# of specifying -# "-mvsx -maltivec" compiler flags) -# 0: disable (even if the CPU supports VSX.) -# 1: check at run time (via POWERPC_VSX_{API,CHECK}) -# 2: switch on unconditionally (inadvisable - instead pass -# -mvsx -maltivec to compiler options) -# When building libpng avoid using any setting other than '0'; '1' is -# set automatically when either 'API' or 'CHECK' are configured in, -# '2' should not be necessary as "-mvsx -maltivec" will achieve the same -# effect as well as applying VSX optimizations to the rest of the -# libpng code. -# POWERPC_VSX_API: (PNG_POWERPC_VSX == 1) allow the optimization to be switched on -# with png_set_option -# POWERPC_VSX_CHECK: (PNG_POWERPC_VSX == 1) compile a run-time check to see if VSX -# extensions are supported. This is supported not for all OSes -# (see contrib/powerpc/README) +# POWERPC_VSX_OPT: +# unset: check at compile time +# (__PPC64__,__ALTIVEC__,__VSX__ must be predefined by the compiler, +# as a result of passing "-mvsx -maltivec" to the compiler options) +# 0: disable (even if the CPU supports VSX) +# 1: check at run time (via POWERPC_VSX_{API,CHECK}) +# 2: switch on unconditionally +# (inadvisable - instead, pass "-mvsx -maltivec" to the compiler) +# NOTE: +# When building libpng, avoid using any setting other than '0'; +# '1' is set automatically when either 'API' or 'CHECK' are configured in; +# '2' should not be necessary, as "-mvsx -maltivec" will achieve the same +# effect as well as applying the VSX optimizations to the rest of libpng. +# +# POWERPC_VSX_API: +# (PNG_POWERPC_VSX == 1) +# Allow the optimization to be switched on with png_set_option. +# +# POWERPC_VSX_CHECK: +# (PNG_POWERPC_VSX == 1) +# Compile a run-time check to see if VSX extensions are supported. +# This is not supported on all systems. See contrib/powerpc-vsx/README. +# setting POWERPC_VSX_OPT option POWERPC_VSX_API disabled enables SET_OPTION, sets POWERPC_VSX_OPT 1 @@ -258,23 +270,30 @@ option POWERPC_VSX_CHECK disabled, # These options are specific to the MIPS MSA hardware optimizations. # -# MIPS_MSA_OPT: unset: check at compile time (__mips_msa must be defined by -# the compiler, typically as a result of specifying -# "-mmsa -mfp64" compiler flags) -# 0: disable (even if the CPU supports MSA.) -# 1: check at run time (via MIPS_MSA_{API,CHECK}) -# 2: switch on unconditionally (inadvisable - instead pass -# -mmsa -mfp64 to compiler options) -# When building libpng avoid using any setting other than '0'; '1' is -# set automatically when either 'API' or 'CHECK' are configured in, -# '2' should not be necessary as "-mmsa -mfp64" will achieve the same -# effect as well as applying MSA optimizations to the rest of the -# libpng code. -# NOTE: any setting other than '0' requires ALIGNED_MEMORY -# MIPS_MSA_API: (PNG_MIPS_MSA == 1) allow the optimization to be switched on -# with png_set_option. -# MIPS_MSA_CHECK: (PNG_MIPS_MSA == 1) compile a run-time check to see if MSA -# extensions are supported. +# MIPS_MSA_OPT: +# unset: check at compile time +# (__mips_msa must be predefined by the compiler, as a result of +# passing "-mmsa -mfp64" to the compiler options) +# 0: disable (even if the CPU supports MSA) +# 1: check at run time (via MIPS_MSA_{API,CHECK}) +# 2: switch on unconditionally +# (inadvisable - instead, pass "-mmsa -mfp64" to the compiler) +# NOTE: +# When building libpng, avoid using any setting other than '0'; +# '1' is set automatically when either 'API' or 'CHECK' are configured in; +# '2' should not be necessary, as "-mmsa -mfp64" will achieve the same +# effect as well as applying the MSA optimizations to the rest of libpng. +# NOTE: +# Any setting other than '0' requires ALIGNED_MEMORY. +# +# MIPS_MSA_API: +# (PNG_MIPS_MSA == 1) +# Allow the optimization to be switched on with png_set_option. +# +# MIPS_MSA_CHECK: +# (PNG_MIPS_MSA == 1) +# Compile a run-time check to see if MSA extensions are supported. +# setting MIPS_MSA_OPT option MIPS_MSA_API disabled requires ALIGNED_MEMORY enables SET_OPTION, sets MIPS_MSA_OPT 1 @@ -283,22 +302,30 @@ option MIPS_MSA_CHECK disabled requires ALIGNED_MEMORY, # These options are specific to the MIPS MMI hardware optimizations. # -# MIPS_MMI_OPT: unset: check at compile time (__mips_loongson_mmi must be defined by -# the compiler, typically as a result of specifying -# "-mloongson-mmi -march=loongson3a" compiler flags) -# 0: disable (even if the CPU supports MMI.) -# 1: check at run time (via MIPS_MMI_{API,CHECK}) -# 2: switch on unconditionally (inadvisable - instead pass -# -mloongson-mmi -march=loongson3a to compiler options) -# When building libpng avoid using any setting other than '0'; '1' is -# set automatically when either 'API' or 'CHECK' are configured in, -# '2' should not be necessary as "-mloongson-mmi -march=loongson3a" will achieve the same -# effect as well as applying MMI optimizations to the rest of the -# libpng code. -# MIPS_MMI_API: (PNG_MIPS_MMI == 1) allow the optimization to be switched on -# with png_set_option -# MIPS_MMI_CHECK: (PNG_MIPS_MMI == 1) compile a run-time check to see if MMI -# extensions are supported. +# MIPS_MMI_OPT: +# unset: check at compile time +# (__mips_loongson_mmi must be defined by the compiler, as a result of +# passing "-mloongson-mmi -march=loongson3a" to the compiler options) +# 0: disable (even if the CPU supports MMI) +# 1: check at run time (via MIPS_MMI_{API,CHECK}) +# 2: switch on unconditionally +# (inadvisable - instead, pass "-mloongson-mmi -march=loongson3a" to the +# compiler) +# NOTE: +# When building libpng, avoid using any setting other than '0'; +# '1' is set automatically when either 'API' or 'CHECK' are configured in; +# '2' should not be necessary, as "-mloongson-mmi -march=loongson3a" will +# achieve the same effect as well as applying the MMI optimizations to the +# rest of libpng. +# +# MIPS_MMI_API: +# (PNG_MIPS_MMI == 1) +# Allow the optimization to be switched on with png_set_option. +# +# MIPS_MMI_CHECK: +# (PNG_MIPS_MMI == 1) +# Compile a run-time check to see if MMI extensions are supported. +# setting MIPS_MMI_OPT option MIPS_MMI_API disabled requires ALIGNED_MEMORY enables SET_OPTION, sets MIPS_MMI_OPT 1 diff --git a/tests/pngtest-all b/tests/pngtest-all index b4280f5ffc..668d92e9c3 100755 --- a/tests/pngtest-all +++ b/tests/pngtest-all @@ -15,7 +15,7 @@ TEST(){ 77) test_status="$skip" skipped=1;; *) test_status="$fail" - st="$status";; + st="$status";; esac echo "===============$test_status $* ====================" return "$status" From 0fa3c0f698c2ca618a0fa44e10a822678df85373 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 15 Feb 2024 21:53:24 +0200 Subject: [PATCH 005/112] chore: Clean up the spurious uses of `sizeof(png_byte)`; fix the manual By definition, `sizeof(png_byte)` is 1. Remove all the occurences of `sizeof(png_byte)` from the code, and fix a related typo in the libpng manual. Also update the main .editorconfig file to reflect the fixing expected by a FIXME note. --- .editorconfig | 3 +-- libpng-manual.txt | 4 ++-- libpng.3 | 4 ++-- pngrtran.c | 17 +++++++---------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.editorconfig b/.editorconfig index 324bdf7d59..7f9f1c9bfe 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,8 +16,7 @@ indent_style = space [*.[chS]] indent_style = space max_doc_length = 80 -max_line_length = 81 -# FIXME: max_line_length should be 80 +max_line_length = 80 [*.dfa] indent_style = space diff --git a/libpng-manual.txt b/libpng-manual.txt index eb24ef4831..d2918ce316 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -1178,11 +1178,11 @@ where row_pointers is an array of pointers to the pixel data for each row: If you know your image size and pixel size ahead of time, you can allocate row_pointers prior to calling png_read_png() with - if (height > PNG_UINT_32_MAX/(sizeof (png_byte))) + if (height > PNG_UINT_32_MAX / (sizeof (png_bytep))) png_error(png_ptr, "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) + if (width > PNG_UINT_32_MAX / pixel_size) png_error(png_ptr, "Image is too wide to process in memory"); diff --git a/libpng.3 b/libpng.3 index 57d06f2db6..8875b219a1 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1697,11 +1697,11 @@ where row_pointers is an array of pointers to the pixel data for each row: If you know your image size and pixel size ahead of time, you can allocate row_pointers prior to calling png_read_png() with - if (height > PNG_UINT_32_MAX/(sizeof (png_byte))) + if (height > PNG_UINT_32_MAX / (sizeof (png_bytep))) png_error(png_ptr, "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) + if (width > PNG_UINT_32_MAX / pixel_size) png_error(png_ptr, "Image is too wide to process in memory"); diff --git a/pngrtran.c b/pngrtran.c index 74cca476b1..041f9306c1 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -440,7 +440,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, int i; png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); + (png_alloc_size_t)num_palette); for (i = 0; i < num_palette; i++) png_ptr->quantize_index[i] = (png_byte)i; } @@ -457,7 +457,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize an array to sort colors */ png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); + (png_alloc_size_t)num_palette); /* Initialize the quantize_sort array */ for (i = 0; i < num_palette; i++) @@ -591,11 +591,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * - (sizeof (png_byte)))); + (png_alloc_size_t)num_palette); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * - (sizeof (png_byte)))); + (png_alloc_size_t)num_palette); /* Initialize the sort array */ for (i = 0; i < num_palette; i++) @@ -760,12 +758,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, size_t num_entries = ((size_t)1 << total_bits); png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, - (png_alloc_size_t)(num_entries * (sizeof (png_byte)))); + (png_alloc_size_t)(num_entries)); - distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries * - (sizeof (png_byte)))); + distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)num_entries); - memset(distance, 0xff, num_entries * (sizeof (png_byte))); + memset(distance, 0xff, num_entries); for (i = 0; i < num_palette; i++) { From 72c4520d3c49cf1db439d835264b21c1aafaa9aa Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 17 Feb 2024 11:56:35 +0200 Subject: [PATCH 006/112] ci: Allow the user to force an in-tree cleanup before verification Introduce the environment option CI_FORCE: * ci_verify_configure.sh is known to fail if an existing build configuration is found in the top-level directory. Setting CI_FORCE=1 will run `make distclean` before verification. * ci_verify_makefiles.sh cannot be reliably executed if random object files are found in the top-level directory. Setting CI_FORCE=1 will run `rm *.o *.obj` before verification. * ci_verify_cmake.sh is not known at this time to fail for similar reasons; but if it does, we will use CI_FORCE to trigger any necessary pre-build cleanup. --- ci/ci_verify_cmake.sh | 1 + ci/ci_verify_configure.sh | 26 +++++++++++++++++++------- ci/ci_verify_makefiles.sh | 28 +++++++++++++++++++++------- ci/lib/ci.lib.sh | 3 +++ 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh index e3fd529dc3..9fe6340263 100755 --- a/ci/ci_verify_cmake.sh +++ b/ci/ci_verify_cmake.sh @@ -69,6 +69,7 @@ function ci_trace_build { ci_info "environment option: \$CI_AR: '$CI_AR'" ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_FORCE: '$CI_FORCE'" ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'" ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" diff --git a/ci/ci_verify_configure.sh b/ci/ci_verify_configure.sh index d73e80c266..141c7a2834 100755 --- a/ci/ci_verify_configure.sh +++ b/ci/ci_verify_configure.sh @@ -57,6 +57,7 @@ function ci_trace_build { ci_info "environment option: \$CI_LD: '$CI_LD'" ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_FORCE: '$CI_FORCE'" ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'" ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" @@ -80,18 +81,29 @@ function ci_trace_build { } function ci_cleanup_old_build { - ci_info "## START OF PRE-BUILD CHECKUP ##" - ci_spawn test '!' -f "$CI_SRC_DIR/config.status" || { - # Warn the user, but do not delete their files. - ci_warn "unexpected build configuration file: '$CI_SRC_DIR/config.status'" - ci_warn "the configure script might fail" - } - ci_info "## END OF PRE-BUILD CHECKUP ##" ci_info "## START OF PRE-BUILD CLEANUP ##" [[ ! -e $CI_BUILD_DIR && ! -e $CI_INSTALL_DIR ]] || { ci_spawn rm -fr "$CI_BUILD_DIR" ci_spawn rm -fr "$CI_INSTALL_DIR" } + [[ ! -e "$CI_SRC_DIR/config.status" ]] || { + ci_warn "unexpected build configuration file: '$CI_SRC_DIR/config.status'" + if ci_expr $((CI_FORCE)) + then + # Delete the old config and (possibly) the old build. + ci_info "note: forcing an in-tree build cleanup" + if [[ -f $CI_SRC_DIR/Makefile ]] + then + ci_spawn make -C "$CI_SRC_DIR" distclean + else + ci_spawn rm -fr "$CI_SRC_DIR"/config.{log,status} + fi + else + # Alert the user, but do not delete their files. + ci_warn "the configure script might fail" + ci_info "hint: consider using the option \$CI_FORCE=1" + fi + } ci_info "## END OF PRE-BUILD CLEANUP ##" } diff --git a/ci/ci_verify_makefiles.sh b/ci/ci_verify_makefiles.sh index 5b9217ad28..e0681b4d8c 100755 --- a/ci/ci_verify_makefiles.sh +++ b/ci/ci_verify_makefiles.sh @@ -50,6 +50,7 @@ function ci_trace_build { ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" ci_info "environment option: \$CI_LIBS: '$CI_LIBS'" ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_FORCE: '$CI_FORCE'" ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" @@ -79,13 +80,26 @@ function ci_cleanup_old_build { # Fortunately, for a clean makefiles-based build, it should be # sufficient to remove the old object files only. ci_info "## START OF PRE-BUILD CLEANUP ##" - local my_file - find "$CI_SRC_DIR" -maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \) | - while IFS="" read -r my_file - do - ci_spawn rm -fr "$my_file" - done - ci_info "## END OF PRE-BUILD CLEANUP ##" + local find_args=(-maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \)) + [[ ! $(find "$CI_SRC_DIR" "${find_args[@]}" | head -n1) ]] || { + ci_warn "unexpected build found in '$CI_SRC_DIR'" + if ci_expr $((CI_FORCE)) + then + # Delete the old build. + local my_file + find "$CI_SRC_DIR" "${find_args[@]}" | + while IFS="" read -r my_file + do + ci_spawn rm -fr "$my_file" + done + ci_info "## END OF PRE-BUILD CLEANUP ##" + else + # Alert the user, but do not delete their existing files, + # and do not mess up their existing build. + ci_info "hint: consider using the option \$CI_FORCE=1" + ci_err "unable to continue" + fi + } } function ci_build { diff --git a/ci/lib/ci.lib.sh b/ci/lib/ci.lib.sh index 813cc09c59..03e866b5c3 100644 --- a/ci/lib/ci.lib.sh +++ b/ci/lib/ci.lib.sh @@ -88,6 +88,9 @@ function ci_spawn { } # Ensure that the user initialization is correct. +[[ ${CI_FORCE:-0} == [01] ]] || { + ci_err "bad boolean option: \$CI_FORCE: '$CI_FORCE'" +} [[ ${CI_NO_TEST:-0} == [01] ]] || { ci_err "bad boolean option: \$CI_NO_TEST: '$CI_NO_TEST'" } From dddaf0c625a8daea4d027cb57380b7fac6f58285 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 17 Feb 2024 16:32:21 +0200 Subject: [PATCH 007/112] ci: Fix the reporting in ci_lint.sh The variable `CI_LINT_COUNTER` was incremented inside subshells, but remained unchanged in the main shell process. The errors detected by the internal linters remained unreported by the main script. (Oopsie!) Besides fixing this defect, considering that only a pass/fail status is needed, we are replacing `CI_LINT_COUNTER` with `CI_LINT_STATUS`. --- ci/ci_lint.sh | 54 +++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/ci/ci_lint.sh b/ci/ci_lint.sh index 2efe3714dd..bce220214e 100755 --- a/ci/ci_lint.sh +++ b/ci/ci_lint.sh @@ -17,8 +17,8 @@ CI_SHELLCHECK="${CI_SHELLCHECK:-shellcheck}" CI_EDITORCONFIG_CHECKER="${CI_EDITORCONFIG_CHECKER:-editorconfig-checker}" CI_YAMLLINT="${CI_YAMLLINT:-yamllint}" -# Initialize the global lint counter. -CI_LINT_COUNTER=0 +# Initialize the global lint status. +CI_LINT_STATUS=0 function ci_init_lint { ci_info "## START OF LINTING ##" @@ -45,14 +45,13 @@ function ci_init_lint { function ci_finish_lint { ci_info "## END OF LINTING ##" - if [[ $CI_LINT_COUNTER -eq 0 ]] + if [[ $CI_LINT_STATUS -eq 0 ]] then ci_info "## SUCCESS ##" - return 0 else ci_info "linting failed" - return 1 fi + return "$CI_LINT_STATUS" } function ci_lint_ci_scripts { @@ -61,15 +60,17 @@ function ci_lint_ci_scripts { return 0 } ci_info "## LINTING: CI scripts ##" - { + ci_spawn "$CI_SHELLCHECK" --version + find ./ci -name "*.sh" -perm +111 | { local my_file - ci_spawn "$CI_SHELLCHECK" --version - find ./ci -maxdepth 1 -name "*.sh" | - while IFS="" read -r my_file - do - ci_spawn "$CI_SHELLCHECK" -x "$my_file" - done - } || CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) + while IFS="" read -r my_file + do + ci_spawn "$CI_SHELLCHECK" -x "$my_file" || { + # Linting failed. + return 1 + } + done + } } function ci_lint_text_files { @@ -80,7 +81,8 @@ function ci_lint_text_files { ci_info "## LINTING: text files ##" ci_spawn "$CI_EDITORCONFIG_CHECKER" --version ci_spawn "$CI_EDITORCONFIG_CHECKER" || { - CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) + # Linting failed. + return 1 } } @@ -90,22 +92,24 @@ function ci_lint_yaml_files { return 0 } ci_info "## LINTING: YAML files ##" - { + ci_spawn "$CI_YAMLLINT" --version + find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" | { local my_file - ci_spawn "$CI_YAMLLINT" --version - find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" | - while IFS="" read -r my_file - do - ci_spawn "$CI_YAMLLINT" --strict "$my_file" - done - } || CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1)) + while IFS="" read -r my_file + do + ci_spawn "$CI_YAMLLINT" --strict "$my_file" || { + # Linting failed. + return 1 + } + done + } } function ci_lint { ci_init_lint - ci_lint_ci_scripts - ci_lint_text_files - ci_lint_yaml_files + ci_lint_ci_scripts || CI_LINT_STATUS=1 + ci_lint_text_files || CI_LINT_STATUS=1 + ci_lint_yaml_files || CI_LINT_STATUS=1 # TODO: ci_lint_png_files, etc. ci_finish_lint } From 6b5a2da07237d7fbe4a93d45c5b94c1e07ba8855 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 17 Feb 2024 18:26:27 +0200 Subject: [PATCH 008/112] Fix "ci: Fix the reporting in ci_lint.sh" This fixes commit dddaf0c625a8daea4d027cb57380b7fac6f58285. The way to reliably `find` executable files is different on BSD, Mac and Linux, unfortunately. --- ci/ci_lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/ci_lint.sh b/ci/ci_lint.sh index bce220214e..d1754715d2 100755 --- a/ci/ci_lint.sh +++ b/ci/ci_lint.sh @@ -61,7 +61,7 @@ function ci_lint_ci_scripts { } ci_info "## LINTING: CI scripts ##" ci_spawn "$CI_SHELLCHECK" --version - find ./ci -name "*.sh" -perm +111 | { + find ./ci -maxdepth 1 -name "*.sh" | { local my_file while IFS="" read -r my_file do From e7ba9c0dfc1446af9f1e118325ba1dd91b8d5851 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Mon, 19 Feb 2024 14:23:53 +1100 Subject: [PATCH 009/112] build: Fix a CMake build regression introduced in version 1.6.41 This fixes commit 4edbb4da81626a7342a22824d7a8f60a3ea71bd0. During the move of CMake scripts to the scripts/cmake/ subdirectory, some of the workflows have been broken. Signed-off-by: Cosmin Truta --- CMakeLists.txt | 14 +++++++------- scripts/cmake/AUTHORS.md | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bff18ff6e..112f05afe0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -386,7 +386,7 @@ else() COMMAND "${CMAKE_COMMAND}" "-DINPUT=${_GC_INPUT}" "-DOUTPUT=${_GC_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/genchk.cmake" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake" DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction() @@ -409,7 +409,7 @@ else() COMMAND "${CMAKE_COMMAND}" "-DINPUT=${_GO_INPUT}" "-DOUTPUT=${_GO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/genout.cmake" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake" DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction() @@ -428,7 +428,7 @@ else() add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" COMMAND "${CMAKE_COMMAND}" "-DOUTPUT=${_GSO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake" DEPENDS ${_GSO_DEPENDS} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction() @@ -558,7 +558,7 @@ else() add_custom_target(png_genprebuilt COMMAND "${CMAKE_COMMAND}" "-DOUTPUT=scripts/pnglibconf.h.prebuilt" - -P "${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") # A single target handles generation of all generated files. @@ -1002,13 +1002,13 @@ endfunction() # Create source generation scripts. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genchk.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/genchk.cmake + ${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genout.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/genout.cmake + ${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/gensrc.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake + ${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake @ONLY) # libpng is a library so default to 'lib' diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index 1c1173ab3f..bffdba60cd 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -14,6 +14,7 @@ Author List * Clifford Yapp * Clinton Ingram * Cosmin Truta + * Dan Rosser * David Callu * Gleb Mazovetskiy * Glenn Randers-Pehrson From aa95dee697d0d688795839695099c383b0ac39f6 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 19 Feb 2024 14:25:55 +0200 Subject: [PATCH 010/112] build: Update the CMake build options PNG_TOOLS and PNG_FRAMEWORK Update the PNG_TOOLS option: set it to OFF by default when the target is an embedded system, yet still allow it to be overridden. Update the PNG_FRAMEWORK option: force it back to OFF and print a warning if the option was ON but the target is not an Apple system. --- CMakeLists.txt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 112f05afe0..45bd2d5426 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,18 @@ if(APPLE) endif() # Allow the users to switch on/off the auxiliary build and test artifacts. -# NOTE: These artifacts are NOT part of libpng proper, and are subject to change at any time. +# These artifacts are NOT part of libpng proper, and are subject to change +# at any time. option(PNG_TESTS "Build the libpng tests" ON) -option(PNG_TOOLS "Build the libpng tools" ON) + +# Same as above, but for the third-party tools. +# Although these tools are targetted at development environments only, +# the users are allowed to override the option to build by default. +if (ANDROID OR IOS) + option(PNG_TOOLS "Build the libpng tools" OFF) +else() + option(PNG_TOOLS "Build the libpng tools" ON) +endif() # Maintain backwards compatibility with the deprecated option PNG_EXECUTABLES. option(PNG_EXECUTABLES "[Deprecated; please use PNG_TOOLS]" ON) @@ -719,7 +728,13 @@ if(PNG_STATIC) target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() -if(PNG_FRAMEWORK AND APPLE) +if(PNG_FRAMEWORK AND NOT APPLE) + message(AUTHOR_WARNING + "Setting PNG_FRAMEWORK to OFF, as it only applies to Apple systems") + set(PNG_FRAMEWORK OFF) +endif() + +if(PNG_FRAMEWORK) add_library(png_framework SHARED ${libpng_sources}) add_dependencies(png_framework png_genfiles) list(APPEND PNG_LIBRARY_TARGETS png_framework) From d165a20ae4804992a104ffc8fa8e897e8964fbe8 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 19 Feb 2024 20:51:26 +0200 Subject: [PATCH 011/112] build: Improve the search for an AWK processor in the CMake build Add nawk to the list of AWK-processing programs that are known to work, and show the search result in the CMake log. --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45bd2d5426..8ab735d83d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,7 +353,15 @@ int main(void) { return 0; } file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") endif() -find_program(AWK NAMES gawk awk) +# Find an AWK language processor. +# Start with specific AWK implementations like gawk and nawk, which are +# known to work with our scripts, then fall back to the system awk. +find_program(AWK NAMES gawk nawk awk) +if(AWK) + message(STATUS "Found AWK program: ${AWK}") +else() + message(STATUS "Could not find an AWK-compatible program") +endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}) From 29e31f622fd8880ad372994effdcf39ea1c606c9 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 20 Feb 2024 15:10:12 +0200 Subject: [PATCH 012/112] build: Add an explicit declaration of the AWK variable to configure.ac Declare AWK explicitly via the AC_ARG_VAR directive, in order to make it "precious", and to include it in the list of influential variables at the end of the configure help text. Rephrase a few comments and config traces. Finally, regenerate the configure script. --- configure | 22 +++++++++++++--------- configure.ac | 17 ++++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/configure b/configure index 7f3a0f8bc3..c2e08e7da1 100755 --- a/configure +++ b/configure @@ -867,6 +867,7 @@ CCAS CCASFLAGS CPP LT_SYS_LIBRARY_PATH +AWK PNG_COPTS' @@ -1613,7 +1614,8 @@ Some influential environment variables: CPP C preprocessor LT_SYS_LIBRARY_PATH User-defined run-time library search path. - PNG_COPTS additional flags for the C compiler, use this for options that + AWK AWK language processor + PNG_COPTS additional flags for the C compiler, to be used for options that would cause configure itself to fail Use these variables to override the choices made by 'configure' or to help @@ -3389,7 +3391,7 @@ PNGLIB_RELEASE=43 ac_config_headers="$ac_config_headers config.h" -# Checks for programs. +# Check for basic programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -13659,20 +13661,22 @@ CC=$lt_save_CC -# Some awks crash when confronted with pnglibconf.dfa, do a test run now -# to make sure this doesn't happen -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that AWK works" >&5 -printf %s "checking that AWK works... " >&6; } + + +# Some awk implementations crash when confronted with pnglibconf.dfa. +# Run a test now, to make sure this doesn't happen. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if awk ($AWK) works" >&5 +printf %s "checking if awk ($AWK) works... " >&6; } if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ ${srcdir}/pngusr.dfa 1>&2 then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -printf "%s\n" "ok" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} -as_fn_error 1 "failed +as_fn_error 1 "no See 'config.log' for more details" "$LINENO" 5; } fi diff --git a/configure.ac b/configure.ac index b9162e8d2b..137339ebd1 100644 --- a/configure.ac +++ b/configure.ac @@ -56,7 +56,7 @@ dnl End of version number stuff AC_CONFIG_SRCDIR([pngget.c]) AC_CONFIG_HEADERS([config.h]) -# Checks for programs. +# Check for basic programs. AC_LANG([C]) AC_PROG_CC AM_PROG_AS @@ -72,16 +72,19 @@ dnl compatible later version may be used LT_INIT([win32-dll]) LT_PREREQ([2.4.2]) -# Some awks crash when confronted with pnglibconf.dfa, do a test run now -# to make sure this doesn't happen -AC_MSG_CHECKING([that AWK works]) +dnl Declare the AWK variable. +AC_ARG_VAR(AWK, [AWK language processor]) + +# Some awk implementations crash when confronted with pnglibconf.dfa. +# Run a test now, to make sure this doesn't happen. +AC_MSG_CHECKING([if awk ($AWK) works]) if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ ${srcdir}/pngusr.dfa 1>&2 then - AC_MSG_RESULT([ok]) + AC_MSG_RESULT([yes]) else - AC_MSG_FAILURE([failed], 1) + AC_MSG_FAILURE([no], 1) fi # This is a remnant of the old cc -E validation, where it may have been @@ -111,7 +114,7 @@ AM_CONDITIONAL([ENABLE_TOOLS], # (it checks the compiler with a program that generates a warning). # Add the following option to deal with this: AC_ARG_VAR(PNG_COPTS, - [additional flags for the C compiler, use this for options that would] + [additional flags for the C compiler, to be used for options that would] [cause configure itself to fail]) AC_ARG_ENABLE(werror, AS_HELP_STRING([[[--enable-werror[=OPT]]]], From 14a348ddc839be9539a10e9085e76d3a6fdcb58b Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 20 Feb 2024 23:14:32 +0200 Subject: [PATCH 013/112] build: Checking for compiler support of LoongArch LSX should be guarded In the configure script, checking whether the LoongArch LSX intrinsics are supported by the compiler was done unconditionally, regardless of the targetted host platform. Compared to how we support the other SIMD platforms and compilers, this is rather unconventional. We are placing this check under the guard of its own platform, for the time being. A full solution, in line with the rest of the configure.ac patterns concering SIMD optimizations, is TODO. We also do an overall cleanup in the SIMD section of configure.ac, and, finally, we regenerate the configure script. --- configure | 231 +++++++++++++++++++++++++-------------------------- configure.ac | 208 +++++++++++++++++++++++----------------------- 2 files changed, 219 insertions(+), 220 deletions(-) diff --git a/configure b/configure index c2e08e7da1..263bb0e612 100755 --- a/configure +++ b/configure @@ -1544,36 +1544,36 @@ Optional Features: default - use --disable-unversioned-libpng-config to change this. --enable-hardware-optimizations - Enable hardware optimizations: =no/off, yes/on: + Enable hardware optimizations: =no/off, yes/on. --enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api, - yes/on: no/off: disable the optimizations; check: + yes/on. no/off: disable the optimizations; check: use internal checking code (deprecated and poorly supported); api: disable by default, enable by a call to png_set_option; yes/on: turn on unconditionally. If not specified: determined by the compiler. --enable-mips-msa Enable MIPS MSA optimizations: =no/off, check, api, - yes/on: no/off: disable the optimizations; check: + yes/on. no/off: disable the optimizations; check: use internal checking code (deprecated and poorly supported); api: disable by default, enable by a call to png_set_option; yes/on: turn on unconditionally. If not specified: determined by the compiler. --enable-mips-mmi Enable MIPS MMI optimizations: =no/off, check, api, - yes/on: no/off: disable the optimizations; check: + yes/on. no/off: disable the optimizations; check: use internal checking code (deprecated and poorly supported); api: disable by default, enable by a call to png_set_option; yes/on: turn on unconditionally. If not specified: determined by the compiler. - --enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on: + --enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on. no/off: disable the optimizations; yes/on: enable the optimizations. If not specified: determined by the compiler. --enable-powerpc-vsx Enable POWERPC VSX optimizations: =no/off, check, - api, yes/on: no/off: disable the optimizations; - check: use internal checking code api: disable by - default, enable by a call to png_set_option yes/on: + api, yes/on. no/off: disable the optimizations; + check: use internal checking code; api: disable by + default, enable by a call to png_set_option; yes/on: turn on unconditionally. If not specified: determined by the compiler. --enable-loongarch-lsx @@ -14227,9 +14227,9 @@ if test "$have_ld_version_script" = "yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for symbol prefix" >&5 printf %s "checking for symbol prefix... " >&6; } SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ - | ${CPP-${CC-gcc} -E} - 2>&1 \ - | ${EGREP-grep} "^PREFIX=" \ - | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` + | ${CPP:-${CC:-gcc} -E} - 2>&1 \ + | ${EGREP:-grep} "^PREFIX=" \ + | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SYMBOL_PREFIX" >&5 printf "%s\n" "$SYMBOL_PREFIX" >&6; } @@ -14429,10 +14429,8 @@ printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h fi -# ARM -# === -# -# ARM NEON (SIMD) support. +# ARM NEON +# ======== # Check whether --enable-arm-neon was given. if test ${enable_arm_neon+y} @@ -14457,21 +14455,22 @@ printf "%s\n" "#define PNG_ARM_NEON_API_SUPPORTED /**/" >>confdefs.h printf "%s\n" "#define PNG_ARM_NEON_OPT 2" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-arm-neon: please specify 'check' or 'api', if - you want the optimizations unconditionally pass -mfpu=neon - to the compiler." >&5 -printf "%s\n" "$as_me: WARNING: --enable-arm-neon: please specify 'check' or 'api', if - you want the optimizations unconditionally pass -mfpu=neon - to the compiler." >&2;};; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-arm-neon: please specify 'check' or 'api'; + if you want the optimizations unconditionally, + pass '-mfpu=neon' to the compiler." >&5 +printf "%s\n" "$as_me: WARNING: --enable-arm-neon: please specify 'check' or 'api'; + if you want the optimizations unconditionally, + pass '-mfpu=neon' to the compiler." >&2;};; *) - as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: invalid value" "$LINENO" 5 + as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: + invalid argument" "$LINENO" 5 esac fi # Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or -# where ARM optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'arm*') +# where ARM optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'arm*'.) if test "$enable_arm_neon" != 'no' && case "$host_cpu" in @@ -14486,10 +14485,8 @@ else fi -# MIPS -# ==== -# -# MIPS MSA (SIMD) support. +# MIPS MSA +# ======== # Check whether --enable-mips-msa was given. if test ${enable_mips_msa+y} @@ -14514,21 +14511,22 @@ printf "%s\n" "#define PNG_MIPS_MSA_API_SUPPORTED /**/" >>confdefs.h printf "%s\n" "#define PNG_MIPS_MSA_OPT 2" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api', if - you want the optimizations unconditionally pass '-mmsa -mfp64' - to the compiler." >&5 -printf "%s\n" "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api', if - you want the optimizations unconditionally pass '-mmsa -mfp64' - to the compiler." >&2;};; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api'; + if you want the optimizations unconditionally, + pass '-mmsa -mfp64' to the compiler." >&5 +printf "%s\n" "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api'; + if you want the optimizations unconditionally, + pass '-mmsa -mfp64' to the compiler." >&2;};; *) - as_fn_error $? "--enable-mips-msa=${enable_mips_msa}: invalid value" "$LINENO" 5 + as_fn_error $? "--enable-mips-msa=${enable_mips_msa}: + invalid argument" "$LINENO" 5 esac fi # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or -# where MIPS optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'mips*') +# where MIPS optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'mips*'.) if test "$enable_mips_msa" != 'no' && case "$host_cpu" in @@ -14542,10 +14540,8 @@ else fi -# MIPS -# === -# -# MIPS MMI (SIMD) support. +# MIPS MMI +# ======== # Check whether --enable-mips-mmi was given. if test ${enable_mips_mmi+y} @@ -14570,25 +14566,26 @@ printf "%s\n" "#define PNG_MIPS_MMI_API_SUPPORTED /**/" >>confdefs.h printf "%s\n" "#define PNG_MIPS_MMI_OPT 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-mmi: please specify 'check' or 'api', if - you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a' - to the compiler." >&5 -printf "%s\n" "$as_me: WARNING: --enable-mips-mmi: please specify 'check' or 'api', if - you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a' - to the compiler." >&2;};; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-mmi: please specify 'check' or 'api'; + if you want the optimizations unconditionally + pass '-mloongson-mmi -march=loongson3a' to the compiler." >&5 +printf "%s\n" "$as_me: WARNING: --enable-mips-mmi: please specify 'check' or 'api'; + if you want the optimizations unconditionally + pass '-mloongson-mmi -march=loongson3a' to the compiler." >&2;};; *) - as_fn_error $? "--enable-mips-mmi=${enable_mips_mmi}: invalid value" "$LINENO" 5 + as_fn_error $? "--enable-mips-mmi=${enable_mips_mmi}: + invalid argument" "$LINENO" 5 esac fi # Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or -# where MIPS optimizations were explicitly requested (this allows a fallback if a -# future host CPU does not match 'mips*') +# where MIPS optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'mips*'.) if test "$enable_mips_mmi" != 'no' && case "$host_cpu" in - mipsel*|mips64el*) :;; + mipsel*|mips64el*) : ;; esac; then PNG_MIPS_MMI_TRUE= PNG_MIPS_MMI_FALSE='#' @@ -14598,10 +14595,8 @@ else fi -# INTEL -# ===== -# -# INTEL SSE (SIMD) support. +# INTEL SSE +# ========= # Check whether --enable-intel-sse was given. if test ${enable_intel_sse+y} @@ -14619,14 +14614,15 @@ printf "%s\n" "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h printf "%s\n" "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h ;; *) - as_fn_error $? "--enable-intel-sse=${enable_intel_sse}: invalid value" "$LINENO" 5 + as_fn_error $? "--enable-intel-sse=${enable_intel_sse}: + invalid argument" "$LINENO" 5 esac fi # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or -# where Intel optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'x86*') +# where Intel optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'x86*'.) if test "$enable_intel_sse" != 'no' && case "$host_cpu" in i?86|x86_64) : ;; @@ -14640,10 +14636,8 @@ else fi -# PowerPC -# ======= -# -# PowerPC VSX (SIMD) support. +# POWERPC VSX +# =========== # Check whether --enable-powerpc-vsx was given. if test ${enable_powerpc_vsx+y} @@ -14660,10 +14654,10 @@ printf "%s\n" "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h printf "%s\n" "#define PNG_POWERPC_VSX_CHECK_SUPPORTED /**/" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file - for the list of supported OSes." >&5 -printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file - for the list of supported OSes." >&2;};; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please see contrib/powerpc/README + for the list of supported systems." >&5 +printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx: please see contrib/powerpc/README + for the list of supported systems." >&2;};; api) printf "%s\n" "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h @@ -14672,21 +14666,22 @@ printf "%s\n" "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h printf "%s\n" "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if - you want the optimizations unconditionally pass '-maltivec -mvsx' - or '-mcpu=power8' to the compiler." >&5 -printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if - you want the optimizations unconditionally pass '-maltivec -mvsx' - or '-mcpu=power8' to the compiler." >&2;};; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api'; + if you want the optimizations unconditionally, + pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler." >&5 +printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api'; + if you want the optimizations unconditionally, + pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler." >&2;};; *) - as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value" "$LINENO" 5 + as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}: + invalid argument" "$LINENO" 5 esac fi -# Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*') -# or where PowerPC optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'powerpc*') +# Add PowerPC-specific files to all builds where $host_cpu is powerpc +# ('powerpc*') or where PowerPC optimizations were explicitly requested. +# (This allows a fallback if a future host CPU does not match 'powerpc*'.) if test "$enable_powerpc_vsx" != 'no' && case "$host_cpu" in @@ -14700,38 +14695,8 @@ else fi -# LOONGARCH -# === -# -# LOONGARCH LSX (SIMD) support - -if test "$LSX_CFLAGS" = ''; then - LSX_CFLAGS="-mlsx" -fi - -compiler_support_loongarch_lsx=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use loongarch LSX intrinsics" >&5 -printf %s "checking whether to use loongarch LSX intrinsics... " >&6; } -save_CFLAGS=$CFLAGS -CFLAGS="$CFLAGS $LSX_CFLAGS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -int main(){ - __m128i a, b, c; - a = __lsx_vadd_w(b, c); - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - compiler_support_loongarch_lsx=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -CFLAGS=$save_CFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $compiler_support_loongarch_lsx" >&5 -printf "%s\n" "$compiler_support_loongarch_lsx" >&6; } +# LOONGARCH LSX +# ============= # Check whether --enable-loongarch-lsx was given. if test ${enable_loongarch_lsx+y} @@ -14750,13 +14715,44 @@ printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h ;; *) - as_fn_error $? "--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value" "$LINENO" 5 + as_fn_error $? "--enable-loongarch-lsx=${enable_loongarch_lsx}: + invalid argument" "$LINENO" 5 esac fi -if test "$enable_loongarch_lsx" != 'no'; then - if test $compiler_support_loongarch_lsx = yes; then +# FIXME: This section should not be needed. +if test "$enable_loongarch_lsx" != "no" && + case "$host_cpu" in + loongarch*) : ;; + *) test "$enable_loongarch_lsx" != '' ;; + esac +then + compiler_support_loongarch_lsx=no + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use LoongArch LSX intrinsics" >&5 +printf %s "checking whether to use LoongArch LSX intrinsics... " >&6; } + save_CFLAGS="$CFLAGS" + LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}" + CFLAGS="$CFLAGS $LSX_CFLAGS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +int main(){ + __m128i a, b, c; + a = __lsx_vadd_w(b, c); + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + compiler_support_loongarch_lsx=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS="$save_CFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $compiler_support_loongarch_lsx" >&5 +printf "%s\n" "$compiler_support_loongarch_lsx" >&6; } + if test "$compiler_support_loongarch_lsx" = "yes"; then printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h @@ -14766,14 +14762,15 @@ printf "%s\n" "$as_me: WARNING: Compiler does not support loongarch LSX." >&2;} fi fi -# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or -# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a -# future host CPU does not match 'loongarch*') +# Add LoongArch specific files to all builds where the host_cpu is loongarch +# ('loongarch*') or where LoongArch optimizations were explicitly requested. +# (This allows a fallback if a future host CPU does not match 'loongarch*'.) - if test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes && + if test "$enable_loongarch_lsx" != "no" && + test "$compiler_support_loongarch_lsx" = "yes" && case "$host_cpu" in - loongarch*) :;; - *) test "$enable_loongarch_lsx" != '';; + loongarch*) : ;; + *) test "$enable_loongarch_lsx" != '' ;; esac; then PNG_LOONGARCH_LSX_TRUE= PNG_LOONGARCH_LSX_FALSE='#' diff --git a/configure.ac b/configure.ac index 137339ebd1..21f0b14fed 100644 --- a/configure.ac +++ b/configure.ac @@ -226,9 +226,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") if test "$have_ld_version_script" = "yes"; then AC_MSG_CHECKING([for symbol prefix]) SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ - | ${CPP-${CC-gcc} -E} - 2>&1 \ - | ${EGREP-grep} "^PREFIX=" \ - | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` + | ${CPP:-${CC:-gcc} -E} - 2>&1 \ + | ${EGREP:-grep} "^PREFIX=" \ + | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` AC_SUBST(SYMBOL_PREFIX) AC_MSG_RESULT($SYMBOL_PREFIX) fi @@ -321,7 +321,7 @@ AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG], # AC_ARG_ENABLE([hardware-optimizations], AS_HELP_STRING([[[--enable-hardware-optimizations]]], - [Enable hardware optimizations: =no/off, yes/on:]), + [Enable hardware optimizations: =no/off, yes/on.]), [case "$enableval" in no|off) # disable hardware optimization on all systems: @@ -379,17 +379,16 @@ AC_ARG_ENABLE([hardware-optimizations], ;; esac]) -# ARM -# === -# -# ARM NEON (SIMD) support. +# ARM NEON +# ======== AC_ARG_ENABLE([arm-neon], AS_HELP_STRING([[[--enable-arm-neon]]], - [Enable ARM NEON optimizations: =no/off, check, api, yes/on:] - [no/off: disable the optimizations; check: use internal checking code] - [(deprecated and poorly supported); api: disable by default, enable by] - [a call to png_set_option; yes/on: turn on unconditionally.] + [Enable ARM NEON optimizations: =no/off, check, api, yes/on.] + [no/off: disable the optimizations;] + [check: use internal checking code (deprecated and poorly supported);] + [api: disable by default, enable by a call to png_set_option;] + [yes/on: turn on unconditionally.] [If not specified: determined by the compiler.]), [case "$enableval" in no|off) @@ -407,16 +406,17 @@ AC_ARG_ENABLE([arm-neon], yes|on) AC_DEFINE([PNG_ARM_NEON_OPT], [2], [Enable ARM Neon optimizations]) - AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if] - [you want the optimizations unconditionally pass -mfpu=neon] - [to the compiler.]);; + AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';] + [if you want the optimizations unconditionally,] + [pass '-mfpu=neon' to the compiler.]);; *) - AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value]) + AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:] + [invalid argument]) esac]) # Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or -# where ARM optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'arm*') +# where ARM optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'arm*'.) AM_CONDITIONAL([PNG_ARM_NEON], [test "$enable_arm_neon" != 'no' && @@ -425,17 +425,16 @@ AM_CONDITIONAL([PNG_ARM_NEON], *) test "$enable_arm_neon" != '' ;; esac]) -# MIPS -# ==== -# -# MIPS MSA (SIMD) support. +# MIPS MSA +# ======== AC_ARG_ENABLE([mips-msa], AS_HELP_STRING([[[--enable-mips-msa]]], - [Enable MIPS MSA optimizations: =no/off, check, api, yes/on:] - [no/off: disable the optimizations; check: use internal checking code] - [(deprecated and poorly supported); api: disable by default, enable by] - [a call to png_set_option; yes/on: turn on unconditionally.] + [Enable MIPS MSA optimizations: =no/off, check, api, yes/on.] + [no/off: disable the optimizations;] + [check: use internal checking code (deprecated and poorly supported);] + [api: disable by default, enable by a call to png_set_option;] + [yes/on: turn on unconditionally.] [If not specified: determined by the compiler.]), [case "$enableval" in no|off) @@ -453,16 +452,17 @@ AC_ARG_ENABLE([mips-msa], yes|on) AC_DEFINE([PNG_MIPS_MSA_OPT], [2], [Enable MIPS MSA optimizations]) - AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if] - [you want the optimizations unconditionally pass '-mmsa -mfp64'] - [to the compiler.]);; + AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api';] + [if you want the optimizations unconditionally,] + [pass '-mmsa -mfp64' to the compiler.]);; *) - AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value]) + AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:] + [invalid argument]) esac]) # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or -# where MIPS optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'mips*') +# where MIPS optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'mips*'.) AM_CONDITIONAL([PNG_MIPS_MSA], [test "$enable_mips_msa" != 'no' && @@ -470,17 +470,16 @@ AM_CONDITIONAL([PNG_MIPS_MSA], mipsel*|mips64el*) : ;; esac]) -# MIPS -# === -# -# MIPS MMI (SIMD) support. +# MIPS MMI +# ======== AC_ARG_ENABLE([mips-mmi], AS_HELP_STRING([[[--enable-mips-mmi]]], - [Enable MIPS MMI optimizations: =no/off, check, api, yes/on:] - [no/off: disable the optimizations; check: use internal checking code] - [(deprecated and poorly supported); api: disable by default, enable by] - [a call to png_set_option; yes/on: turn on unconditionally.] + [Enable MIPS MMI optimizations: =no/off, check, api, yes/on.] + [no/off: disable the optimizations;] + [check: use internal checking code (deprecated and poorly supported);] + [api: disable by default, enable by a call to png_set_option;] + [yes/on: turn on unconditionally.] [If not specified: determined by the compiler.]), [case "$enableval" in no|off) @@ -498,31 +497,30 @@ AC_ARG_ENABLE([mips-mmi], yes|on) AC_DEFINE([PNG_MIPS_MMI_OPT], [1], [Enable MIPS MMI optimizations]) - AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api', if] - [you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a'] - [to the compiler.]);; + AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api';] + [if you want the optimizations unconditionally] + [pass '-mloongson-mmi -march=loongson3a' to the compiler.]);; *) - AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}: invalid value]) + AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}:] + [invalid argument]) esac]) # Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or -# where MIPS optimizations were explicitly requested (this allows a fallback if a -# future host CPU does not match 'mips*') +# where MIPS optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'mips*'.) AM_CONDITIONAL([PNG_MIPS_MMI], [test "$enable_mips_mmi" != 'no' && case "$host_cpu" in - mipsel*|mips64el*) :;; + mipsel*|mips64el*) : ;; esac]) -# INTEL -# ===== -# -# INTEL SSE (SIMD) support. +# INTEL SSE +# ========= AC_ARG_ENABLE([intel-sse], AS_HELP_STRING([[[--enable-intel-sse]]], - [Enable Intel SSE optimizations: =no/off, yes/on:] + [Enable Intel SSE optimizations: =no/off, yes/on.] [no/off: disable the optimizations;] [yes/on: enable the optimizations.] [If not specified: determined by the compiler.]), @@ -537,12 +535,13 @@ AC_ARG_ENABLE([intel-sse], AC_DEFINE([PNG_INTEL_SSE_OPT], [1], [Enable Intel SSE optimizations]);; *) - AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value]) + AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:] + [invalid argument]) esac]) # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or -# where Intel optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'x86*') +# where Intel optimizations were explicitly requested. (This allows a fallback +# if a future host CPU does not match 'x86*'.) AM_CONDITIONAL([PNG_INTEL_SSE], [test "$enable_intel_sse" != 'no' && case "$host_cpu" in @@ -550,16 +549,15 @@ AM_CONDITIONAL([PNG_INTEL_SSE], *) test "$enable_intel_sse" != '' ;; esac]) -# PowerPC -# ======= -# -# PowerPC VSX (SIMD) support. +# POWERPC VSX +# =========== AC_ARG_ENABLE([powerpc-vsx], AS_HELP_STRING([[[--enable-powerpc-vsx]]], - [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:] - [no/off: disable the optimizations; check: use internal checking code] - [api: disable by default, enable by a call to png_set_option] + [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on.] + [no/off: disable the optimizations;] + [check: use internal checking code;] + [api: disable by default, enable by a call to png_set_option;] [yes/on: turn on unconditionally.] [If not specified: determined by the compiler.]), [case "$enableval" in @@ -572,24 +570,25 @@ AS_HELP_STRING([[[--enable-powerpc-vsx]]], check) AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [], [Check for POWERPC VSX support at run-time]) - AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file] - [for the list of supported OSes.]);; + AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README] + [for the list of supported systems.]);; api) AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [], [Turn on POWERPC VSX optimizations at run-time]);; yes|on) AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], [Enable POWERPC VSX optimizations]) - AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if] - [you want the optimizations unconditionally pass '-maltivec -mvsx'] - [or '-mcpu=power8' to the compiler.]);; + AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api';] + [if you want the optimizations unconditionally,] + [pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler.]);; *) - AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value]) + AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:] + [invalid argument]) esac]) -# Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*') -# or where PowerPC optimizations were explicitly requested (this allows a fallback -# if a future host CPU does not match 'powerpc*') +# Add PowerPC-specific files to all builds where $host_cpu is powerpc +# ('powerpc*') or where PowerPC optimizations were explicitly requested. +# (This allows a fallback if a future host CPU does not match 'powerpc*'.) AM_CONDITIONAL([PNG_POWERPC_VSX], [test "$enable_powerpc_vsx" != 'no' && @@ -597,28 +596,8 @@ AM_CONDITIONAL([PNG_POWERPC_VSX], powerpc*|ppc64*) : ;; esac]) -# LOONGARCH -# === -# -# LOONGARCH LSX (SIMD) support - -if test "$LSX_CFLAGS" = ''; then - LSX_CFLAGS="-mlsx" -fi - -compiler_support_loongarch_lsx=no -AC_MSG_CHECKING(whether to use loongarch LSX intrinsics) -save_CFLAGS=$CFLAGS -CFLAGS="$CFLAGS $LSX_CFLAGS" -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#include -int main(){ - __m128i a, b, c; - a = __lsx_vadd_w(b, c); - return 0; -}]])],compiler_support_loongarch_lsx=yes) -CFLAGS=$save_CFLAGS -AC_MSG_RESULT($compiler_support_loongarch_lsx) +# LOONGARCH LSX +# ============= AC_ARG_ENABLE([loongarch-lsx], AS_HELP_STRING([[[--enable-loongarch-lsx]]], @@ -638,26 +617,49 @@ AC_ARG_ENABLE([loongarch-lsx], [Enable LOONGARCH LSX optimizations]) ;; *) - AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value]) + AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}:] + [invalid argument]) esac]) -if test "$enable_loongarch_lsx" != 'no'; then - if test $compiler_support_loongarch_lsx = yes; then - AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], [Enable LOONGARCH LSX optimizations]) +# FIXME: This section should not be needed. +if test "$enable_loongarch_lsx" != "no" && + case "$host_cpu" in + loongarch*) : ;; + *) test "$enable_loongarch_lsx" != '' ;; + esac +then + compiler_support_loongarch_lsx=no + AC_MSG_CHECKING(whether to use LoongArch LSX intrinsics) + save_CFLAGS="$CFLAGS" + LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}" + CFLAGS="$CFLAGS $LSX_CFLAGS" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#include +int main(){ + __m128i a, b, c; + a = __lsx_vadd_w(b, c); + return 0; +}]])],compiler_support_loongarch_lsx=yes) + CFLAGS="$save_CFLAGS" + AC_MSG_RESULT($compiler_support_loongarch_lsx) + if test "$compiler_support_loongarch_lsx" = "yes"; then + AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], + [Enable LOONGARCH LSX optimizations]) else AC_MSG_WARN([Compiler does not support loongarch LSX.]) fi fi -# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or -# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a -# future host CPU does not match 'loongarch*') +# Add LoongArch specific files to all builds where the host_cpu is loongarch +# ('loongarch*') or where LoongArch optimizations were explicitly requested. +# (This allows a fallback if a future host CPU does not match 'loongarch*'.) AM_CONDITIONAL([PNG_LOONGARCH_LSX], - [test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes && + [test "$enable_loongarch_lsx" != "no" && + test "$compiler_support_loongarch_lsx" = "yes" && case "$host_cpu" in - loongarch*) :;; - *) test "$enable_loongarch_lsx" != '';; + loongarch*) : ;; + *) test "$enable_loongarch_lsx" != '' ;; esac]) AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) From 7b888092b9f5d249e7baa7bd43ee14f560cd0ae1 Mon Sep 17 00:00:00 2001 From: Benjamin Buch Date: Wed, 21 Feb 2024 19:06:33 +0100 Subject: [PATCH 014/112] build: Mark the installed libpng headers as system headers in CMake Modern compilers can disable the warnings that originate from system headers. This change allows them to do so with the libpng headers. Signed-off-by: Cosmin Truta --- CMakeLists.txt | 21 +++++++++------------ scripts/cmake/AUTHORS.md | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ab735d83d..fca2bb83fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -714,10 +714,9 @@ if(PNG_SHARED) set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) endif() target_include_directories(png_shared - PUBLIC - $ - $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + PUBLIC $) + target_include_directories(png_shared SYSTEM + INTERFACE $) target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() @@ -729,10 +728,9 @@ if(PNG_STATIC) OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}" DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_include_directories(png_static - PUBLIC - $ - $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + PUBLIC $) + target_include_directories(png_static SYSTEM + INTERFACE $) target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() @@ -759,10 +757,9 @@ if(PNG_FRAMEWORK) # Avoid CMake's implicit compile definition "-Dpng_framework_EXPORTS". set_target_properties(png_framework PROPERTIES DEFINE_SYMBOL "") target_include_directories(png_framework - PUBLIC - $ - $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + PUBLIC $) + target_include_directories(png_framework SYSTEM + INTERFACE $) target_link_libraries(png_framework PUBLIC ZLIB::ZLIB ${M_LIBRARY}) endif() diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index bffdba60cd..fe423fe778 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -7,6 +7,7 @@ Author List * Alex Gaynor * Andreas Franek * B. Scott Michel + * Benjamin Buch * Cameron Cawley * Christian Ehrlicher * Christopher Sean Morrison From ec2e58c16aeecbb9a556e305b2f62e5da88e1f4d Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 22 Feb 2024 11:32:53 +0200 Subject: [PATCH 015/112] pngexif: Import pngexifinfo as an externally-contributed project We used this experimental project in the development of the PNG-EXIF ("eXIf") specification, back in 2017. The project evolved together with the draft specification, which was finalized on 2017-Jun-15 and approved by the PNG Group on 2017-Jul-13. The EXIF specification, outside of the scope of PNG and libpng, is quite complex. The libpng implementation cannot grow too much beyond performing basic integrity checks on top of serialization. In order to create and manipulate PNG-EXIF image files, the use of external libraries and tools such as ExifTool is necessary. Now, with the addition of contrib/pngexif to the libpng repository, offline tasks like metadata inspection and linting can be performed without importing external dependencies. --- contrib/pngexif/.editorconfig | 11 ++ contrib/pngexif/.gitignore | 3 + contrib/pngexif/.pylintrc | 8 + contrib/pngexif/LICENSE_MIT.txt | 19 ++ contrib/pngexif/README.md | 20 +++ contrib/pngexif/bytepack.py | 48 +++++ contrib/pngexif/exifinfo.py | 306 ++++++++++++++++++++++++++++++++ contrib/pngexif/pngexifinfo | 10 ++ contrib/pngexif/pngexifinfo.bat | 4 + contrib/pngexif/pngexifinfo.py | 178 +++++++++++++++++++ 10 files changed, 607 insertions(+) create mode 100644 contrib/pngexif/.editorconfig create mode 100644 contrib/pngexif/.gitignore create mode 100644 contrib/pngexif/.pylintrc create mode 100644 contrib/pngexif/LICENSE_MIT.txt create mode 100644 contrib/pngexif/README.md create mode 100755 contrib/pngexif/bytepack.py create mode 100755 contrib/pngexif/exifinfo.py create mode 100755 contrib/pngexif/pngexifinfo create mode 100644 contrib/pngexif/pngexifinfo.bat create mode 100755 contrib/pngexif/pngexifinfo.py diff --git a/contrib/pngexif/.editorconfig b/contrib/pngexif/.editorconfig new file mode 100644 index 0000000000..ce8fbbfc1b --- /dev/null +++ b/contrib/pngexif/.editorconfig @@ -0,0 +1,11 @@ +# https://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +insert_final_newline = true +max_doc_length = 79 +max_line_length = 79 +trim_trailing_whitespace = true diff --git a/contrib/pngexif/.gitignore b/contrib/pngexif/.gitignore new file mode 100644 index 0000000000..016f70a803 --- /dev/null +++ b/contrib/pngexif/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +*.py[co] +*$py.class diff --git a/contrib/pngexif/.pylintrc b/contrib/pngexif/.pylintrc new file mode 100644 index 0000000000..50cf1152da --- /dev/null +++ b/contrib/pngexif/.pylintrc @@ -0,0 +1,8 @@ +[COMPATIBILITY] +disable=consider-using-f-string + +[COMPLEXITY] +disable=too-many-branches,too-many-instance-attributes + +[STYLE] +disable=consider-using-in diff --git a/contrib/pngexif/LICENSE_MIT.txt b/contrib/pngexif/LICENSE_MIT.txt new file mode 100644 index 0000000000..9cf106272a --- /dev/null +++ b/contrib/pngexif/LICENSE_MIT.txt @@ -0,0 +1,19 @@ +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/contrib/pngexif/README.md b/contrib/pngexif/README.md new file mode 100644 index 0000000000..c9ff88b647 --- /dev/null +++ b/contrib/pngexif/README.md @@ -0,0 +1,20 @@ +pngexifinfo +=========== + +Show the EXIF information embedded in a PNG file. + + +Sample usage +------------ + +Show the EXIF info inside a PNG file: + + pngexifinfo /path/to/file.png + +Show the EXIF info inside a raw `.exif` file, using base 16 for the EXIF tags: + + pngexifinfo --hex /path/to/file.exif + +Show the help text: + + pngexifinfo --help diff --git a/contrib/pngexif/bytepack.py b/contrib/pngexif/bytepack.py new file mode 100755 index 0000000000..93af21994a --- /dev/null +++ b/contrib/pngexif/bytepack.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +""" +Byte packing and unpacking utilities. + +Copyright (C) 2017-2020 Cosmin Truta. + +Use, modification and distribution are subject to the MIT License. +Please see the accompanying file LICENSE_MIT.txt +""" + +from __future__ import absolute_import, division, print_function + +import struct + + +def unpack_uint32be(buffer, offset=0): + """Unpack an unsigned int from its 32-bit big-endian representation.""" + return struct.unpack(">I", buffer[offset:offset + 4])[0] + + +def unpack_uint32le(buffer, offset=0): + """Unpack an unsigned int from its 32-bit little-endian representation.""" + return struct.unpack("H", buffer[offset:offset + 2])[0] + + +def unpack_uint16le(buffer, offset=0): + """Unpack an unsigned int from its 16-bit little-endian representation.""" + return struct.unpack(" "ascii" + value_or_offset >>= 24 + elif tag_type == 3: + # 3 --> "short" + value_or_offset >>= 16 + else: + # ... FIXME + pass + if count == 0: + raise RuntimeError("unsupported count=0 in tag 0x%x" % tag_id) + if tag_id == _TIFF_EXIF_IFD: + if tag_type != 4: + raise RuntimeError("incorrect tag type for EXIF IFD") + self._exif_ifd_offset = value_or_offset + elif tag_id == _GPS_IFD: + if tag_type != 4: + raise RuntimeError("incorrect tag type for GPS IFD") + self._gps_ifd_offset = value_or_offset + elif tag_id == _INTEROPERABILITY_IFD: + if tag_type != 4: + raise RuntimeError("incorrect tag type for Interop IFD") + self._interoperability_ifd_offset = value_or_offset + yield (tag_id, tag_type, count, value_or_offset) + + def tags(self): + """Yield all TIFF/EXIF tags.""" + if self._verbose: + print("TIFF IFD : 0x%08x" % self._global_ifd_offset) + for tag in self._tags_for_ifd(self._global_ifd_offset): + yield tag + if self._exif_ifd_offset > 0: + if self._verbose: + print("EXIF IFD : 0x%08x" % self._exif_ifd_offset) + for tag in self._tags_for_ifd(self._exif_ifd_offset): + yield tag + if self._gps_ifd_offset > 0: + if self._verbose: + print("GPS IFD : 0x%08x" % self._gps_ifd_offset) + for tag in self._tags_for_ifd(self._gps_ifd_offset): + yield tag + if self._interoperability_ifd_offset > 0: + if self._verbose: + print("Interoperability IFD : 0x%08x" % + self._interoperability_ifd_offset) + for tag in self._tags_for_ifd(self._interoperability_ifd_offset): + yield tag + + def tagid2str(self, tag_id): + """Return an informative string representation of a TIFF tag id.""" + idstr = _TIFF_TAGS.get(tag_id, "[Unknown]") + if self._hex: + idnum = "0x%04x" % tag_id + else: + idnum = "%d" % tag_id + return "%s (%s)" % (idstr, idnum) + + @staticmethod + def tagtype2str(tag_type): + """Return an informative string representation of a TIFF tag type.""" + typestr = _TIFF_TAG_TYPES.get(tag_type, "[unknown]") + return "%d:%s" % (tag_type, typestr) + + def tag2str(self, tag_id, tag_type, count, value_or_offset): + """Return an informative string representation of a TIFF tag tuple.""" + return "%s (type=%s) (count=%d) : 0x%08x" \ + % (self.tagid2str(tag_id), self.tagtype2str(tag_type), count, + value_or_offset) + + def _ui32(self): + """Decode a 32-bit unsigned int found at the current offset; + advance the offset by 4. + """ + if self._offset + 4 > len(self._buffer): + raise RuntimeError("out-of-bounds uint32 access in EXIF") + if self._endian == "MM": + result = unpack_uint32be(self._buffer, self._offset) + else: + result = unpack_uint32le(self._buffer, self._offset) + self._offset += 4 + return result + + def _ui16(self): + """Decode a 16-bit unsigned int found at the current offset; + advance the offset by 2. + """ + if self._offset + 2 > len(self._buffer): + raise RuntimeError("out-of-bounds uint16 access in EXIF") + if self._endian == "MM": + result = unpack_uint16be(self._buffer, self._offset) + else: + result = unpack_uint16le(self._buffer, self._offset) + self._offset += 2 + return result + + def _ui8(self): + """Decode an 8-bit unsigned int found at the current offset; + advance the offset by 1. + """ + if self._offset + 1 > len(self._buffer): + raise RuntimeError("out-of-bounds uint8 access in EXIF") + result = unpack_uint8(self._buffer, self._offset) + self._offset += 1 + return result + + +def print_raw_exif_info(buffer, **kwargs): + """Print the EXIF information found in a raw byte stream.""" + lister = ExifInfo(buffer, **kwargs) + print("EXIF (endian=%s)" % lister.endian()) + for (tag_id, tag_type, count, value_or_offset) in lister.tags(): + print(lister.tag2str(tag_id=tag_id, + tag_type=tag_type, + count=count, + value_or_offset=value_or_offset)) + + +if __name__ == "__main__": + # For testing only. + for arg in sys.argv[1:]: + with open(arg, "rb") as test_stream: + test_buffer = test_stream.read(_READ_DATA_SIZE_MAX) + print_raw_exif_info(test_buffer, hex=True, verbose=True) diff --git a/contrib/pngexif/pngexifinfo b/contrib/pngexif/pngexifinfo new file mode 100755 index 0000000000..16f8eaab14 --- /dev/null +++ b/contrib/pngexif/pngexifinfo @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +my_python="$(command -v python3 || command -v python)" || { + echo >&2 "error: program not found: Python interpreter" + exit 127 +} +my_python_flags="-BES" + +exec "$my_python" "$my_python_flags" "$(dirname "$0")/pngexifinfo.py" "$@" diff --git a/contrib/pngexif/pngexifinfo.bat b/contrib/pngexif/pngexifinfo.bat new file mode 100644 index 0000000000..ab8bd358cc --- /dev/null +++ b/contrib/pngexif/pngexifinfo.bat @@ -0,0 +1,4 @@ +@echo off +@setlocal enableextensions + +python.exe -BES %~dp0.\pngexifinfo.py %* diff --git a/contrib/pngexif/pngexifinfo.py b/contrib/pngexif/pngexifinfo.py new file mode 100755 index 0000000000..37d4c4bcd8 --- /dev/null +++ b/contrib/pngexif/pngexifinfo.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python + +""" +Show the PNG EXIF information. + +Copyright (C) 2017-2020 Cosmin Truta. + +Use, modification and distribution are subject to the MIT License. +Please see the accompanying file LICENSE_MIT.txt +""" + +from __future__ import absolute_import, division, print_function + +import argparse +import io +import re +import sys +import zlib + +from bytepack import unpack_uint32be, unpack_uint8 +from exifinfo import print_raw_exif_info + +_PNG_SIGNATURE = b"\x89PNG\x0d\x0a\x1a\x0a" +_PNG_CHUNK_SIZE_MAX = 0x7fffffff +_READ_DATA_SIZE_MAX = 0x3ffff + + +def print_error(msg): + """Print an error message to stderr.""" + sys.stderr.write("%s: error: %s\n" % (sys.argv[0], msg)) + + +def print_debug(msg): + """Print a debug message to stderr.""" + sys.stderr.write("%s: debug: %s\n" % (sys.argv[0], msg)) + + +def _check_png(condition, chunk_sig=None): + """Check a PNG-specific assertion.""" + if condition: + return + if chunk_sig is None: + raise RuntimeError("bad PNG data") + raise RuntimeError("bad PNG data in '%s'" % chunk_sig) + + +def _check_png_crc(data, checksum, chunk_sig): + """Check a CRC32 value inside a PNG stream.""" + if unpack_uint32be(data) == (checksum & 0xffffffff): + return + raise RuntimeError("bad PNG checksum in '%s'" % chunk_sig) + + +def _extract_png_exif(data, **kwargs): + """Extract the EXIF header and data from a PNG chunk.""" + debug = kwargs.get("debug", False) + if unpack_uint8(data, 0) == 0: + if debug: + print_debug("found compressed EXIF, compression method 0") + if (unpack_uint8(data, 1) & 0x0f) == 0x08: + data = zlib.decompress(data[1:]) + elif unpack_uint8(data, 1) == 0 \ + and (unpack_uint8(data, 5) & 0x0f) == 0x08: + if debug: + print_debug("found uncompressed-length EXIF field") + data_len = unpack_uint32be(data, 1) + data = zlib.decompress(data[5:]) + if data_len != len(data): + raise RuntimeError( + "incorrect uncompressed-length field in PNG EXIF") + else: + raise RuntimeError("invalid compression method in PNG EXIF") + if data.startswith(b"MM\x00\x2a") or data.startswith(b"II\x2a\x00"): + return data + raise RuntimeError("invalid TIFF/EXIF header in PNG EXIF") + + +def print_png_exif_info(instream, **kwargs): + """Print the EXIF information found in the given PNG datastream.""" + debug = kwargs.get("debug", False) + has_exif = False + while True: + chunk_hdr = instream.read(8) + _check_png(len(chunk_hdr) == 8) + chunk_len = unpack_uint32be(chunk_hdr, offset=0) + chunk_sig = chunk_hdr[4:8].decode("latin_1", errors="ignore") + _check_png(re.search(r"^[A-Za-z]{4}$", chunk_sig), chunk_sig=chunk_sig) + _check_png(chunk_len < _PNG_CHUNK_SIZE_MAX, chunk_sig=chunk_sig) + if debug: + print_debug("processing chunk: %s" % chunk_sig) + if chunk_len <= _READ_DATA_SIZE_MAX: + # The chunk size does not exceed an arbitrary, reasonable limit. + chunk_data = instream.read(chunk_len) + chunk_crc = instream.read(4) + _check_png(len(chunk_data) == chunk_len and len(chunk_crc) == 4, + chunk_sig=chunk_sig) + checksum = zlib.crc32(chunk_hdr[4:8]) + checksum = zlib.crc32(chunk_data, checksum) + _check_png_crc(chunk_crc, checksum, chunk_sig=chunk_sig) + else: + # The chunk is too big. Skip it. + instream.seek(chunk_len + 4, io.SEEK_CUR) + continue + if chunk_sig == "IEND": + _check_png(chunk_len == 0, chunk_sig=chunk_sig) + break + if chunk_sig.lower() in ["exif", "zxif"] and chunk_len > 8: + has_exif = True + exif_data = _extract_png_exif(chunk_data, **kwargs) + print_raw_exif_info(exif_data, **kwargs) + if not has_exif: + raise RuntimeError("no EXIF data in PNG stream") + + +def print_exif_info(file, **kwargs): + """Print the EXIF information found in the given file.""" + with open(file, "rb") as stream: + header = stream.read(4) + if header == _PNG_SIGNATURE[0:4]: + if stream.read(4) != _PNG_SIGNATURE[4:8]: + raise RuntimeError("corrupted PNG file") + print_png_exif_info(instream=stream, **kwargs) + elif header == b"II\x2a\x00" or header == b"MM\x00\x2a": + data = header + stream.read(_READ_DATA_SIZE_MAX) + print_raw_exif_info(data, **kwargs) + else: + raise RuntimeError("not a PNG file") + + +def main(): + """The main function.""" + parser = argparse.ArgumentParser( + prog="pngexifinfo", + usage="%(prog)s [options] [--] files...", + description="Show the PNG EXIF information.") + parser.add_argument("files", + metavar="file", + nargs="*", + help="a PNG file or a raw EXIF blob") + parser.add_argument("-x", + "--hex", + dest="hex", + action="store_true", + help="show EXIF tags in base 16") + parser.add_argument("-v", + "--verbose", + dest="verbose", + action="store_true", + help="run in verbose mode") + parser.add_argument("--debug", + dest="debug", + action="store_true", + help="run in debug mode") + args = parser.parse_args() + if not args.files: + parser.error("missing file operand") + result = 0 + for file in args.files: + try: + print_exif_info(file, + hex=args.hex, + debug=args.debug, + verbose=args.verbose) + except (IOError, OSError) as err: + print_error(str(err)) + result = 66 # os.EX_NOINPUT + except RuntimeError as err: + print_error("%s: %s" % (file, str(err))) + result = 69 # os.EX_UNAVAILABLE + parser.exit(result) + + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + sys.stderr.write("INTERRUPTED\n") + sys.exit(130) # SIGINT From e05ebfba7c7f9faeb6d311155f40092856da4c61 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 22 Feb 2024 12:30:50 +0200 Subject: [PATCH 016/112] doc: Update the README file --- README | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README b/README index afb8c7a9bf..3f75548b90 100644 --- a/README +++ b/README @@ -142,10 +142,11 @@ Files included in this distribution pngwrite.c => High-level write functions pngwtran.c => Write data transformations pngwutil.c => Write utility functions - arm/ => Optimized code for the ARM platform - intel/ => Optimized code for the INTEL-SSE2 platform - mips/ => Optimized code for the MIPS platform - powerpc/ => Optimized code for the PowerPC platform + arm/ => Optimized code for ARM Neon + intel/ => Optimized code for INTEL SSE2 + loongarch/ => Optimized code for LoongArch LSX + mips/ => Optimized code for MIPS MSA and MIPS MMI + powerpc/ => Optimized code for PowerPC VSX ci/ => Scripts for continuous integration contrib/ => External contributions arm-neon/ => Optimized code for the ARM-NEON platform @@ -158,6 +159,7 @@ Files included in this distribution libtests/ => Test programs oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing libpng + pngexif/ => Program to inspect the EXIF information in PNG files pngminim/ => Minimal decoder, encoder, and progressive decoder programs demonstrating the use of pngusr.dfa pngminus/ => Simple pnm2png and png2pnm programs From 3b9a73ed3e24ec26cbfb379b6758b2715536424a Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 22 Feb 2024 16:47:51 +0200 Subject: [PATCH 017/112] doc: Review the libpng history and update scripts/cmake/AUTHORS.md --- scripts/cmake/AUTHORS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index fe423fe778..641dde265f 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -5,9 +5,12 @@ Author List ----------- * Alex Gaynor + * Alexey Petruchik * Andreas Franek + * Andrew Hundt * B. Scott Michel * Benjamin Buch + * Bernd Kuhls * Cameron Cawley * Christian Ehrlicher * Christopher Sean Morrison @@ -17,6 +20,7 @@ Author List * Cosmin Truta * Dan Rosser * David Callu + * Gianfranco Costamagna * Gleb Mazovetskiy * Glenn Randers-Pehrson * Gunther Nikl @@ -26,6 +30,7 @@ Author List * Kyle Bentley * Martin Storsjö * Owen Rudge + * Philip Lowman * Roger Leigh * Roger Lowman * Sam Serrels From 890231026d265f20299f47f14e47838276b2cbb4 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 22 Feb 2024 17:00:05 +0200 Subject: [PATCH 018/112] chore: Delete comments and config settings and stuff from here and there --- .editorconfig | 9 --------- CMakeLists.txt | 1 - configure | 1 - configure.ac | 1 - 4 files changed, 12 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7f9f1c9bfe..f49b2a3e47 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,9 +7,6 @@ charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true -# Traditionally, the end-of-line character has been platform-specific. -end_of_line = unset - [*.txt] indent_style = space @@ -40,12 +37,6 @@ max_doc_length = unset max_line_length = unset trim_trailing_whitespace = unset -[*~] -end_of_line = unset -indent_style = unset -insert_final_newline = unset -trim_trailing_whitespace = unset - [COMMIT_EDITMSG] indent_style = space max_doc_length = unset diff --git a/CMakeLists.txt b/CMakeLists.txt index fca2bb83fb..a7a9d33731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,6 @@ option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF) if(NOT PNG_BUILD_ZLIB) find_package(ZLIB REQUIRED) elseif(POLICY CMP0074) - # TODO: Remove the policy check if CMake version 3.12 or greater becomes the minimum required. if("x${ZLIB_ROOT}" STREQUAL "x") message(DEPRECATION "The option PNG_BUILD_ZLIB has been deprecated; please use ZLIB_ROOT instead") diff --git a/configure b/configure index 263bb0e612..f83ca644db 100755 --- a/configure +++ b/configure @@ -14721,7 +14721,6 @@ printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h fi -# FIXME: This section should not be needed. if test "$enable_loongarch_lsx" != "no" && case "$host_cpu" in loongarch*) : ;; diff --git a/configure.ac b/configure.ac index 21f0b14fed..eed51a8d37 100644 --- a/configure.ac +++ b/configure.ac @@ -621,7 +621,6 @@ AC_ARG_ENABLE([loongarch-lsx], [invalid argument]) esac]) -# FIXME: This section should not be needed. if test "$enable_loongarch_lsx" != "no" && case "$host_cpu" in loongarch*) : ;; From 80691b9da216e243eeeb6a5591f1230b24f8f5f5 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 23 Feb 2024 11:09:51 +0200 Subject: [PATCH 019/112] test: Fix a compiler warning in pngtest.c --- pngtest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pngtest.c b/pngtest.c index a94b449400..571ee6aaac 100644 --- a/pngtest.c +++ b/pngtest.c @@ -139,7 +139,10 @@ static float t_start, t_stop, t_decode, t_encode, t_misc; #ifdef PNG_TIME_RFC1123_SUPPORTED static int tIME_chunk_present = 0; -static char tIME_string[] = "tIME chunk is not present"; +static char tIME_string[29] = "tIME chunk is not present"; +/* This use case is deprecated. + * See the declaration of png_convert_to_rfc1123_buffer for more details. + */ #endif static int verbose = 0; From e1fa61daa80be44a9cd821e1dbdc437c8a242836 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 23 Feb 2024 11:12:03 +0200 Subject: [PATCH 020/112] ci: Add the libpng release tags to the list of exclusions The release tags are redundant in the CI process. It is the main branch that is always verified. --- .appveyor.yml | 1 + .travis.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index e07b932fc7..ddeb4ecf59 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,6 +3,7 @@ version: 1.6.x-{build} branches: except: - /libpng[0-1][0-7]/ + - /v[0-1][.][0-7][.][0-9]+/ image: - Visual Studio 2022 diff --git a/.travis.yml b/.travis.yml index ab3fba6d64..e8adbbd4af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ branches: except: - /libpng[0-1][0-7]/ + - /v[0-1][.][0-7][.][0-9]+/ language: c From ed217e3e601d8e462f7fd1e04bed43ac42212429 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 23 Feb 2024 11:51:40 +0200 Subject: [PATCH 021/112] Release libpng version 1.6.43 --- ANNOUNCE | 83 ++++++++++++++--------------------- CHANGES | 31 ++++++++++++- CMakeLists.txt | 4 +- README | 4 +- configure | 22 +++++----- configure.ac | 4 +- libpng-manual.txt | 2 +- libpng.3 | 6 +-- libpngpf.3 | 4 +- png.5 | 2 +- png.c | 4 +- png.h | 22 +++++----- pngconf.h | 2 +- pngrtran.c | 2 +- pngtest.c | 2 +- scripts/libpng-config-head.in | 2 +- scripts/libpng.pc.in | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 18 files changed, 104 insertions(+), 96 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 2e749c307a..bc147adb78 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,13 +1,5 @@ -libpng 1.6.43.git -================= - -This is a development version, not intended to be a public release. -It will be replaced by a public release, or by another development -version, at a later time. - - -libpng 1.6.42 - January 29, 2024 -================================ +libpng 1.6.43 - February 23, 2024 +================================= This is a public release of libpng, intended for use in production code. @@ -17,13 +9,13 @@ Files available for download Source files with LF line endings (for Unix/Linux): - * libpng-1.6.42.tar.xz (LZMA-compressed, recommended) - * libpng-1.6.42.tar.gz (deflate-compressed) + * libpng-1.6.43.tar.xz (LZMA-compressed, recommended) + * libpng-1.6.43.tar.gz (deflate-compressed) Source files with CRLF line endings (for Windows): - * lpng1642.7z (LZMA-compressed, recommended) - * lpng1642.zip (deflate-compressed) + * lpng1643.7z (LZMA-compressed, recommended) + * lpng1643.zip (deflate-compressed) Other information: @@ -33,47 +25,36 @@ Other information: * TRADEMARK.md -Changes from version 1.6.41 to version 1.6.42 ---------------------------------------------- - - * Fixed the implementation of the macro function `png_check_sig`. - This was an API regression, introduced in libpng-1.6.41. - (Reported by Matthieu Darbois) - - -Changes from version 1.6.40 to version 1.6.41 +Changes from version 1.6.42 to version 1.6.43 --------------------------------------------- - * Added SIMD-optimized code for the Loongarch LSX hardware. - (Contributed by GuXiWei, JinBo and ZhangLixia) - * Fixed the run-time discovery of MIPS MSA hardware. - (Contributed by Sui Jingfeng) - * Fixed an off-by-one error in the function `png_do_check_palette_indexes`, - which failed to recognize errors that might have existed in the first - column of a broken palette-encoded image. This was a benign regression - accidentally introduced in libpng-1.6.33. No pixel was harmed. - (Contributed by Adam Richter; reviewed by John Bowler) - * Fixed, improved and modernized the contrib/pngminus programs, i.e., - png2pnm.c and pnm2png.c - * Removed old and peculiar portability hacks that were meant to silence - warnings issued by gcc version 7.1 alone. + * Fixed the row width check in png_check_IHDR(). + This corrected a bug that was specific to the 16-bit platforms, + and removed a spurious compiler warning from the 64-bit builds. + (Reported by Jacek Caban; fixed by John Bowler) + * Added eXIf chunk support to the push-mode reader in pngpread.c. + (Contributed by Chris Blume) + * Added contrib/pngexif for the benefit of the users who would like + to inspect the content of eXIf chunks. + * Added contrib/conftest/basic.dfa, a basic build-time configuration. (Contributed by John Bowler) - * Fixed and modernized the CMake file, and raised the minimum required - CMake version from 3.1 to 3.6. - (Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.) - * Allowed the configure script to disable the building of auxiliary tools - and tests, thus catching up with the CMake file. - (Contributed by Carlo Bramini) - * Fixed a build issue on Mac. - (Contributed by Zixu Wang) - * Moved the Autoconf macro files to scripts/autoconf. - * Moved the CMake files (except for the main CMakeLists.txt) to - scripts/cmake and moved the list of their contributing authors to - scripts/cmake/AUTHORS.md - * Updated the CI configurations and scripts. - * Relicensed the CI scripts to the MIT License. - * Improved the test coverage. + * Fixed a preprocessor condition in pngread.c that broke build-time + configurations like contrib/conftest/pngcp.dfa. (Contributed by John Bowler) + * Added CMake build support for LoongArch LSX. + (Contributed by GuXiWei) + * Fixed a CMake build error that occurred under a peculiar state of the + dependency tree. This was a regression introduced in libpng-1.6.41. + (Contributed by Dan Rosser) + * Marked the installed libpng headers as system headers in CMake. + (Contributed by Benjamin Buch) + * Updated the build support for RISCOS. + (Contributed by Cameron Cawley) + * Updated the makefiles to allow cross-platform builds to initialize + conventional make variables like AR and ARFLAGS. + * Added various improvements to the CI scripts in areas like version + consistency verification and text linting. + * Added version consistency verification to pngtest.c also. Send comments/corrections/commendations to png-mng-implement at lists.sf.net. diff --git a/CHANGES b/CHANGES index 478b63a9dd..441b57ecf1 100644 --- a/CHANGES +++ b/CHANGES @@ -6130,7 +6130,7 @@ Version 1.6.40 [June 21, 2023] Cleaned up the code, the build scripts, and the documentation. Version 1.6.41 [January 24, 2024] - Added SIMD-optimized code for the Loongarch LSX hardware. + Added SIMD-optimized code for the LoongArch LSX hardware. (Contributed by GuXiWei, JinBo and ZhangLixia) Fixed the run-time discovery of MIPS MSA hardware. (Contributed by Sui Jingfeng) @@ -6167,7 +6167,34 @@ Version 1.6.42 [January 29, 2024] (Reported by Matthieu Darbois) Fixed and updated the libpng manual. -Version 1.6.43 [TODO] +Version 1.6.43 [February 23, 2024] + Fixed the row width check in png_check_IHDR(). + This corrected a bug that was specific to the 16-bit platforms, + and removed a spurious compiler warning from the 64-bit builds. + (Reported by Jacek Caban; fixed by John Bowler) + Added eXIf chunk support to the push-mode reader in pngpread.c. + (Contributed by Chris Blume) + Added contrib/pngexif for the benefit of the users who would like + to inspect the content of eXIf chunks. + Added contrib/conftest/basic.dfa, a basic build-time configuration. + (Contributed by John Bowler) + Fixed a preprocessor condition in pngread.c that broke build-time + configurations like contrib/conftest/pngcp.dfa. + (Contributed by John Bowler) + Added CMake build support for LoongArch LSX. + (Contributed by GuXiWei) + Fixed a CMake build error that occurred under a peculiar state of the + dependency tree. This was a regression introduced in libpng-1.6.41. + (Contributed by Dan Rosser) + Marked the installed libpng headers as system headers in CMake. + (Contributed by Benjamin Buch) + Updated the build support for RISCOS. + (Contributed by Cameron Cawley) + Updated the makefiles to allow cross-platform builds to initialize + conventional make variables like AR and ARFLAGS. + Added various improvements to the CI scripts in areas like version + consistency verification and text linting. + Added version consistency verification to pngtest.c also. Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit diff --git a/CMakeLists.txt b/CMakeLists.txt index a7a9d33731..ad3f2427dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,8 @@ cmake_minimum_required(VERSION 3.6) set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) set(PNGLIB_REVISION 43) -#set(PNGLIB_SUBREVISION 0) -set(PNGLIB_SUBREVISION "git") +set(PNGLIB_SUBREVISION 0) +#set(PNGLIB_SUBREVISION "git") set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) diff --git a/README b/README index 3f75548b90..a6ca3ae9f9 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -README for libpng version 1.6.43.git -==================================== +README for libpng version 1.6.43 +================================ See the note about version numbers near the top of `png.h`. See `INSTALL` for instructions on how to install libpng. diff --git a/configure b/configure index f83ca644db..ca475f7711 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for libpng 1.6.43.git. +# Generated by GNU Autoconf 2.72 for libpng 1.6.43. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.6.43.git' -PACKAGE_STRING='libpng 1.6.43.git' +PACKAGE_VERSION='1.6.43' +PACKAGE_STRING='libpng 1.6.43' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -1417,7 +1417,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures libpng 1.6.43.git to adapt to many kinds of systems. +'configure' configures libpng 1.6.43 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1488,7 +1488,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.6.43.git:";; + short | recursive ) echo "Configuration of libpng 1.6.43:";; esac cat <<\_ACEOF @@ -1685,7 +1685,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.6.43.git +libpng configure 1.6.43 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -1948,7 +1948,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.6.43.git, which was +It was created by libpng $as_me 1.6.43, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3248,7 +3248,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.6.43.git' + VERSION='1.6.43' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -3381,7 +3381,7 @@ fi -PNGLIB_VERSION=1.6.43.git +PNGLIB_VERSION=1.6.43 PNGLIB_MAJOR=1 PNGLIB_MINOR=6 PNGLIB_RELEASE=43 @@ -15382,7 +15382,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.6.43.git, which was +This file was extended by libpng $as_me 1.6.43, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15450,7 +15450,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libpng config.status 1.6.43.git +libpng config.status 1.6.43 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index eed51a8d37..505d72ff60 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng],[1.6.43.git],[png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng],[1.6.43],[png-mng-implement@lists.sourceforge.net]) AC_CONFIG_MACRO_DIR([scripts/autoconf]) # libpng does not follow GNU file name conventions (hence 'foreign') @@ -46,7 +46,7 @@ dnl automake, so the following is not necessary (and is not defined anyway): dnl AM_PREREQ([1.11.2]) dnl stop configure from automagically running automake -PNGLIB_VERSION=1.6.43.git +PNGLIB_VERSION=1.6.43 PNGLIB_MAJOR=1 PNGLIB_MINOR=6 PNGLIB_RELEASE=43 diff --git a/libpng-manual.txt b/libpng-manual.txt index d2918ce316..7988057599 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -9,7 +9,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng version 1.6.36, December 2018, through 1.6.42 - January 2024 + libpng version 1.6.36, December 2018, through 1.6.43 - February 2024 Updated and distributed by Cosmin Truta Copyright (c) 2018-2024 Cosmin Truta diff --git a/libpng.3 b/libpng.3 index 8875b219a1..45e76e4837 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "January 29, 2024" +.TH LIBPNG 3 "February 23, 2024" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.6.42 +libpng \- Portable Network Graphics (PNG) Reference Library 1.6.43 .SH SYNOPSIS \fB#include \fP @@ -528,7 +528,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng version 1.6.36, December 2018, through 1.6.42 - January 2024 + libpng version 1.6.36, December 2018, through 1.6.43 - February 2024 Updated and distributed by Cosmin Truta Copyright (c) 2018-2024 Cosmin Truta diff --git a/libpngpf.3 b/libpngpf.3 index a469205030..0abec74a2d 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,6 +1,6 @@ -.TH LIBPNGPF 3 "January 29, 2024" +.TH LIBPNGPF 3 "February 23, 2024" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.6.42 +libpng \- Portable Network Graphics (PNG) Reference Library 1.6.43 (private functions) .SH SYNOPSIS diff --git a/png.5 b/png.5 index 1737ba5105..a8a681813f 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "January 29, 2024" +.TH PNG 5 "February 23, 2024" .SH NAME png \- Portable Network Graphics (PNG) format diff --git a/png.c b/png.c index 802c61e821..9ed3157009 100644 --- a/png.c +++ b/png.c @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_43_git Your_png_h_is_not_version_1_6_43_git; +typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -794,7 +794,7 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.43.git" PNG_STRING_NEWLINE \ + "libpng version 1.6.43" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index 013f309eae..83d3903126 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.43.git + * libpng version 1.6.43 * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson @@ -15,7 +15,7 @@ * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.35, July 2018: * Glenn Randers-Pehrson - * libpng versions 1.6.36, December 2018, through 1.6.42, January 2024: + * libpng versions 1.6.36, December 2018, through 1.6.43, February 2024: * Cosmin Truta * See also "Contributing Authors", below. */ @@ -239,7 +239,7 @@ * ... * 1.5.30 15 10530 15.so.15.30[.0] * ... - * 1.6.42 16 10642 16.so.16.42[.0] + * 1.6.43 16 10643 16.so.16.43[.0] * * Henceforth the source version will match the shared-library major and * minor numbers; the shared-library major version number will be used for @@ -275,7 +275,7 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.43.git" +#define PNG_LIBPNG_VER_STRING "1.6.43" #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n" /* The versions of shared library builds should stay in sync, going forward */ @@ -289,14 +289,14 @@ #define PNG_LIBPNG_VER_RELEASE 43 /* This should be zero for a public release, or non-zero for a - * development version. [Deprecated] + * development version. */ -#define PNG_LIBPNG_VER_BUILD 1 +#define PNG_LIBPNG_VER_BUILD 0 /* Release Status */ -#define PNG_LIBPNG_BUILD_ALPHA 1 /* [Deprecated] */ +#define PNG_LIBPNG_BUILD_ALPHA 1 #define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 /* [Deprecated] */ +#define PNG_LIBPNG_BUILD_RC 3 #define PNG_LIBPNG_BUILD_STABLE 4 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 @@ -308,7 +308,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE /* Careful here. At one time, Guy wanted to use 082, but that * would be octal. We must not include leading zeros. @@ -317,7 +317,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10643 /* 1.6.43.git */ +#define PNG_LIBPNG_VER 10643 /* 1.6.43 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -427,7 +427,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_43_git; +typedef char* png_libpng_version_1_6_43; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * diff --git a/pngconf.h b/pngconf.h index f58d206640..000d7b1a8a 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine-configurable file for libpng * - * libpng version 1.6.43.git + * libpng version 1.6.43 * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson diff --git a/pngrtran.c b/pngrtran.c index 041f9306c1..1526123e02 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -302,7 +302,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, * viewing correction values. The intent is to weed out the API users * who might use the inverse of the gamma value accidentally! * - * In libpng 1.6.x, we changed from 0.07..3 to 0.01..100, to accommodate + * In libpng 1.6.0, we changed from 0.07..3 to 0.01..100, to accommodate * the optimal 16-bit gamma of 36 and its reciprocal. */ if (output_gamma < 1000 || output_gamma > 10000000) diff --git a/pngtest.c b/pngtest.c index 571ee6aaac..45ef66a701 100644 --- a/pngtest.c +++ b/pngtest.c @@ -46,7 +46,7 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_43_git Your_png_h_is_not_version_1_6_43_git; +typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43; /* Ensure that all version numbers in png.h are consistent with one another. */ #if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \ diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in index df8d6621bd..37577f4134 100644 --- a/scripts/libpng-config-head.in +++ b/scripts/libpng-config-head.in @@ -11,7 +11,7 @@ # Modeled after libxml-config. -version=1.6.43.git +version=1.6.43 prefix="" libdir="" libs="" diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in index 0fc82fa578..6a581d1a48 100644 --- a/scripts/libpng.pc.in +++ b/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng16 Name: libpng Description: Loads and saves PNG files -Version: 1.6.43.git +Version: 1.6.43 Libs: -L${libdir} -lpng16 Cflags: -I${includedir} diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 9dd54087ad..83f09fbe77 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -1,6 +1,6 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.6.43.git */ +/* libpng version 1.6.43 */ /* Copyright (c) 2018-2024 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ From f1848a3b560ddcad065242268433af475948461e Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 24 Feb 2024 13:32:56 +0200 Subject: [PATCH 022/112] Bump version to 1.6.44.git --- ANNOUNCE | 8 ++++++++ CHANGES | 2 ++ CMakeLists.txt | 6 +++--- README | 4 ++-- configure | 26 +++++++++++++------------- configure.ac | 8 ++++---- png.c | 4 ++-- png.h | 22 +++++++++++----------- pngconf.h | 2 +- pngtest.c | 2 +- scripts/libpng-config-head.in | 2 +- scripts/libpng.pc.in | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 13 files changed, 50 insertions(+), 40 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index bc147adb78..6361247876 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,3 +1,11 @@ +libpng 1.6.44.git +================= + +This is a development version, not intended to be a public release. +It will be replaced by a public release, or by another development +version, at a later time. + + libpng 1.6.43 - February 23, 2024 ================================= diff --git a/CHANGES b/CHANGES index 441b57ecf1..6eab52bae7 100644 --- a/CHANGES +++ b/CHANGES @@ -6196,6 +6196,8 @@ Version 1.6.43 [February 23, 2024] consistency verification and text linting. Added version consistency verification to pngtest.c also. +Version 1.6.44 [TODO] + Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/CMakeLists.txt b/CMakeLists.txt index ad3f2427dc..77e5398b6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,9 +19,9 @@ cmake_minimum_required(VERSION 3.6) set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) -set(PNGLIB_REVISION 43) -set(PNGLIB_SUBREVISION 0) -#set(PNGLIB_SUBREVISION "git") +set(PNGLIB_REVISION 44) +#set(PNGLIB_SUBREVISION 0) +set(PNGLIB_SUBREVISION "git") set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) diff --git a/README b/README index a6ca3ae9f9..d0a3635bdf 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -README for libpng version 1.6.43 -================================ +README for libpng version 1.6.44.git +==================================== See the note about version numbers near the top of `png.h`. See `INSTALL` for instructions on how to install libpng. diff --git a/configure b/configure index ca475f7711..ee7d0eadac 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for libpng 1.6.43. +# Generated by GNU Autoconf 2.72 for libpng 1.6.44.git. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.6.43' -PACKAGE_STRING='libpng 1.6.43' +PACKAGE_VERSION='1.6.44.git' +PACKAGE_STRING='libpng 1.6.44.git' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -1417,7 +1417,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures libpng 1.6.43 to adapt to many kinds of systems. +'configure' configures libpng 1.6.44.git to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1488,7 +1488,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.6.43:";; + short | recursive ) echo "Configuration of libpng 1.6.44.git:";; esac cat <<\_ACEOF @@ -1685,7 +1685,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.6.43 +libpng configure 1.6.44.git generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -1948,7 +1948,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.6.43, which was +It was created by libpng $as_me 1.6.44.git, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3248,7 +3248,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.6.43' + VERSION='1.6.44.git' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -3381,17 +3381,17 @@ fi -PNGLIB_VERSION=1.6.43 +PNGLIB_VERSION=1.6.44.git PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=43 +PNGLIB_RELEASE=44 ac_config_headers="$ac_config_headers config.h" -# Check for basic programs. +# Check the basic programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -15382,7 +15382,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.6.43, which was +This file was extended by libpng $as_me 1.6.44.git, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15450,7 +15450,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libpng config.status 1.6.43 +libpng config.status 1.6.44.git configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 505d72ff60..2c6b3333c6 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng],[1.6.43],[png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng],[1.6.44.git],[png-mng-implement@lists.sourceforge.net]) AC_CONFIG_MACRO_DIR([scripts/autoconf]) # libpng does not follow GNU file name conventions (hence 'foreign') @@ -46,17 +46,17 @@ dnl automake, so the following is not necessary (and is not defined anyway): dnl AM_PREREQ([1.11.2]) dnl stop configure from automagically running automake -PNGLIB_VERSION=1.6.43 +PNGLIB_VERSION=1.6.44.git PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=43 +PNGLIB_RELEASE=44 dnl End of version number stuff AC_CONFIG_SRCDIR([pngget.c]) AC_CONFIG_HEADERS([config.h]) -# Check for basic programs. +# Check the basic programs. AC_LANG([C]) AC_PROG_CC AM_PROG_AS diff --git a/png.c b/png.c index 9ed3157009..28e5a43e73 100644 --- a/png.c +++ b/png.c @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43; +typedef png_libpng_version_1_6_44_git Your_png_h_is_not_version_1_6_44_git; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -794,7 +794,7 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.43" PNG_STRING_NEWLINE \ + "libpng version 1.6.44.git" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index 83d3903126..b71bd7064a 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.43 + * libpng version 1.6.44.git * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson @@ -275,7 +275,7 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.43" +#define PNG_LIBPNG_VER_STRING "1.6.44.git" #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n" /* The versions of shared library builds should stay in sync, going forward */ @@ -286,18 +286,18 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 43 +#define PNG_LIBPNG_VER_RELEASE 44 /* This should be zero for a public release, or non-zero for a * development version. */ -#define PNG_LIBPNG_VER_BUILD 0 +#define PNG_LIBPNG_VER_BUILD 1 /* Release Status */ -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 +#define PNG_LIBPNG_BUILD_ALPHA 1 +#define PNG_LIBPNG_BUILD_BETA 2 +#define PNG_LIBPNG_BUILD_RC 3 +#define PNG_LIBPNG_BUILD_STABLE 4 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 /* Release-Specific Flags */ @@ -308,7 +308,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA /* Careful here. At one time, Guy wanted to use 082, but that * would be octal. We must not include leading zeros. @@ -317,7 +317,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10643 /* 1.6.43 */ +#define PNG_LIBPNG_VER 10644 /* 1.6.44.git */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -427,7 +427,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_43; +typedef char* png_libpng_version_1_6_44_git; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * diff --git a/pngconf.h b/pngconf.h index 000d7b1a8a..175a36c6f1 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine-configurable file for libpng * - * libpng version 1.6.43 + * libpng version 1.6.44.git * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson diff --git a/pngtest.c b/pngtest.c index 45ef66a701..81da721263 100644 --- a/pngtest.c +++ b/pngtest.c @@ -46,7 +46,7 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43; +typedef png_libpng_version_1_6_44_git Your_png_h_is_not_version_1_6_44_git; /* Ensure that all version numbers in png.h are consistent with one another. */ #if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \ diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in index 37577f4134..2fb79d428a 100644 --- a/scripts/libpng-config-head.in +++ b/scripts/libpng-config-head.in @@ -11,7 +11,7 @@ # Modeled after libxml-config. -version=1.6.43 +version=1.6.44.git prefix="" libdir="" libs="" diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in index 6a581d1a48..73ed7f54dd 100644 --- a/scripts/libpng.pc.in +++ b/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng16 Name: libpng Description: Loads and saves PNG files -Version: 1.6.43 +Version: 1.6.44.git Libs: -L${libdir} -lpng16 Cflags: -I${includedir} diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 83f09fbe77..2c95cd5df2 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -1,6 +1,6 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.6.43 */ +/* libpng version 1.6.44.git */ /* Copyright (c) 2018-2024 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ From ceed2a3cf6af420a0782e7f6147d5965b01b772a Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 30 May 2024 07:53:42 -0700 Subject: [PATCH 023/112] SECURITY: disable build of filter_neon.S on arm This fixes the bug https://github.com/pnggroup/libpng/issues/505 "libpng does not support PAC/BTI on aarch64 targets" which arises because the build mechanisms (both cmake and configure) assemble arm/filter_neon.S even though it ends up completely empty. The empty file effectively poisons the so that the PAC/BTI support gets disabled. The fix is minimal; it simply removes arm/filter_neon.S from the list of sources included in the 64-bit ARM builds build. Note that this was already done in cmake for MSVC - it's not clear whether this change was a partial fix for the same issue. This version of the fix ONLY affects aarch64 (arm64) builds; 32-bit ARM systems can still invoke the assembler if required and, indeed, there should be no change whatsover to those builds. The assembler code could not be used on 64-bit systems in any case so in practice there is no material change to 64-bit builds either. TESTING: pull the changes then type "autoreconf" if using configure (not required for cmake). TESTS: cmake has not been tested because cross-builds with cmake currently fail to find the zlib installation from the cmake system root path. The following has been tested with configure cross builds: armv7-linux-gnueabi [no neon support] armv7a-linux-gnueabi [no neon support] armv7a-hardfloat-linux-gnueabi [neon support not enabled] armv7a-hardfloat-linux-gnueabi -mfpu=neon [uses intrinics] armv7a-hardfloat-linux-gnueabi -mfpu=neon -DPNG_ARM_NEON_IMPLEMENTATION=2 [uses assembler] aarch64-linux-gnu [uses intrinsics] aarch64-linux-gnu -DPNG_ARM_NEON_OPT=0 [neon support disabled] Signed-off-by: John Bowler --- CMakeLists.txt | 2 +- Makefile.am | 6 ++++-- configure.ac | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77e5398b6a..11bbe36d2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)") arm/arm_init.c arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c) - if(NOT MSVC) + if(NOT MSVC AND NOT TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)") list(APPEND libpng_arm_sources arm/filter_neon.S) endif() if(PNG_ARM_NEON STREQUAL "on") diff --git a/Makefile.am b/Makefile.am index 1f06c703a1..5cc27a4c8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -107,9 +107,11 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa if PNG_ARM_NEON +if PNG_ARM_NEON_ASM +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S +endif libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ - arm/filter_neon.S arm/filter_neon_intrinsics.c \ - arm/palette_neon_intrinsics.c + arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c endif if PNG_MIPS_MSA diff --git a/configure.ac b/configure.ac index 2c6b3333c6..e3c1536f0c 100644 --- a/configure.ac +++ b/configure.ac @@ -425,6 +425,16 @@ AM_CONDITIONAL([PNG_ARM_NEON], *) test "$enable_arm_neon" != '' ;; esac]) +# Add the assembler implementation source file. This only works on 32-bit +# ARM and causes problems even if empty on 64-bit ARM. +AM_CONDITIONAL([PNG_ARM_NEON_ASM], + [test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm64*|aarch64*) false ;; + arm*) true ;; + *) test "$enable_arm_neon" != '' ;; + esac]) + # MIPS MSA # ======== From 9e538750d99c8f1accf7e93878e4fde47c069908 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Thu, 14 Dec 2023 20:25:46 +0000 Subject: [PATCH 024/112] arm: Remove obsolete assembler implementation filter_neon.S This file contains hand-coded assembler implementations of the filter functions for 32-bit Arm platforms. These are only used when the compiler doesn't support neon intrinsics (added to GCC 4.3 in 2008) or is exactly GCC 4.5.4 (released 2012), both of which are sufficiently unlikely to be true that it's fair to say the assembler is no longer used. This commit deletes filter_neon.S and removes the now obsolete preprocessor logic in pngpriv.h. Signed-off-by: Bill Roberts Signed-off-by: Cosmin Truta --- CMakeLists.txt | 3 - Makefile.am | 6 +- Makefile.in | 56 ++-------- arm/filter_neon.S | 253 ---------------------------------------------- configure.ac | 10 -- pngpriv.h | 41 -------- 6 files changed, 11 insertions(+), 358 deletions(-) delete mode 100644 arm/filter_neon.S diff --git a/CMakeLists.txt b/CMakeLists.txt index 11bbe36d2a..3cb4dedf6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,9 +153,6 @@ if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)") arm/arm_init.c arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c) - if(NOT MSVC AND NOT TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)") - list(APPEND libpng_arm_sources arm/filter_neon.S) - endif() if(PNG_ARM_NEON STREQUAL "on") add_definitions(-DPNG_ARM_NEON_OPT=2) elseif(PNG_ARM_NEON STREQUAL "check") diff --git a/Makefile.am b/Makefile.am index 5cc27a4c8f..eed986c2b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -107,11 +107,9 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa if PNG_ARM_NEON -if PNG_ARM_NEON_ASM -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S -endif libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ - arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c + arm/filter_neon_intrinsics.c \ + arm/palette_neon_intrinsics.c endif if PNG_MIPS_MSA diff --git a/Makefile.in b/Makefile.in index c9eac7dbc6..46c3a13cfe 100644 --- a/Makefile.in +++ b/Makefile.in @@ -108,7 +108,7 @@ host_triplet = @host@ @ENABLE_TOOLS_TRUE@bin_PROGRAMS = pngfix$(EXEEXT) \ @ENABLE_TOOLS_TRUE@ png-fix-itxt$(EXEEXT) @PNG_ARM_NEON_TRUE@am__append_2 = arm/arm_init.c\ -@PNG_ARM_NEON_TRUE@ arm/filter_neon.S arm/filter_neon_intrinsics.c \ +@PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.c \ @PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.c @PNG_MIPS_MSA_TRUE@am__append_3 = mips/mips_init.c\ @@ -188,13 +188,13 @@ am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST = png.c \ pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c \ pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \ pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \ - arm/filter_neon.S arm/filter_neon_intrinsics.c \ - arm/palette_neon_intrinsics.c mips/mips_init.c \ - mips/filter_msa_intrinsics.c mips/filter_mmi_inline_assembly.c \ - intel/intel_init.c intel/filter_sse2_intrinsics.c \ - powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c + arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c \ + mips/mips_init.c mips/filter_msa_intrinsics.c \ + mips/filter_mmi_inline_assembly.c intel/intel_init.c \ + intel/filter_sse2_intrinsics.c powerpc/powerpc_init.c \ + powerpc/filter_vsx_intrinsics.c am__dirstamp = $(am__leading_dot)dirstamp -@PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \ +@PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo \ @PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.lo \ @PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.lo @PNG_MIPS_MSA_TRUE@am__objects_2 = mips/mips_init.lo \ @@ -312,7 +312,7 @@ am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \ ./$(DEPDIR)/pngtest.Po ./$(DEPDIR)/pngtrans.Plo \ ./$(DEPDIR)/pngwio.Plo ./$(DEPDIR)/pngwrite.Plo \ ./$(DEPDIR)/pngwtran.Plo ./$(DEPDIR)/pngwutil.Plo \ - arm/$(DEPDIR)/arm_init.Plo arm/$(DEPDIR)/filter_neon.Plo \ + arm/$(DEPDIR)/arm_init.Plo \ arm/$(DEPDIR)/filter_neon_intrinsics.Plo \ arm/$(DEPDIR)/palette_neon_intrinsics.Plo \ contrib/libtests/$(DEPDIR)/pngimage.Po \ @@ -333,16 +333,6 @@ am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \ powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo \ powerpc/$(DEPDIR)/powerpc_init.Plo am__mv = mv -f -CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -LTCPPASCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CCASFLAGS) $(CCASFLAGS) -AM_V_CPPAS = $(am__v_CPPAS_@AM_V@) -am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@) -am__v_CPPAS_0 = @echo " CPPAS " $@; -am__v_CPPAS_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -885,7 +875,7 @@ all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: -.SUFFIXES: .chk .out .S .c .lo .log .o .obj .test .test$(EXEEXT) .trs +.SUFFIXES: .chk .out .c .lo .log .o .obj .test .test$(EXEEXT) .trs am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @@ -1049,7 +1039,6 @@ arm/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) arm/$(DEPDIR) @: > arm/$(DEPDIR)/$(am__dirstamp) arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) -arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \ arm/$(DEPDIR)/$(am__dirstamp) arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \ @@ -1237,7 +1226,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwtran.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwutil.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/arm_init.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon_intrinsics.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/palette_neon_intrinsics.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngimage.Po@am__quote@ # am--include-marker @@ -1264,30 +1252,6 @@ $(am__depfiles_remade): am--depfiles: $(am__depfiles_remade) -.S.o: -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $< - -.S.obj: -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.S.lo: -@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LTCPPASCOMPILE) -c -o $@ $< - .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @@ -2196,7 +2160,6 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/pngwtran.Plo -rm -f ./$(DEPDIR)/pngwutil.Plo -rm -f arm/$(DEPDIR)/arm_init.Plo - -rm -f arm/$(DEPDIR)/filter_neon.Plo -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po @@ -2284,7 +2247,6 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/pngwtran.Plo -rm -f ./$(DEPDIR)/pngwutil.Plo -rm -f arm/$(DEPDIR)/arm_init.Plo - -rm -f arm/$(DEPDIR)/filter_neon.Plo -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po diff --git a/arm/filter_neon.S b/arm/filter_neon.S deleted file mode 100644 index 2308aad13e..0000000000 --- a/arm/filter_neon.S +++ /dev/null @@ -1,253 +0,0 @@ - -/* filter_neon.S - NEON optimised filter functions - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 2014,2017 Glenn Randers-Pehrson - * Written by Mans Rullgard, 2011. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* This is required to get the symbol renames, which are #defines, and the - * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION. - */ -#define PNG_VERSION_INFO_ONLY -#include "../pngpriv.h" - -#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__) -.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ -#endif - -#ifdef PNG_READ_SUPPORTED - -/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for - * ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it - * only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h - * for the logic which sets PNG_USE_ARM_NEON_ASM: - */ -#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */ - -#if PNG_ARM_NEON_OPT > 0 - -#ifdef __ELF__ -# define ELF -#else -# define ELF @ -#endif - - .arch armv7-a - .fpu neon - -.macro func name, export=0 - .macro endfunc -ELF .size \name, . - \name - .endfunc - .purgem endfunc - .endm - .text - - /* Explicitly specifying alignment here because some versions of - * GAS don't align code correctly. This is harmless in correctly - * written versions of GAS. - */ - .align 2 - - .if \export - .global \name - .endif -ELF .type \name, STT_FUNC - .func \name -\name: -.endm - -func png_read_filter_row_sub4_neon, export=1 - ldr r3, [r0, #4] @ rowbytes - vmov.i8 d3, #0 -1: - vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] - vadd.u8 d0, d3, d4 - vadd.u8 d1, d0, d5 - vadd.u8 d2, d1, d6 - vadd.u8 d3, d2, d7 - vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! - subs r3, r3, #16 - bgt 1b - - bx lr -endfunc - -func png_read_filter_row_sub3_neon, export=1 - ldr r3, [r0, #4] @ rowbytes - vmov.i8 d3, #0 - mov r0, r1 - mov r2, #3 - mov r12, #12 - vld1.8 {q11}, [r0], r12 -1: - vext.8 d5, d22, d23, #3 - vadd.u8 d0, d3, d22 - vext.8 d6, d22, d23, #6 - vadd.u8 d1, d0, d5 - vext.8 d7, d23, d23, #1 - vld1.8 {q11}, [r0], r12 - vst1.32 {d0[0]}, [r1,:32], r2 - vadd.u8 d2, d1, d6 - vst1.32 {d1[0]}, [r1], r2 - vadd.u8 d3, d2, d7 - vst1.32 {d2[0]}, [r1], r2 - vst1.32 {d3[0]}, [r1], r2 - subs r3, r3, #12 - bgt 1b - - bx lr -endfunc - -func png_read_filter_row_up_neon, export=1 - ldr r3, [r0, #4] @ rowbytes -1: - vld1.8 {q0}, [r1,:128] - vld1.8 {q1}, [r2,:128]! - vadd.u8 q0, q0, q1 - vst1.8 {q0}, [r1,:128]! - subs r3, r3, #16 - bgt 1b - - bx lr -endfunc - -func png_read_filter_row_avg4_neon, export=1 - ldr r12, [r0, #4] @ rowbytes - vmov.i8 d3, #0 -1: - vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] - vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! - vhadd.u8 d0, d3, d16 - vadd.u8 d0, d0, d4 - vhadd.u8 d1, d0, d17 - vadd.u8 d1, d1, d5 - vhadd.u8 d2, d1, d18 - vadd.u8 d2, d2, d6 - vhadd.u8 d3, d2, d19 - vadd.u8 d3, d3, d7 - vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! - subs r12, r12, #16 - bgt 1b - - bx lr -endfunc - -func png_read_filter_row_avg3_neon, export=1 - push {r4,lr} - ldr r12, [r0, #4] @ rowbytes - vmov.i8 d3, #0 - mov r0, r1 - mov r4, #3 - mov lr, #12 - vld1.8 {q11}, [r0], lr -1: - vld1.8 {q10}, [r2], lr - vext.8 d5, d22, d23, #3 - vhadd.u8 d0, d3, d20 - vext.8 d17, d20, d21, #3 - vadd.u8 d0, d0, d22 - vext.8 d6, d22, d23, #6 - vhadd.u8 d1, d0, d17 - vext.8 d18, d20, d21, #6 - vadd.u8 d1, d1, d5 - vext.8 d7, d23, d23, #1 - vld1.8 {q11}, [r0], lr - vst1.32 {d0[0]}, [r1,:32], r4 - vhadd.u8 d2, d1, d18 - vst1.32 {d1[0]}, [r1], r4 - vext.8 d19, d21, d21, #1 - vadd.u8 d2, d2, d6 - vhadd.u8 d3, d2, d19 - vst1.32 {d2[0]}, [r1], r4 - vadd.u8 d3, d3, d7 - vst1.32 {d3[0]}, [r1], r4 - subs r12, r12, #12 - bgt 1b - - pop {r4,pc} -endfunc - -.macro paeth rx, ra, rb, rc - vaddl.u8 q12, \ra, \rb @ a + b - vaddl.u8 q15, \rc, \rc @ 2*c - vabdl.u8 q13, \rb, \rc @ pa - vabdl.u8 q14, \ra, \rc @ pb - vabd.u16 q15, q12, q15 @ pc - vcle.u16 q12, q13, q14 @ pa <= pb - vcle.u16 q13, q13, q15 @ pa <= pc - vcle.u16 q14, q14, q15 @ pb <= pc - vand q12, q12, q13 @ pa <= pb && pa <= pc - vmovn.u16 d28, q14 - vmovn.u16 \rx, q12 - vbsl d28, \rb, \rc - vbsl \rx, \ra, d28 -.endm - -func png_read_filter_row_paeth4_neon, export=1 - ldr r12, [r0, #4] @ rowbytes - vmov.i8 d3, #0 - vmov.i8 d20, #0 -1: - vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] - vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! - paeth d0, d3, d16, d20 - vadd.u8 d0, d0, d4 - paeth d1, d0, d17, d16 - vadd.u8 d1, d1, d5 - paeth d2, d1, d18, d17 - vadd.u8 d2, d2, d6 - paeth d3, d2, d19, d18 - vmov d20, d19 - vadd.u8 d3, d3, d7 - vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! - subs r12, r12, #16 - bgt 1b - - bx lr -endfunc - -func png_read_filter_row_paeth3_neon, export=1 - push {r4,lr} - ldr r12, [r0, #4] @ rowbytes - vmov.i8 d3, #0 - vmov.i8 d4, #0 - mov r0, r1 - mov r4, #3 - mov lr, #12 - vld1.8 {q11}, [r0], lr -1: - vld1.8 {q10}, [r2], lr - paeth d0, d3, d20, d4 - vext.8 d5, d22, d23, #3 - vadd.u8 d0, d0, d22 - vext.8 d17, d20, d21, #3 - paeth d1, d0, d17, d20 - vst1.32 {d0[0]}, [r1,:32], r4 - vext.8 d6, d22, d23, #6 - vadd.u8 d1, d1, d5 - vext.8 d18, d20, d21, #6 - paeth d2, d1, d18, d17 - vext.8 d7, d23, d23, #1 - vld1.8 {q11}, [r0], lr - vst1.32 {d1[0]}, [r1], r4 - vadd.u8 d2, d2, d6 - vext.8 d19, d21, d21, #1 - paeth d3, d2, d19, d18 - vst1.32 {d2[0]}, [r1], r4 - vmov d4, d19 - vadd.u8 d3, d3, d7 - vst1.32 {d3[0]}, [r1], r4 - subs r12, r12, #12 - bgt 1b - - pop {r4,pc} -endfunc -#endif /* PNG_ARM_NEON_OPT > 0 */ -#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */ -#endif /* READ */ diff --git a/configure.ac b/configure.ac index e3c1536f0c..2c6b3333c6 100644 --- a/configure.ac +++ b/configure.ac @@ -425,16 +425,6 @@ AM_CONDITIONAL([PNG_ARM_NEON], *) test "$enable_arm_neon" != '' ;; esac]) -# Add the assembler implementation source file. This only works on 32-bit -# ARM and causes problems even if empty on 64-bit ARM. -AM_CONDITIONAL([PNG_ARM_NEON_ASM], - [test "$enable_arm_neon" != 'no' && - case "$host_cpu" in - arm64*|aarch64*) false ;; - arm*) true ;; - *) test "$enable_arm_neon" != '' ;; - esac]) - # MIPS MSA # ======== diff --git a/pngpriv.h b/pngpriv.h index 9bfdb71342..b59084e7eb 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -140,47 +140,6 @@ * callbacks to do this. */ # define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon - - /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used - * if possible - if __ARM_NEON__ is set and the compiler version is not known - * to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can - * be: - * - * 1 The intrinsics code (the default with __ARM_NEON__) - * 2 The hand coded assembler (the default without __ARM_NEON__) - * - * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however - * this is *NOT* supported and may cease to work even after a minor revision - * to libpng. It *is* valid to do this for testing purposes, e.g. speed - * testing or a new compiler, but the results should be communicated to the - * libpng implementation list for incorporation in the next minor release. - */ -# ifndef PNG_ARM_NEON_IMPLEMENTATION -# if defined(__ARM_NEON__) || defined(__ARM_NEON) -# if defined(__clang__) - /* At present it is unknown by the libpng developers which versions - * of clang support the intrinsics, however some or perhaps all - * versions do not work with the assembler so this may be - * irrelevant, so just use the default (do nothing here.) - */ -# elif defined(__GNUC__) - /* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to - * work, so if this *is* GCC, or G++, look for a version >4.5 - */ -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) -# define PNG_ARM_NEON_IMPLEMENTATION 2 -# endif /* no GNUC support */ -# endif /* __GNUC__ */ -# else /* !defined __ARM_NEON__ */ - /* The 'intrinsics' code simply won't compile without this -mfpu=neon: - */ -# if !defined(__aarch64__) && !defined(_M_ARM64) - /* The assembler code currently does not work on ARM64 */ -# define PNG_ARM_NEON_IMPLEMENTATION 2 -# endif /* __aarch64__ */ -# endif /* __ARM_NEON__ */ -# endif /* !PNG_ARM_NEON_IMPLEMENTATION */ - # ifndef PNG_ARM_NEON_IMPLEMENTATION /* Use the intrinsics code by default. */ # define PNG_ARM_NEON_IMPLEMENTATION 1 From e4a31f024b6158aaaf55a43502f574d5f5d1c894 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 17 Jun 2024 15:28:38 +0300 Subject: [PATCH 025/112] arm: Add a placeholder file in lieu of the former `filter_neon.S` In the previous commit 9e538750d99c8f1accf7e93878e4fde47c069908 we removed the obsolete assembler implementation `filter_neon.S`. In this commit we add a stand-in for the original file, restoring the original source tree structure, for the benefit of continuing hassle-free libpng source upgrades in the 1.6.x line. --- arm/filter_neon.S | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 arm/filter_neon.S diff --git a/arm/filter_neon.S b/arm/filter_neon.S new file mode 100644 index 0000000000..fc3c7a2964 --- /dev/null +++ b/arm/filter_neon.S @@ -0,0 +1,61 @@ + +/* filter_neon.S - placeholder file + * + * Copyright (c) 2024 Cosmin Truta + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* IMPORTANT NOTE: + * + * Historically, the hand-coded assembler implementation of Neon optimizations + * in this module had not been in sync with the intrinsics-based implementation + * in filter_neon_intrinsics.c and palette_neon_intrinsics.c, at least since + * the introduction of riffled palette optimizations. Moreover, the assembler + * code used to work on 32-bit ARM only, and it caused problems, even if empty, + * on 64-bit ARM. + * + * All references to this module from our internal build scripts and projects + * have been removed. + * + * For the external projects that might still expect this module to be present, + * we leave this stub in place, for the remaining lifetime of libpng-1.6.x. + * Everything should continue to function normally, as long as there are no + * deliberate attempts to use the old hand-made assembler code. A build error + * will be raised otherwise. + */ + +/* This is required to get the symbol renames, which are #defines, and the + * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION. + */ +#define PNG_VERSION_INFO_ONLY +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED +#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */ +#if PNG_ARM_NEON_OPT > 0 + +#if defined(__clang__) +#define GNUC_VERSION 0 /* not gcc, although it might pretend to be */ +#elif defined(__GNUC__) +#define GNUC_MAJOR (__GNUC__ + 0) +#define GNUC_MINOR (__GNUC_MINOR__ + 0) +#define GNUC_PATCHLEVEL (__GNUC_PATCHLEVEL__ + 0) +#define GNUC_VERSION (GNUC_MAJOR * 10000 + GNUC_MINOR * 100 + GNUC_PATCHLEVEL) +#else +#define GNUC_VERSION 0 /* not gcc */ +#endif + +#if (GNUC_VERSION > 0) && (GNUC_VERSION < 40300) +#error "PNG_ARM_NEON is not supported with gcc versions earlier than 4.3.0" +#elif GNUC_VERSION == 40504 +#error "PNG_ARM_NEON is not supported with gcc version 4.5.4" +#else +#error "Please use 'arm/*_neon_intrinsics.c' for PNG_ARM_NEON support" +#endif + +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 */ +#endif /* READ */ From 532fec021404a5f5ceda068d176fd2ab1cd1955c Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 3 Sep 2024 14:48:50 +0300 Subject: [PATCH 026/112] ci: Fix the verification of the msys2 toolchain on AppVeyor CI Initialize the arch-specific MSYSTEM environment variable, to ensure that msys2 bash picks up and executes /etc/profile correctly. Install and use the host-specific cmake and ninja, to ensure that msys2 cmake picks up the host-specific zlib build correctly. --- .appveyor.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ddeb4ecf59..ee3d27ad34 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -48,6 +48,7 @@ install: - 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe integrate install' - 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows' - 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe integrate install' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\pacman.exe -S --noconfirm mingw-w64-%ARCH%-cmake mingw-w64-%ARCH%-ninja' before_build: - 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_GENERATOR=Visual Studio 17 2022' @@ -58,11 +59,11 @@ before_build: - 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_VARS=-DPNG_TESTS=0' - 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_GENERATOR=Ninja' - 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake' - - 'if "%TOOLCHAIN%"=="llvm" set CI_CC=clang.exe' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" set CI_CMAKE_GENERATOR=Unix Makefiles' - - 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="i686" set PATH=C:\msys64\mingw32\bin;%PATH%' - - 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="x86_64" set PATH=C:\msys64\mingw64\bin;%PATH%' - - 'if "%TOOLCHAIN%"=="msys2" set CI_CC=%ARCH%-w64-mingw32-gcc.exe' + - 'if "%TOOLCHAIN%"=="llvm" set CI_CC=clang' + - 'if "%TOOLCHAIN%"=="msys2" set CI_CMAKE_GENERATOR=Ninja' + - 'if "%TOOLCHAIN%"=="msys2" set CI_CC=gcc' + - 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="i686" set MSYSTEM=MINGW32' + - 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="x86_64" set MSYSTEM=MINGW64' - 'set CI_CMAKE_BUILD_FLAGS=-j2' - 'set CI_CTEST_FLAGS=-j2' - 'set CI_MAKE_FLAGS=-j2' @@ -77,3 +78,4 @@ build_script: cache: - C:\tools\vcpkg\installed + - C:\msys64\var\cache\pacman From 33ef48b6d65ebf47bc0c60988a430706f586321b Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Wed, 4 Sep 2024 18:32:03 +0300 Subject: [PATCH 027/112] cmake: Fix the handling of PNG_HARDWARE_OPTIMIZATIONS on FreeBSD/amd64 Because of a missing "amd64" string (in lowercase) in a regex match, the CMake build was unable to pick up the PNG_HARDWARE_OPTIMIZATIONS flag on FreeBSD/amd64 (and possibly other amd64 systems as well). Rename the target arch variable from TARGET_ARCH to a more idiomatic PNG_TARGET_ARCHITECTURE, and set it to an always-lowercase string. The follow-on checks are now simpler and easier to get right. --- CMakeLists.txt | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cb4dedf6a..e154002650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,21 @@ endif() option(PNG_DEBUG "Enable debug output" OFF) option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) +# Initialize and show the target architecture variable PNG_TARGET_ARCHITECTURE. +# +# NOTE: +# On macOS, CMake sets CMAKE_SYSTEM_PROCESSOR to either "x86_64" or "arm64", +# based upon the OS architecture, not the target architecture. As such, we need +# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to +# enable. Note that this will fail if you attempt to build a universal binary +# in a single CMake invocation. +if (APPLE AND CMAKE_OSX_ARCHITECTURES) + string(TOLOWER "${CMAKE_OSX_ARCHITECTURES}" PNG_TARGET_ARCHITECTURE) +else() + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" PNG_TARGET_ARCHITECTURE) +endif() +message(STATUS "Building for target architecture: ${PNG_TARGET_ARCHITECTURE}") + # Allow the users to specify a custom location of zlib. # This option is deprecated, and no longer needed with CMake 3.12 and newer. # Under the CMake policy CMP0074, if zlib is being built alongside libpng as a @@ -119,22 +134,11 @@ else() # libm is not available or not needed. endif() -# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS, -# based upon the OS architecture, not the target architecture. As such, we need -# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to -# enable. Note that this will fail if you attempt to build a universal binary in -# a single CMake invocation. -if (APPLE AND CMAKE_OSX_ARCHITECTURES) - set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES}) -else() - set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) -endif() - if(PNG_HARDWARE_OPTIMIZATIONS) # Set definitions and sources for ARM. -if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)") - if(TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") + if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm64|aarch64)") set(PNG_ARM_NEON_POSSIBLE_VALUES on off) set(PNG_ARM_NEON "on" CACHE STRING "Enable ARM NEON optimizations: on|off; on is default") @@ -164,7 +168,7 @@ if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)") endif() # Set definitions and sources for PowerPC. -if(TARGET_ARCH MATCHES "^(powerpc|ppc64)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default") @@ -186,7 +190,7 @@ if(TARGET_ARCH MATCHES "^(powerpc|ppc64)") endif() # Set definitions and sources for Intel. -if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default") @@ -208,7 +212,7 @@ if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)") endif() # Set definitions and sources for MIPS. -if(TARGET_ARCH MATCHES "^(mipsel|mips64el)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default") @@ -255,7 +259,7 @@ if(TARGET_ARCH MATCHES "^(mipsel|mips64el)") endif() # Set definitions and sources for LoongArch. -if(TARGET_ARCH MATCHES "^(loongarch)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") include(CheckCCompilerFlag) set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off) set(PNG_LOONGARCH_LSX "on" @@ -286,27 +290,27 @@ endif() else(PNG_HARDWARE_OPTIMIZATIONS) # Set definitions and sources for ARM. -if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") add_definitions(-DPNG_ARM_NEON_OPT=0) endif() # Set definitions and sources for PowerPC. -if(TARGET_ARCH MATCHES "^(powerpc|ppc64)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") add_definitions(-DPNG_POWERPC_VSX_OPT=0) endif() # Set definitions and sources for Intel. -if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") add_definitions(-DPNG_INTEL_SSE_OPT=0) endif() # Set definitions and sources for MIPS. -if(TARGET_ARCH MATCHES "^(mipsel|mips64el)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") add_definitions(-DPNG_MIPS_MSA_OPT=0) endif() # Set definitions and sources for LoongArch. -if(TARGET_ARCH MATCHES "^(loongarch)") +if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) endif() From 43d6ad3e15a95deeaa80a0659ddf5a56bdb95db7 Mon Sep 17 00:00:00 2001 From: Eric Riff Date: Wed, 4 Sep 2024 19:29:14 +0000 Subject: [PATCH 028/112] cmake: Honor CMAKE_SYSROOT if set Signed-off-by: Cosmin Truta --- scripts/cmake/AUTHORS.md | 1 + scripts/cmake/genout.cmake.in | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index 641dde265f..b4b61cfc0e 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -20,6 +20,7 @@ Author List * Cosmin Truta * Dan Rosser * David Callu + * Eric Riff * Gianfranco Costamagna * Gleb Mazovetskiy * Glenn Randers-Pehrson diff --git a/scripts/cmake/genout.cmake.in b/scripts/cmake/genout.cmake.in index ab82859689..d4a333282f 100644 --- a/scripts/cmake/genout.cmake.in +++ b/scripts/cmake/genout.cmake.in @@ -19,6 +19,7 @@ set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@") set(AWK "@AWK@") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") set(CMAKE_C_FLAGS @CMAKE_C_FLAGS@) +set(CMAKE_SYSROOT @CMAKE_SYSROOT@) set(INCDIR "@CMAKE_CURRENT_BINARY_DIR@") set(PNG_PREFIX "@PNG_PREFIX@") set(PNGLIB_MAJOR "@PNGLIB_MAJOR@") @@ -38,6 +39,10 @@ if(APPLE) endif() endif() +if(CMAKE_SYSROOT) + set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} "--sysroot=${CMAKE_SYSROOT}") +endif() + get_filename_component(INPUTEXT "${INPUT}" EXT) get_filename_component(OUTPUTEXT "${OUTPUT}" EXT) get_filename_component(INPUTBASE "${INPUT}" NAME_WE) From 7e18d142966045bb331e7af20cbdae4e92383822 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 5 Sep 2024 22:23:30 +0300 Subject: [PATCH 029/112] ci: Add the targets/ subdirectory to facilitate cross-platform testing Considering that a non-trivial amount of libpng code is arch-specific, we should perform cross-platform builds (with cross-platform toolchains) and test runs (on emulated architectures) in our routine verification. The content of ci/targets/ shall consist of target description files, written in the standard shell language. These files may be source'd as needed, before running the verification scripts ci/ci_verify_*.sh. Here is the initial list of target systems: Android, Cygwin, FreeBSD, Linux, MSDOS, Windows. And here is the initial list of target architectures: ARM, MIPS, PowerPC, RISC-V, x86. --- .../android/ci_env.aarch64-linux-android.sh | 16 ++++++++++++++ .../ci_env.armv7a-linux-androideabi.sh | 16 ++++++++++++++ .../android/ci_env.i686-linux-android.sh | 16 ++++++++++++++ .../android/ci_env.x86_64-linux-android.sh | 16 ++++++++++++++ ci/targets/cygwin/ci_env.i686-pc-cygwin.sh | 18 ++++++++++++++++ ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh | 18 ++++++++++++++++ .../darwin/ci_env.arm64-apple-darwin.sh | 15 +++++++++++++ .../darwin/ci_env.x86_64-apple-darwin.sh | 15 +++++++++++++ .../freebsd/ci_env.aarch64-unknown-freebsd.sh | 14 +++++++++++++ .../freebsd/ci_env.i686-unknown-freebsd.sh | 14 +++++++++++++ .../freebsd/ci_env.riscv64-unknown-freebsd.sh | 14 +++++++++++++ .../freebsd/ci_env.x86_64-unknown-freebsd.sh | 14 +++++++++++++ ci/targets/linux/ci_env.aarch64-linux-gnu.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.arm-linux-gnueabi.sh | 21 +++++++++++++++++++ .../linux/ci_env.arm-linux-gnueabihf.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.i686-linux-gnu.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.mips-linux-gnu.sh | 21 +++++++++++++++++++ .../linux/ci_env.mips64-linux-gnuabi64.sh | 21 +++++++++++++++++++ .../linux/ci_env.mips64el-linux-gnuabi64.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.mipsel-linux-gnu.sh | 21 +++++++++++++++++++ .../linux/ci_env.mipsisa32r6-linux-gnu.sh | 21 +++++++++++++++++++ .../linux/ci_env.mipsisa32r6el-linux-gnu.sh | 21 +++++++++++++++++++ .../ci_env.mipsisa64r6-linux-gnuabi64.sh | 21 +++++++++++++++++++ .../ci_env.mipsisa64r6el-linux-gnuabi64.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.powerpc-linux-gnu.sh | 21 +++++++++++++++++++ .../linux/ci_env.powerpc64-linux-gnu.sh | 21 +++++++++++++++++++ .../linux/ci_env.powerpc64le-linux-gnu.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.riscv64-linux-gnu.sh | 21 +++++++++++++++++++ ci/targets/linux/ci_env.x86_64-linux-gnu.sh | 21 +++++++++++++++++++ .../msdos/ci_env.i386-pc-msdoswatcom.sh | 18 ++++++++++++++++ ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh | 18 ++++++++++++++++ ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh | 19 +++++++++++++++++ .../windows/ci_env.aarch64-windows-llvm.sh | 18 ++++++++++++++++ ci/targets/windows/ci_env.i686-w64-mingw32.sh | 21 +++++++++++++++++++ .../windows/ci_env.i686-windows-llvm.sh | 18 ++++++++++++++++ .../windows/ci_env.x86_64-w64-mingw32.sh | 21 +++++++++++++++++++ .../windows/ci_env.x86_64-windows-llvm.sh | 18 ++++++++++++++++ 37 files changed, 694 insertions(+) create mode 100644 ci/targets/android/ci_env.aarch64-linux-android.sh create mode 100644 ci/targets/android/ci_env.armv7a-linux-androideabi.sh create mode 100644 ci/targets/android/ci_env.i686-linux-android.sh create mode 100644 ci/targets/android/ci_env.x86_64-linux-android.sh create mode 100644 ci/targets/cygwin/ci_env.i686-pc-cygwin.sh create mode 100644 ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh create mode 100644 ci/targets/darwin/ci_env.arm64-apple-darwin.sh create mode 100644 ci/targets/darwin/ci_env.x86_64-apple-darwin.sh create mode 100644 ci/targets/freebsd/ci_env.aarch64-unknown-freebsd.sh create mode 100644 ci/targets/freebsd/ci_env.i686-unknown-freebsd.sh create mode 100644 ci/targets/freebsd/ci_env.riscv64-unknown-freebsd.sh create mode 100644 ci/targets/freebsd/ci_env.x86_64-unknown-freebsd.sh create mode 100644 ci/targets/linux/ci_env.aarch64-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.arm-linux-gnueabi.sh create mode 100644 ci/targets/linux/ci_env.arm-linux-gnueabihf.sh create mode 100644 ci/targets/linux/ci_env.i686-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.mips-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.mips64-linux-gnuabi64.sh create mode 100644 ci/targets/linux/ci_env.mips64el-linux-gnuabi64.sh create mode 100644 ci/targets/linux/ci_env.mipsel-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.mipsisa32r6-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.mipsisa32r6el-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.mipsisa64r6-linux-gnuabi64.sh create mode 100644 ci/targets/linux/ci_env.mipsisa64r6el-linux-gnuabi64.sh create mode 100644 ci/targets/linux/ci_env.powerpc-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.powerpc64-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.powerpc64le-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.riscv64-linux-gnu.sh create mode 100644 ci/targets/linux/ci_env.x86_64-linux-gnu.sh create mode 100644 ci/targets/msdos/ci_env.i386-pc-msdoswatcom.sh create mode 100644 ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh create mode 100644 ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh create mode 100644 ci/targets/windows/ci_env.aarch64-windows-llvm.sh create mode 100644 ci/targets/windows/ci_env.i686-w64-mingw32.sh create mode 100644 ci/targets/windows/ci_env.i686-windows-llvm.sh create mode 100644 ci/targets/windows/ci_env.x86_64-w64-mingw32.sh create mode 100644 ci/targets/windows/ci_env.x86_64-windows-llvm.sh diff --git a/ci/targets/android/ci_env.aarch64-linux-android.sh b/ci/targets/android/ci_env.aarch64-linux-android.sh new file mode 100644 index 0000000000..fef0ef138f --- /dev/null +++ b/ci/targets/android/ci_env.aarch64-linux-android.sh @@ -0,0 +1,16 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=aarch64 +export CI_TARGET_ARCHVER=aarch64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=android +export CI_TARGET_ABIVER=android29 + +export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" diff --git a/ci/targets/android/ci_env.armv7a-linux-androideabi.sh b/ci/targets/android/ci_env.armv7a-linux-androideabi.sh new file mode 100644 index 0000000000..c27bd121eb --- /dev/null +++ b/ci/targets/android/ci_env.armv7a-linux-androideabi.sh @@ -0,0 +1,16 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=arm +export CI_TARGET_ARCHVER=armv7a +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=androideabi +export CI_TARGET_ABIVER=androideabi29 + +export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" diff --git a/ci/targets/android/ci_env.i686-linux-android.sh b/ci/targets/android/ci_env.i686-linux-android.sh new file mode 100644 index 0000000000..88e3690824 --- /dev/null +++ b/ci/targets/android/ci_env.i686-linux-android.sh @@ -0,0 +1,16 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i686 +export CI_TARGET_ARCHVER=i686 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=android +export CI_TARGET_ABIVER=android29 + +export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" diff --git a/ci/targets/android/ci_env.x86_64-linux-android.sh b/ci/targets/android/ci_env.x86_64-linux-android.sh new file mode 100644 index 0000000000..87460c8885 --- /dev/null +++ b/ci/targets/android/ci_env.x86_64-linux-android.sh @@ -0,0 +1,16 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_ARCHVER=x86_64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=android +export CI_TARGET_ABIVER=android29 + +export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" diff --git a/ci/targets/cygwin/ci_env.i686-pc-cygwin.sh b/ci/targets/cygwin/ci_env.i686-pc-cygwin.sh new file mode 100644 index 0000000000..66b99997b9 --- /dev/null +++ b/ci/targets/cygwin/ci_env.i686-pc-cygwin.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i686 +export CI_TARGET_SYSTEM=cygwin + +export CI_CC="$CI_TARGET_ARCH-pc-$CI_TARGET_SYSTEM-gcc" +export CI_AR="$CI_CC-ar" +export CI_RANLIB="$CI_CC-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=CYGWIN + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh b/ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh new file mode 100644 index 0000000000..78f8c25ff8 --- /dev/null +++ b/ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_SYSTEM=cygwin + +export CI_CC="$CI_TARGET_ARCH-pc-$CI_TARGET_SYSTEM-gcc" +export CI_AR="$CI_CC-ar" +export CI_RANLIB="$CI_CC-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=CYGWIN + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/darwin/ci_env.arm64-apple-darwin.sh b/ci/targets/darwin/ci_env.arm64-apple-darwin.sh new file mode 100644 index 0000000000..c54d8c7605 --- /dev/null +++ b/ci/targets/darwin/ci_env.arm64-apple-darwin.sh @@ -0,0 +1,15 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=arm64 +export CI_TARGET_SYSTEM=darwin + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Darwin + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH + -DCMAKE_OSX_ARCHITECTURES=$CI_TARGET_ARCH +" diff --git a/ci/targets/darwin/ci_env.x86_64-apple-darwin.sh b/ci/targets/darwin/ci_env.x86_64-apple-darwin.sh new file mode 100644 index 0000000000..ee87711d54 --- /dev/null +++ b/ci/targets/darwin/ci_env.x86_64-apple-darwin.sh @@ -0,0 +1,15 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_SYSTEM=darwin + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Darwin + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH + -DCMAKE_OSX_ARCHITECTURES=$CI_TARGET_ARCH +" diff --git a/ci/targets/freebsd/ci_env.aarch64-unknown-freebsd.sh b/ci/targets/freebsd/ci_env.aarch64-unknown-freebsd.sh new file mode 100644 index 0000000000..42235de7d0 --- /dev/null +++ b/ci/targets/freebsd/ci_env.aarch64-unknown-freebsd.sh @@ -0,0 +1,14 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=aarch64 +export CI_TARGET_SYSTEM=freebsd + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=FreeBSD + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/freebsd/ci_env.i686-unknown-freebsd.sh b/ci/targets/freebsd/ci_env.i686-unknown-freebsd.sh new file mode 100644 index 0000000000..3d188f8da1 --- /dev/null +++ b/ci/targets/freebsd/ci_env.i686-unknown-freebsd.sh @@ -0,0 +1,14 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i686 +export CI_TARGET_SYSTEM=freebsd + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=FreeBSD + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/freebsd/ci_env.riscv64-unknown-freebsd.sh b/ci/targets/freebsd/ci_env.riscv64-unknown-freebsd.sh new file mode 100644 index 0000000000..0a02cde4f6 --- /dev/null +++ b/ci/targets/freebsd/ci_env.riscv64-unknown-freebsd.sh @@ -0,0 +1,14 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=riscv64 +export CI_TARGET_SYSTEM=freebsd + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=FreeBSD + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/freebsd/ci_env.x86_64-unknown-freebsd.sh b/ci/targets/freebsd/ci_env.x86_64-unknown-freebsd.sh new file mode 100644 index 0000000000..c77ace53ba --- /dev/null +++ b/ci/targets/freebsd/ci_env.x86_64-unknown-freebsd.sh @@ -0,0 +1,14 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_SYSTEM=freebsd + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=FreeBSD + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.aarch64-linux-gnu.sh b/ci/targets/linux/ci_env.aarch64-linux-gnu.sh new file mode 100644 index 0000000000..cb85bc6d8b --- /dev/null +++ b/ci/targets/linux/ci_env.aarch64-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=aarch64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.arm-linux-gnueabi.sh b/ci/targets/linux/ci_env.arm-linux-gnueabi.sh new file mode 100644 index 0000000000..45504dfcd5 --- /dev/null +++ b/ci/targets/linux/ci_env.arm-linux-gnueabi.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=arm +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnueabi + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.arm-linux-gnueabihf.sh b/ci/targets/linux/ci_env.arm-linux-gnueabihf.sh new file mode 100644 index 0000000000..3eb9d1892d --- /dev/null +++ b/ci/targets/linux/ci_env.arm-linux-gnueabihf.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=arm +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnueabihf + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.i686-linux-gnu.sh b/ci/targets/linux/ci_env.i686-linux-gnu.sh new file mode 100644 index 0000000000..a5efd9f7fe --- /dev/null +++ b/ci/targets/linux/ci_env.i686-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i686 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mips-linux-gnu.sh b/ci/targets/linux/ci_env.mips-linux-gnu.sh new file mode 100644 index 0000000000..532c93c04c --- /dev/null +++ b/ci/targets/linux/ci_env.mips-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mips +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mips64-linux-gnuabi64.sh b/ci/targets/linux/ci_env.mips64-linux-gnuabi64.sh new file mode 100644 index 0000000000..348d2b8006 --- /dev/null +++ b/ci/targets/linux/ci_env.mips64-linux-gnuabi64.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mips64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnuabi64 + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mips64el-linux-gnuabi64.sh b/ci/targets/linux/ci_env.mips64el-linux-gnuabi64.sh new file mode 100644 index 0000000000..e264913d8e --- /dev/null +++ b/ci/targets/linux/ci_env.mips64el-linux-gnuabi64.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mips64el +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnuabi64 + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mipsel-linux-gnu.sh b/ci/targets/linux/ci_env.mipsel-linux-gnu.sh new file mode 100644 index 0000000000..f99050f10e --- /dev/null +++ b/ci/targets/linux/ci_env.mipsel-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mipsel +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mipsisa32r6-linux-gnu.sh b/ci/targets/linux/ci_env.mipsisa32r6-linux-gnu.sh new file mode 100644 index 0000000000..0a32867f63 --- /dev/null +++ b/ci/targets/linux/ci_env.mipsisa32r6-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mipsisa32r6 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mipsisa32r6el-linux-gnu.sh b/ci/targets/linux/ci_env.mipsisa32r6el-linux-gnu.sh new file mode 100644 index 0000000000..ca06009300 --- /dev/null +++ b/ci/targets/linux/ci_env.mipsisa32r6el-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mipsisa32r6el +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mipsisa64r6-linux-gnuabi64.sh b/ci/targets/linux/ci_env.mipsisa64r6-linux-gnuabi64.sh new file mode 100644 index 0000000000..6c1138fe62 --- /dev/null +++ b/ci/targets/linux/ci_env.mipsisa64r6-linux-gnuabi64.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mipsisa64r6 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnuabi64 + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.mipsisa64r6el-linux-gnuabi64.sh b/ci/targets/linux/ci_env.mipsisa64r6el-linux-gnuabi64.sh new file mode 100644 index 0000000000..f64f2fcf44 --- /dev/null +++ b/ci/targets/linux/ci_env.mipsisa64r6el-linux-gnuabi64.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=mipsisa64r6el +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnuabi64 + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.powerpc-linux-gnu.sh b/ci/targets/linux/ci_env.powerpc-linux-gnu.sh new file mode 100644 index 0000000000..e50d9b502a --- /dev/null +++ b/ci/targets/linux/ci_env.powerpc-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=powerpc +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.powerpc64-linux-gnu.sh b/ci/targets/linux/ci_env.powerpc64-linux-gnu.sh new file mode 100644 index 0000000000..15e60adf27 --- /dev/null +++ b/ci/targets/linux/ci_env.powerpc64-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=powerpc64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.powerpc64le-linux-gnu.sh b/ci/targets/linux/ci_env.powerpc64le-linux-gnu.sh new file mode 100644 index 0000000000..be0e2ca69c --- /dev/null +++ b/ci/targets/linux/ci_env.powerpc64le-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=powerpc64le +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.riscv64-linux-gnu.sh b/ci/targets/linux/ci_env.riscv64-linux-gnu.sh new file mode 100644 index 0000000000..d8518d97fe --- /dev/null +++ b/ci/targets/linux/ci_env.riscv64-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=riscv64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/linux/ci_env.x86_64-linux-gnu.sh b/ci/targets/linux/ci_env.x86_64-linux-gnu.sh new file mode 100644 index 0000000000..3263fbff8a --- /dev/null +++ b/ci/targets/linux/ci_env.x86_64-linux-gnu.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_SYSTEM=linux +export CI_TARGET_ABI=gnu + +export CI_GCC="${CI_GCC-gcc}" + +export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC" +export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar" +export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Linux + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/msdos/ci_env.i386-pc-msdoswatcom.sh b/ci/targets/msdos/ci_env.i386-pc-msdoswatcom.sh new file mode 100644 index 0000000000..59f3bd58fd --- /dev/null +++ b/ci/targets/msdos/ci_env.i386-pc-msdoswatcom.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i386 +export CI_TARGET_SYSTEM=msdoswatcom + +export CI_CC="wcl386" + +# Open Watcom V2 CMake build +# https://github.com/open-watcom/open-watcom-v2/discussions/716 +export CI_CMAKE_GENERATOR="Watcom WMake" +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=DOS +" diff --git a/ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh b/ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh new file mode 100644 index 0000000000..63e6d06767 --- /dev/null +++ b/ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i586 +export CI_TARGET_SYSTEM=msdosdjgpp + +export CI_CC="$CI_TARGET_ARCH-pc-$CI_TARGET_SYSTEM-gcc" +export CI_AR="$CI_CC-ar" +export CI_RANLIB="$CI_CC-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Generic + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh b/ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh new file mode 100644 index 0000000000..3059f18356 --- /dev/null +++ b/ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh @@ -0,0 +1,19 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i86 +export CI_TARGET_SYSTEM=msdoswatcom + +export CI_CC="wcl" + +# Open Watcom V2 CMake build +# https://github.com/open-watcom/open-watcom-v2/discussions/716 +export CI_CMAKE_GENERATOR="Watcom WMake" +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=DOS + -DCMAKE_SYSTEM_PROCESSOR=I86 +" diff --git a/ci/targets/windows/ci_env.aarch64-windows-llvm.sh b/ci/targets/windows/ci_env.aarch64-windows-llvm.sh new file mode 100644 index 0000000000..80244172a3 --- /dev/null +++ b/ci/targets/windows/ci_env.aarch64-windows-llvm.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=aarch64 +export CI_TARGET_SYSTEM=windows + +export CI_CC="clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Windows + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/windows/ci_env.i686-w64-mingw32.sh b/ci/targets/windows/ci_env.i686-w64-mingw32.sh new file mode 100644 index 0000000000..8c83d0f2c6 --- /dev/null +++ b/ci/targets/windows/ci_env.i686-w64-mingw32.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i686 +export CI_TARGET_SYSTEM=mingw32 + +# The output of `uname -s` on MSYS2 is understandable, and so is +# CI_TARGET_SYSTEM above, in simplified form. (See also Cygwin.) +# But aside from that, the Mingw-w64 nomenclature is rather messy. +export CI_CC="$CI_TARGET_ARCH-w64-mingw32-gcc" +export CI_AR="$CI_CC-ar" +export CI_RANLIB="$CI_CC-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Windows + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/windows/ci_env.i686-windows-llvm.sh b/ci/targets/windows/ci_env.i686-windows-llvm.sh new file mode 100644 index 0000000000..3d29f6d558 --- /dev/null +++ b/ci/targets/windows/ci_env.i686-windows-llvm.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=i686 +export CI_TARGET_SYSTEM=windows + +export CI_CC="clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Windows + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/windows/ci_env.x86_64-w64-mingw32.sh b/ci/targets/windows/ci_env.x86_64-w64-mingw32.sh new file mode 100644 index 0000000000..67d83557bd --- /dev/null +++ b/ci/targets/windows/ci_env.x86_64-w64-mingw32.sh @@ -0,0 +1,21 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_SYSTEM=mingw64 + +# The output of `uname -s` on MSYS2 is understandable, and so is +# CI_TARGET_SYSTEM above, in simplified form. (See also Cygwin.) +# But aside from that, the Mingw-w64 nomenclature is rather messy. +export CI_CC="$CI_TARGET_ARCH-w64-mingw32-gcc" +export CI_AR="$CI_CC-ar" +export CI_RANLIB="$CI_CC-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Windows + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" diff --git a/ci/targets/windows/ci_env.x86_64-windows-llvm.sh b/ci/targets/windows/ci_env.x86_64-windows-llvm.sh new file mode 100644 index 0000000000..747f99b214 --- /dev/null +++ b/ci/targets/windows/ci_env.x86_64-windows-llvm.sh @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2024 Cosmin Truta. +# +# Use, modification and distribution are subject to the MIT License. +# Please see the accompanying file LICENSE_MIT.txt +# +# SPDX-License-Identifier: MIT + +export CI_TARGET_ARCH=x86_64 +export CI_TARGET_SYSTEM=windows + +export CI_CC="clang" +export CI_AR="llvm-ar" +export CI_RANLIB="llvm-ranlib" + +export CI_CMAKE_VARS=" + -DCMAKE_SYSTEM_NAME=Windows + -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH +" From 20f819c29e49f4b8c1d38e3f475b82a9cdce0da6 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Tue, 3 Sep 2024 17:11:20 -0700 Subject: [PATCH 030/112] fix: Remove cHRM check to accomodate ACES AP1 ACES AP1 has a red endpoint with a negative Z, this triggers the checks in libpng that ensure that x, y and z (chromaticities) are all >=0. This removes the checks on the sign of the chromaticities since it is valid to use negative values for any of them and converts the "internal" error code return to external (because the internal cases correspond to negative x, y or z.) Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- png.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/png.c b/png.c index 28e5a43e73..84e03b5fd7 100644 --- a/png.c +++ b/png.c @@ -1257,20 +1257,6 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) png_fixed_point red_inverse, green_inverse, blue_scale; png_fixed_point left, right, denominator; - /* Check xy and, implicitly, z. Note that wide gamut color spaces typically - * have end points with 0 tristimulus values (these are impossible end - * points, but they are used to cover the possible colors). We check - * xy->whitey against 5, not 0, to avoid a possible integer overflow. - */ - if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; - if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; - if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1; - if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1; - if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1; - if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1; - if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1; - if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1; - /* The reverse calculation is more difficult because the original tristimulus * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8 * derived values were recorded in the cHRM chunk; @@ -1451,16 +1437,16 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * value of 2 indicates an internal error to the caller. */ if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0) - return 2; + return 1; if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0) - return 2; + return 1; denominator = left - right; /* Now find the red numerator. */ if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) - return 2; + return 1; if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0) - return 2; + return 1; /* Overflow is possible here and it indicates an extreme set of PNG cHRM * chunk values. This calculation actually returns the reciprocal of the @@ -1473,9 +1459,9 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) /* Similarly for green_inverse: */ if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0) - return 2; + return 1; if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) - return 2; + return 1; if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 || green_inverse <= xy->whitey) return 1; From 40878fd6dcc178844a3f6a9ec56fab36394f4334 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Fri, 26 Apr 2024 13:20:18 -0400 Subject: [PATCH 031/112] fix: Restore STDERR in pngtest.c In "test: Add consistency checks for the PNG_LIBPNG_VER* number" [0] the `STDERR` macro was moved from outside an `ifdef` to inside an `ifdef`. This broke the code in the `else` of this `ifdef` which also uses the `STDERR` macro. Move `STDERR` back to where it was to avoid compile errors in the `else` case. [0] https://github.com/pnggroup/libpng/commit/cc8006c48d90cca8bf380fa69469b08f4edb00c5 Fixes: #560 Reviewed-by: Cosmin Truta Signed-off-by: Cosmin Truta --- pngtest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pngtest.c b/pngtest.c index 81da721263..ba2b7463eb 100644 --- a/pngtest.c +++ b/pngtest.c @@ -45,6 +45,11 @@ #include "png.h" +/* This hack was introduced for historical reasons, and we are + * still keeping it in libpng-1.6.x for compatibility reasons. + */ +#define STDERR stdout + /* Generate a compiler error if there is an old png.h in the search path. */ typedef png_libpng_version_1_6_44_git Your_png_h_is_not_version_1_6_44_git; @@ -103,11 +108,6 @@ typedef png_libpng_version_1_6_44_git Your_png_h_is_not_version_1_6_44_git; typedef FILE * png_FILE_p; #endif -/* This hack was introduced for historical reasons, and we are - * still keeping it in libpng-1.6.x for compatibility reasons. - */ -#define STDERR stdout - #ifndef PNG_DEBUG # define PNG_DEBUG 0 #endif From 222086586b7dceeb1c3d2e21b11d4795173fbd6c Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 8 Sep 2024 15:22:58 +0300 Subject: [PATCH 032/112] chore: Pacify editorconfig-checker version 3.0 --- scripts/dfn.awk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/dfn.awk b/scripts/dfn.awk index 0b25c8a372..0b970e0061 100755 --- a/scripts/dfn.awk +++ b/scripts/dfn.awk @@ -75,12 +75,12 @@ $1 ~ /^PNG_DFN_END_SORT/{ if (lineno == "") lineno=NR if (sub(/^[^"]*PNG_DFN *"/,"",line) != 1) { - print "line", lineno ": processing failed:" - print orig - err=1 - next + print "line", lineno ": processing failed:" + print orig + err=1 + next } else { - ++out_count + ++out_count } # Now examine quotes within the value: @@ -94,7 +94,7 @@ $1 ~ /^PNG_DFN_END_SORT/{ # #define first_name John # #define last_name Smith # - # PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'" + # PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'" # # Might get C preprocessed to: # @@ -102,7 +102,7 @@ $1 ~ /^PNG_DFN_END_SORT/{ # # Which this script reduces to: # - # #define name "John Smith" + # #define name "John Smith" # while (1) { # While there is an @" remove it and the next "@ @@ -195,7 +195,7 @@ $1 ~ /^PNG_DFN_END_SORT/{ END{ if (out_count > 0 || err > 0) - exit err + exit err print "no definition lines found" exit 1 From fcdec9c66e1657edca7f0c4f92e952967cf299e9 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 8 Sep 2024 15:35:10 +0300 Subject: [PATCH 033/112] chore: Delete contrib/tools/chkfmt.sh Going forward, we will continue developing and using ci/ci_lint.sh --- contrib/tools/chkfmt.sh | 157 ---------------------------------------- 1 file changed, 157 deletions(-) delete mode 100755 contrib/tools/chkfmt.sh diff --git a/contrib/tools/chkfmt.sh b/contrib/tools/chkfmt.sh deleted file mode 100755 index 8810aa7b5d..0000000000 --- a/contrib/tools/chkfmt.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/sh - -# chkfmt.sh -# -# COPYRIGHT: -# Written by John Cunningham Bowler, 2010. -# Revised by Cosmin Truta, 2022. -# To the extent possible under law, the author has waived all copyright and -# related or neighboring rights to this work. The author published this work -# from the United States. -# -# Check the format of the source files in the current directory: -# -# * The lines should not exceed a predefined maximum length. -# * Tab characters should appear only where necessary (e.g. in makefiles). -# -# Optionally arguments are files or directories to check. -# -# -v: output the long lines (makes fixing them easier) -# -e: spawn an editor for each file that needs a change ($EDITOR must be -# defined). When using -e the script MUST be run from an interactive -# command line. - -script_name=`basename "$0"` - -verbose= -edit= -vers= -test "$1" = "-v" && { - shift - verbose=yes -} -test "$1" = "-e" && { - shift - if test -n "$EDITOR" - then - edit=yes - - # Copy the standard streams for the editor - exec 3>&0 4>&1 5>&2 - else - echo "$script_name -e: EDITOR must be defined" >&2 - exit 1 - fi -} - -# Function to edit a single file - if the file isn't changed ask the user -# whether or not to continue. This stuff only works if the script is run -# from the command line (otherwise, don't specify -e or you will be sorry). -doed(){ - cp "$file" "$file".orig - "$EDITOR" "$file" 0>&3 1>&4 2>&5 3>&- 4>&- 5>&- || exit 1 - if cmp -s "$file".orig "$file" - then - rm "$file".orig - echo -n "$file: file not changed, type anything to continue: " >&5 - read ans 0>&3 - test -n "$ans" || return 1 - fi - return 0 -} - -# In beta versions, the version string which appears in files can be a little -# long and cause spuriously overlong lines. To avoid this, substitute the -# version string with a placeholder string "a.b.cc" before checking for long -# lines. -# (Starting from libpng version 1.6.36, we switched to a conventional Git -# workflow, and we are no longer publishing beta versions.) -if test -r png.h -then - vers="`sed -n -e \ - 's/^#define PNG_LIBPNG_VER_STRING .\([0-9]\.[0-9]\.[0-9][0-9a-z]*\).$/\1/p' \ - png.h`" - echo "$script_name: checking version $vers" -fi -if test -z "$vers" -then - echo "$script_name: png.h not found, ignoring version number" >&2 -fi - -test -n "$1" || set -- . -find "$@" \( -type d \( -name '.git' -o -name '.libs' -o -name 'projects' \) \ - -prune \) -o \( -type f \ - ! -name '*.[oa]' ! -name '*.l[oa]' ! -name '*.png' ! -name '*.out' \ - ! -name '*.jpg' ! -name '*.patch' ! -name '*.obj' ! -name '*.exe' \ - ! -name '*.com' ! -name '*.tar.*' ! -name '*.zip' ! -name '*.ico' \ - ! -name '*.res' ! -name '*.rc' ! -name '*.mms' ! -name '*.rej' \ - ! -name '*.dsp' ! -name '*.orig' ! -name '*.dfn' ! -name '*.swp' \ - ! -name '~*' ! -name '*.3' \ - ! -name 'missing' ! -name 'mkinstalldirs' ! -name 'depcomp' \ - ! -name 'aclocal.m4' ! -name 'install-sh' ! -name 'Makefile.in' \ - ! -name 'ltmain.sh' ! -name 'config*' -print \) | { - st=0 - while read file - do - case "$file" in - *.mak|*[Mm]akefile.*|*[Mm]akefile) - # Makefiles require tabs, dependency lines can be this long. - check_tabs= - line_length=100;; - *.awk) - # Allow literal tabs. - check_tabs= - # Mainframe line printer, anyone? - line_length=132;; - */ci_*.sh) - check_tabs=yes - line_length=100;; - *contrib/*/*.[ch]) - check_tabs=yes - line_length=100;; - *) - check_tabs=yes - line_length=80;; - esac - - # Note that vers can only contain 0-9, . and a-z - if test -n "$vers" - then - sed -e "s/$vers/a.b.cc/g" "$file" >"$file".$$ - else - cp "$file" "$file".$$ - fi - splt="`fold -$line_length "$file".$$ | diff -c "$file".$$ -`" - rm "$file".$$ - - if test -n "$splt" - then - echo "$file: lines too long" - st=1 - if test -n "$EDITOR" -a -n "$edit" - then - doed "$file" || exit 1 - elif test -n "$verbose" - then - echo "$splt" - fi - fi - if test -n "$check_tabs" - then - tab="`tr -c -d '\t' <"$file"`" - if test -n "$tab" - then - echo "$file: file contains tab characters" - st=1 - if test -n "$EDITOR" -a -n "$edit" - then - doed "$file" || exit 1 - elif test -n "$verbose" - then - echo "$splt" - fi - fi - fi - done - exit $st -} From 53a7f4e3204a139be5fa6b8999a67f691df8245b Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 8 Sep 2024 15:58:08 +0300 Subject: [PATCH 034/112] ci: Simplify the Travis CI configuration matrix Going forward, we will continue to verify the cmake build and the configure build with the hardware optimizations enabled by default, and the makefile build with the hardware optimizations disabled by default. The Travis CI configuration file is simpler, and, more importantly, the Travis CI verification process will be shorter and cheaper. --- .travis.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8adbbd4af..f14e7c1cad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,19 +11,13 @@ os: - osx env: - - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=ON" - - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=OFF" - - AUTOMATION=configure CI_CONFIGURE_FLAGS="--enable-hardware-optimizations" - - AUTOMATION=configure CI_CONFIGURE_FLAGS="--disable-hardware-optimizations" + - AUTOMATION=cmake + - AUTOMATION=configure - AUTOMATION=makefiles -matrix: - include: - - os: osx - env: AUTOMATION=cmake CI_CMAKE_GENERATOR=Xcode - before_script: - 'if test "$TRAVIS_OS_NAME" = "linux"; then export CI_CC="gcc"; else export CI_CC="clang"; fi' + - 'if test "$TRAVIS_OS_NAME" = "osx"; then export CI_CMAKE_GENERATOR="Xcode"; fi' - 'if test "$TRAVIS_OS_NAME" != "osx"; then export CI_SANITIZERS="address,undefined"; fi' - 'export CI_MAKEFILES="scripts/makefile.$CI_CC scripts/makefile.std"' - 'export CI_MAKE_FLAGS=-j2' From 0e204b736440719f41cf3eb5d13a889cdca1e3d4 Mon Sep 17 00:00:00 2001 From: Benjamin Buch Date: Fri, 1 Mar 2024 13:14:17 +0100 Subject: [PATCH 035/112] build: Add a CMake config file compatible with the FindPNG module Co-authored-by: Cosmin Truta Signed-off-by: Cosmin Truta --- CMakeLists.txt | 24 ++++++++++++++++++++++++ scripts/cmake/PNGConfig.cmake | 15 +++++++++++++++ scripts/cmake/README.md | 1 + 3 files changed, 40 insertions(+) create mode 100644 scripts/cmake/PNGConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e154002650..e0d0369501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1129,6 +1129,30 @@ if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) FILE libpng${PNGLIB_ABI_VERSION}.cmake) endif() +# Create a CMake Config File that can be used via find_package(PNG CONFIG) +if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL) + install(TARGETS ${PNG_LIBRARY_TARGETS} + EXPORT PNGTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + include(CMakePackageConfigHelpers) + write_basic_package_version_file(PNGConfigVersion.cmake + VERSION ${PNGLIB_VERSION} + COMPATIBILITY SameMinorVersion) + + install(EXPORT PNGTargets + FILE PNGTargets.cmake + NAMESPACE PNG:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG) + + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/PNGConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG) +endif() + # TODO: Create MSVC import lib for MinGW-compiled shared lib. # pexports libpng.dll > libpng.def # lib /def:libpng.def /machine:x86 diff --git a/scripts/cmake/PNGConfig.cmake b/scripts/cmake/PNGConfig.cmake new file mode 100644 index 0000000000..3b6f646de7 --- /dev/null +++ b/scripts/cmake/PNGConfig.cmake @@ -0,0 +1,15 @@ +include(CMakeFindDependencyMacro) + +find_dependency(ZLIB REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/PNGTargets.cmake") + +if(NOT TARGET PNG::PNG) + if(TARGET PNG::png_shared) + add_library(PNG::PNG INTERFACE IMPORTED) + target_link_libraries(PNG::PNG INTERFACE PNG::png_shared) + elseif(TARGET PNG::png_static) + add_library(PNG::PNG INTERFACE IMPORTED) + target_link_libraries(PNG::PNG INTERFACE PNG::png_static) + endif() +endif() diff --git a/scripts/cmake/README.md b/scripts/cmake/README.md index ca418893a9..18e7107175 100644 --- a/scripts/cmake/README.md +++ b/scripts/cmake/README.md @@ -20,6 +20,7 @@ File List CMakeLists.txt ==> The main CMake lists file scripts/cmake/AUTHORS.md ==> The Authors file scripts/cmake/README.md ==> This file + scripts/cmake/PNGConfig.cmake ==> Config file for FindPNG scripts/cmake/genchk.cmake.in ==> Template for genchk.cmake scripts/cmake/genout.cmake.in ==> Template for genout.cmake scripts/cmake/gensrc.cmake.in ==> Template for gensrc.cmake From 68ba4f1f7de1905956a7220fa9d99deaf6cfa71b Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Tue, 2 Jul 2024 23:27:27 +0300 Subject: [PATCH 036/112] oss-fuzz: Add fuzzing targets for simplified READ API New target added to libpng_read_fuzzer.cc for simplified READ API. --- contrib/oss-fuzz/libpng_read_fuzzer.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.cc b/contrib/oss-fuzz/libpng_read_fuzzer.cc index 0190cf7865..ad9f9adc6a 100644 --- a/contrib/oss-fuzz/libpng_read_fuzzer.cc +++ b/contrib/oss-fuzz/libpng_read_fuzzer.cc @@ -204,5 +204,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { png_read_end(png_handler.png_ptr, png_handler.end_info_ptr); PNG_CLEANUP + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED + // Simplified READ API + png_image image; + memset(&image, 0, (sizeof image)); + image.version = PNG_IMAGE_VERSION; + + if (!png_image_begin_read_from_memory(&image, data, size)) { + return 0; + } + + image.format = PNG_FORMAT_RGBA; + std::vector buffer(PNG_IMAGE_SIZE(image)); + png_image_finish_read(&image, NULL, buffer.data(), 0, NULL); +#endif + return 0; } From 1964d560e96c6d14af59a3e8a80299a09a875148 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 10 Sep 2024 19:15:13 +0300 Subject: [PATCH 037/112] Deprecate PNGARG and remove all of its remaining uses --- png.h | 2 +- pngconf.h | 6 +++--- pngerror.c | 9 +++++---- pngtest.c | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/png.h b/png.h index b71bd7064a..6ac0171d9e 100644 --- a/png.h +++ b/png.h @@ -824,7 +824,7 @@ typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, * your compiler. This may be very difficult - try using a different compiler * to build the library! */ -PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); +PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), (jmp_buf, int), typedef); #endif /* Transform masks for the high-level interface */ diff --git a/pngconf.h b/pngconf.h index 175a36c6f1..41785a3ca2 100644 --- a/pngconf.h +++ b/pngconf.h @@ -88,7 +88,7 @@ /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect * against legacy (pre ISOC90) compilers that did not understand function - * prototypes. It is not required for modern C compilers. + * prototypes. [Deprecated.] */ #ifndef PNGARG # define PNGARG(arglist) arglist @@ -298,7 +298,7 @@ #ifndef PNG_EXPORTA # define PNG_EXPORTA(ordinal, type, name, args, attributes) \ - PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ + PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), args, \ PNG_LINKAGE_API attributes) #endif @@ -316,7 +316,7 @@ #endif #ifndef PNG_CALLBACK -# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) +# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) args #endif /* Support for compiler specific function attributes. These are used diff --git a/pngerror.c b/pngerror.c index 29ebda7943..1babf9f8d2 100644 --- a/pngerror.c +++ b/pngerror.c @@ -20,13 +20,14 @@ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, - png_const_charp error_message)),PNG_NORETURN); +static PNG_FUNCTION(void /* PRIVATE */, +png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), + PNG_NORETURN); #ifdef PNG_WARNINGS_SUPPORTED static void /* PRIVATE */ -png_default_warning PNGARG((png_const_structrp png_ptr, - png_const_charp warning_message)); +png_default_warning(png_const_structrp png_ptr, + png_const_charp warning_message); #endif /* WARNINGS */ /* This function is called whenever there is a fatal error. This function diff --git a/pngtest.c b/pngtest.c index ba2b7463eb..a4621a60f3 100644 --- a/pngtest.c +++ b/pngtest.c @@ -518,9 +518,9 @@ static int maximum_allocation = 0; static int total_allocation = 0; static int num_allocations = 0; -png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr, - png_alloc_size_t size)); -void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); +png_voidp PNGCBAPI png_debug_malloc(png_structp png_ptr, + png_alloc_size_t size); +void PNGCBAPI png_debug_free(png_structp png_ptr, png_voidp ptr); png_voidp PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) From 1d1cc9ae18f677201bf7e47928c30562df967756 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 17 Apr 2024 12:32:45 +0200 Subject: [PATCH 038/112] cmake: Fix an error in the declaration of target include directories Properly declare target include directories for generated includes. Previously the non targeted `include_directories()` was used, which had issue when using the `png_static` target in a submodule. Signed-off-by: Cosmin Truta --- CMakeLists.txt | 6 ++++-- scripts/cmake/AUTHORS.md | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d0369501..ce8c054a0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,8 +363,6 @@ else() message(STATUS "Could not find an AWK-compatible program") endif() -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(NOT AWK OR ANDROID OR IOS) # No awk available to generate sources; use pre-built pnglibconf.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt @@ -715,6 +713,8 @@ if(PNG_SHARED) endif() target_include_directories(png_shared PUBLIC $) + target_include_directories(png_shared + PUBLIC $) target_include_directories(png_shared SYSTEM INTERFACE $) target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY}) @@ -729,6 +729,8 @@ if(PNG_STATIC) DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_include_directories(png_static PUBLIC $) + target_include_directories(png_static + PUBLIC $) target_include_directories(png_static SYSTEM INTERFACE $) target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index b4b61cfc0e..c098217865 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -21,6 +21,7 @@ Author List * Dan Rosser * David Callu * Eric Riff + * Erik Scholz * Gianfranco Costamagna * Gleb Mazovetskiy * Glenn Randers-Pehrson From 843dbb75799178972c5b6a7951533375b34e6241 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 10 Sep 2024 22:41:03 +0300 Subject: [PATCH 039/112] Revert "cmake: Fix an error in the declaration of target include directories" This reverts commit 1d1cc9ae18f677201bf7e47928c30562df967756. The verification has failed. (Oopsie!) --- CMakeLists.txt | 6 ++---- scripts/cmake/AUTHORS.md | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce8c054a0f..e0d0369501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,6 +363,8 @@ else() message(STATUS "Could not find an AWK-compatible program") endif() +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + if(NOT AWK OR ANDROID OR IOS) # No awk available to generate sources; use pre-built pnglibconf.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt @@ -713,8 +715,6 @@ if(PNG_SHARED) endif() target_include_directories(png_shared PUBLIC $) - target_include_directories(png_shared - PUBLIC $) target_include_directories(png_shared SYSTEM INTERFACE $) target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY}) @@ -729,8 +729,6 @@ if(PNG_STATIC) DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_include_directories(png_static PUBLIC $) - target_include_directories(png_static - PUBLIC $) target_include_directories(png_static SYSTEM INTERFACE $) target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index c098217865..b4b61cfc0e 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -21,7 +21,6 @@ Author List * Dan Rosser * David Callu * Eric Riff - * Erik Scholz * Gianfranco Costamagna * Gleb Mazovetskiy * Glenn Randers-Pehrson From 8cc22a8c1549a978a9b7ef1f5bbcf4d6d02b9de9 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 17 Apr 2024 12:32:45 +0200 Subject: [PATCH 040/112] cmake: Fix an error in the declaration of target include directories Properly declare target include directories for generated includes. Previously the non targeted `include_directories()` was used, which had issue when using the `png_static` target in a submodule. Signed-off-by: Cosmin Truta --- CMakeLists.txt | 8 ++++++-- scripts/cmake/AUTHORS.md | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d0369501..fc5256393d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,8 +363,6 @@ else() message(STATUS "Could not find an AWK-compatible program") endif() -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(NOT AWK OR ANDROID OR IOS) # No awk available to generate sources; use pre-built pnglibconf.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt @@ -715,6 +713,8 @@ if(PNG_SHARED) endif() target_include_directories(png_shared PUBLIC $) + target_include_directories(png_shared + PUBLIC $) target_include_directories(png_shared SYSTEM INTERFACE $) target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY}) @@ -729,6 +729,8 @@ if(PNG_STATIC) DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_include_directories(png_static PUBLIC $) + target_include_directories(png_static + PUBLIC $) target_include_directories(png_static SYSTEM INTERFACE $) target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY}) @@ -758,6 +760,8 @@ if(PNG_FRAMEWORK) set_target_properties(png_framework PROPERTIES DEFINE_SYMBOL "") target_include_directories(png_framework PUBLIC $) + target_include_directories(png_framework + PUBLIC $) target_include_directories(png_framework SYSTEM INTERFACE $) target_link_libraries(png_framework PUBLIC ZLIB::ZLIB ${M_LIBRARY}) diff --git a/scripts/cmake/AUTHORS.md b/scripts/cmake/AUTHORS.md index b4b61cfc0e..c098217865 100644 --- a/scripts/cmake/AUTHORS.md +++ b/scripts/cmake/AUTHORS.md @@ -21,6 +21,7 @@ Author List * Dan Rosser * David Callu * Eric Riff + * Erik Scholz * Gianfranco Costamagna * Gleb Mazovetskiy * Glenn Randers-Pehrson From 5a7e87fc049d39c3471f403f8f0ed13d15f3e7cb Mon Sep 17 00:00:00 2001 From: John Bowler Date: Wed, 11 Sep 2024 12:27:03 -0700 Subject: [PATCH 041/112] fix: Prevent overflow in chromaticity calculations In `png_xy_from_XYZ` X+Y+Z was calculated without checking for overflow. This fixes that by moving the correct code from `png_XYZ_normalize` into a static function which is now used from `png_xy_from_XYZ`. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- png.c | 71 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/png.c b/png.c index 84e03b5fd7..465f758484 100644 --- a/png.c +++ b/png.c @@ -1203,6 +1203,24 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) #endif /* GAMMA */ #ifdef PNG_COLORSPACE_SUPPORTED +static int +png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1, + png_int_32 addend2) { + /* Safely add three integers. Returns 0 on success, 1 on overlow. + * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore + * relying on addition of two positive values producing a negative one is not + * safe. + */ + int addend0 = *addend0_and_result; + if (0x7fffffff - addend0 < addend1) + return 1; + addend0 += addend1; + if (0x7fffffff - addend1 < addend2) + return 1; + *addend0_and_result = addend0 + addend2; + return 0; +} + /* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for * cHRM, as opposed to using chromaticities. These internal APIs return * non-zero on a parameter error. The X, Y and Z values are required to be @@ -1211,38 +1229,52 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) static int png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) { - png_int_32 d, dwhite, whiteX, whiteY; + png_int_32 d, dred, dgreen, dwhite, whiteX, whiteY; - d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z; + /* 'd' in each of the blocks below is just X+Y+Z for each component, + * x, y and z are X,Y,Z/(X+Y+Z). + */ + d = XYZ->red_X; + if (png_safe_add(&d, XYZ->red_Y, XYZ->red_Z)) + return 1; if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0) return 1; if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0) return 1; - dwhite = d; + dred = d; whiteX = XYZ->red_X; whiteY = XYZ->red_Y; - d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z; + d = XYZ->green_X; + if (png_safe_add(&d, XYZ->green_Y, XYZ->green_Z)) + return 1; if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0) return 1; if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0) return 1; - dwhite += d; + dgreen = d; whiteX += XYZ->green_X; whiteY += XYZ->green_Y; - d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z; + d = XYZ->blue_X; + if (png_safe_add(&d, XYZ->blue_Y, XYZ->blue_Z)) + return 1; if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0) return 1; if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0) return 1; - dwhite += d; whiteX += XYZ->blue_X; whiteY += XYZ->blue_Y; - /* The reference white is simply the sum of the end-point (X,Y,Z) vectors, - * thus: + /* The reference white is simply the sum of the end-point (X,Y,Z) vectors so + * the fillowing calculates (X+Y+Z) of the reference white (media white, + * encoding white) itself: */ + if (png_safe_add(&d, dred, dgreen)) + return 1; + + dwhite = d; + if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0) return 1; if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0) @@ -1506,25 +1538,14 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) static int png_XYZ_normalize(png_XYZ *XYZ) { - png_int_32 Y; + png_int_32 Y, Ytemp; - if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 || - XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 || - XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0) + /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. */ + Ytemp = XYZ->red_Y; + if (png_safe_add(&Ytemp, XYZ->green_Y, XYZ->blue_Y)) return 1; - /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. - * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore - * relying on addition of two positive values producing a negative one is not - * safe. - */ - Y = XYZ->red_Y; - if (0x7fffffff - Y < XYZ->green_X) - return 1; - Y += XYZ->green_Y; - if (0x7fffffff - Y < XYZ->blue_X) - return 1; - Y += XYZ->blue_Y; + Y = Ytemp; if (Y != PNG_FP_1) { From 3117b5f94a06aaf52a7365074e8199909680e52e Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 12 Sep 2024 18:26:10 +0300 Subject: [PATCH 042/112] oss-fuzz: Update the README file, the Docker file and the build script --- contrib/oss-fuzz/Dockerfile | 15 +++++++++------ contrib/oss-fuzz/README.txt | 4 ++++ contrib/oss-fuzz/build.sh | 31 ++++++++++++++----------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/contrib/oss-fuzz/Dockerfile b/contrib/oss-fuzz/Dockerfile index f5bc1a985d..c9bc4145e0 100644 --- a/contrib/oss-fuzz/Dockerfile +++ b/contrib/oss-fuzz/Dockerfile @@ -1,3 +1,5 @@ +# Copyright 2024 Cosmin Truta +# Copyright 2017 Glenn Randers-Pehrson # Copyright 2016 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,11 +17,12 @@ ################################################################################ FROM gcr.io/oss-fuzz-base/base-builder -MAINTAINER glennrp@gmail.com + RUN apt-get update && \ - apt-get install -y make autoconf automake libtool + apt-get install -y make autoconf automake libtool zlib1g-dev + +RUN git clone --depth=1 https://github.com/pnggroup/libpng.git && \ + git clone --depth=1 https://github.com/madler/zlib.git && \ + cp libpng/contrib/oss-fuzz/build.sh $SRC -RUN git clone --depth 1 https://github.com/madler/zlib.git -RUN git clone --depth 1 https://github.com/glennrp/libpng.git -RUN cp libpng/contrib/oss-fuzz/build.sh $SRC -WORKDIR libpng +WORKDIR /home/libpng diff --git a/contrib/oss-fuzz/README.txt b/contrib/oss-fuzz/README.txt index 66d5242c57..b01af52acc 100644 --- a/contrib/oss-fuzz/README.txt +++ b/contrib/oss-fuzz/README.txt @@ -1,3 +1,7 @@ +libpng additions to oss-fuzz +============================ + +Copyright (c) 2024 Cosmin Truta Copyright (c) 2017 Glenn Randers-Pehrson This code is released under the libpng license. diff --git a/contrib/oss-fuzz/build.sh b/contrib/oss-fuzz/build.sh index 7b8f026397..1970f9c06c 100755 --- a/contrib/oss-fuzz/build.sh +++ b/contrib/oss-fuzz/build.sh @@ -1,6 +1,8 @@ -#!/bin/bash -eu +#!/usr/bin/env bash +set -eu -# Copyright 2017-2018 Glenn Randers-Pehrson +# Copyright 2024 Cosmin Truta +# Copyright 2017 Glenn Randers-Pehrson # Copyright 2016 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,36 +17,31 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Revisions by Glenn Randers-Pehrson, 2017: -# 1. Build only the library, not the tools (changed "make -j$(nproc) all" to -# "make -j$(nproc) libpng16.la"). -# 2. Disabled WARNING and WRITE options in pnglibconf.dfa. -# 3. Build zlib alongside libpng ################################################################################ # Disable logging via library build configuration control. -cat scripts/pnglibconf.dfa | \ - sed -e "s/option STDIO/option STDIO disabled/" \ - -e "s/option WARNING /option WARNING disabled/" \ - -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ -> scripts/pnglibconf.dfa.temp -mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa +sed -e "s/option STDIO/option STDIO disabled/" \ + -e "s/option WARNING /option WARNING disabled/" \ + -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ + scripts/pnglibconf.dfa >scripts/pnglibconf.dfa.tmp +mv -f scripts/pnglibconf.dfa.tmp scripts/pnglibconf.dfa -# build the libpng library. +# Build the libpng library ("libpng16.la"), excluding the auxiliary tools. autoreconf -f -i ./configure --with-libpng-prefix=OSS_FUZZ_ make -j$(nproc) clean make -j$(nproc) libpng16.la -# build libpng_read_fuzzer. +# Build libpng_read_fuzzer. $CXX $CXXFLAGS -std=c++11 -I. \ $SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \ -o $OUT/libpng_read_fuzzer \ -lFuzzingEngine .libs/libpng16.a -lz -# add seed corpus. +# Add seed corpus. find $SRC/libpng -name "*.png" | grep -v crashers | \ xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip cp $SRC/libpng/contrib/oss-fuzz/*.dict \ - $SRC/libpng/contrib/oss-fuzz/*.options $OUT/ + $SRC/libpng/contrib/oss-fuzz/*.options \ + $OUT/ From 88ab4f592da09cc6a732896a7d41e9bc3b46dd27 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 12 Sep 2024 21:44:11 +0300 Subject: [PATCH 043/112] chore: Rerun `./autogen.sh --maintainer` --- Makefile.in | 211 +++++++++++++++----------- aclocal.m4 | 417 +++++++++++++++++++++++++++++++++++---------------- compile | 11 +- config.guess | 11 +- config.sub | 29 ++-- configure | 337 ++++++++++++++++++++++++++++++----------- depcomp | 15 +- install-sh | 8 +- missing | 75 +++++---- test-driver | 15 +- 10 files changed, 760 insertions(+), 369 deletions(-) diff --git a/Makefile.in b/Makefile.in index 46c3a13cfe..44b6936b7d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -83,6 +83,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ @@ -177,10 +179,9 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST = png.c \ @@ -503,6 +504,7 @@ am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ + $$am__collect_skipped_logs \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the @@ -527,6 +529,11 @@ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ +if test -n '$(IGNORE_SKIPPED_LOGS)'; then \ + am__collect_skipped_logs='--collect-skipped-logs no'; \ +else \ + am__collect_skipped_logs=''; \ +fi; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ @@ -582,20 +589,22 @@ distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ + find "$(distdir)" -type d ! -perm -700 -exec chmod u+rwx {} ';' \ + ; rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz -GZIP_ENV = --best +GZIP_ENV = -9 DIST_TARGETS = dist-xz dist-gzip # Exists only to be overridden by the user if desired. AM_DISTCHECK_DVI_TARGET = dvi distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' -distcleancheck_listfiles = find . -type f -print +distcleancheck_listfiles = \ + find . \( -type f -a \! \ + \( -name .nfs* -o -name .smb* -o -name .__afs* \) \) -print #distribute headers in /usr/include/libpng/* pkgincludedir = $(includedir)/$(PNGLIB_BASENAME) @@ -699,8 +708,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ # generate the -config scripts if required binconfigs = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config @@ -915,12 +926,12 @@ config.h: stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status config.h + $(AM_V_at)rm -f stamp-h1 + $(AM_V_GEN)cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 - touch $@ + $(AM_V_GEN)($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + $(AM_V_at)rm -f stamp-h1 + $(AM_V_at)touch $@ distclean-hdr: -rm -f config.h stamp-h1 @@ -967,25 +978,15 @@ uninstall-binPROGRAMS: `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(bindir)" && rm -f $$files + cd "$(DESTDIR)$(bindir)" && $(am__rm_f) $$files clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list + $(am__rm_f) $(bin_PROGRAMS) + test -z "$(EXEEXT)" || $(am__rm_f) $(bin_PROGRAMS:$(EXEEXT)=) clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list + $(am__rm_f) $(check_PROGRAMS) + test -z "$(EXEEXT)" || $(am__rm_f) $(check_PROGRAMS:$(EXEEXT)=) install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @@ -1012,32 +1013,28 @@ uninstall-libLTLIBRARIES: done clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + -$(am__rm_f) $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } + echo rm -f $${locs}; \ + $(am__rm_f) $${locs} clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + -$(am__rm_f) $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } + echo rm -f $${locs}; \ + $(am__rm_f) $${locs} arm/$(am__dirstamp): @$(MKDIR_P) arm - @: > arm/$(am__dirstamp) + @: >>arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) arm/$(DEPDIR) - @: > arm/$(DEPDIR)/$(am__dirstamp) + @: >>arm/$(DEPDIR)/$(am__dirstamp) arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \ arm/$(DEPDIR)/$(am__dirstamp) @@ -1045,10 +1042,10 @@ arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \ arm/$(DEPDIR)/$(am__dirstamp) mips/$(am__dirstamp): @$(MKDIR_P) mips - @: > mips/$(am__dirstamp) + @: >>mips/$(am__dirstamp) mips/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) mips/$(DEPDIR) - @: > mips/$(DEPDIR)/$(am__dirstamp) + @: >>mips/$(DEPDIR)/$(am__dirstamp) mips/mips_init.lo: mips/$(am__dirstamp) mips/$(DEPDIR)/$(am__dirstamp) mips/filter_msa_intrinsics.lo: mips/$(am__dirstamp) \ mips/$(DEPDIR)/$(am__dirstamp) @@ -1056,20 +1053,20 @@ mips/filter_mmi_inline_assembly.lo: mips/$(am__dirstamp) \ mips/$(DEPDIR)/$(am__dirstamp) intel/$(am__dirstamp): @$(MKDIR_P) intel - @: > intel/$(am__dirstamp) + @: >>intel/$(am__dirstamp) intel/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) intel/$(DEPDIR) - @: > intel/$(DEPDIR)/$(am__dirstamp) + @: >>intel/$(DEPDIR)/$(am__dirstamp) intel/intel_init.lo: intel/$(am__dirstamp) \ intel/$(DEPDIR)/$(am__dirstamp) intel/filter_sse2_intrinsics.lo: intel/$(am__dirstamp) \ intel/$(DEPDIR)/$(am__dirstamp) powerpc/$(am__dirstamp): @$(MKDIR_P) powerpc - @: > powerpc/$(am__dirstamp) + @: >>powerpc/$(am__dirstamp) powerpc/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) powerpc/$(DEPDIR) - @: > powerpc/$(DEPDIR)/$(am__dirstamp) + @: >>powerpc/$(DEPDIR)/$(am__dirstamp) powerpc/powerpc_init.lo: powerpc/$(am__dirstamp) \ powerpc/$(DEPDIR)/$(am__dirstamp) powerpc/filter_vsx_intrinsics.lo: powerpc/$(am__dirstamp) \ @@ -1079,10 +1076,10 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_O $(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK) -rpath $(libdir) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD) $(LIBS) loongarch/$(am__dirstamp): @$(MKDIR_P) loongarch - @: > loongarch/$(am__dirstamp) + @: >>loongarch/$(am__dirstamp) loongarch/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) loongarch/$(DEPDIR) - @: > loongarch/$(DEPDIR)/$(am__dirstamp) + @: >>loongarch/$(DEPDIR)/$(am__dirstamp) loongarch/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la-loongarch_lsx_init.lo: \ loongarch/$(am__dirstamp) loongarch/$(DEPDIR)/$(am__dirstamp) loongarch/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la-filter_lsx_intrinsics.lo: \ @@ -1092,10 +1089,10 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ls $(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_LINK) $(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_rpath) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_LIBADD) $(LIBS) contrib/tools/$(am__dirstamp): @$(MKDIR_P) contrib/tools - @: > contrib/tools/$(am__dirstamp) + @: >>contrib/tools/$(am__dirstamp) contrib/tools/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) contrib/tools/$(DEPDIR) - @: > contrib/tools/$(DEPDIR)/$(am__dirstamp) + @: >>contrib/tools/$(DEPDIR)/$(am__dirstamp) contrib/tools/png-fix-itxt.$(OBJEXT): contrib/tools/$(am__dirstamp) \ contrib/tools/$(DEPDIR)/$(am__dirstamp) @@ -1116,10 +1113,10 @@ pngfix$(EXEEXT): $(pngfix_OBJECTS) $(pngfix_DEPENDENCIES) $(EXTRA_pngfix_DEPENDE $(AM_V_CCLD)$(LINK) $(pngfix_OBJECTS) $(pngfix_LDADD) $(LIBS) contrib/libtests/$(am__dirstamp): @$(MKDIR_P) contrib/libtests - @: > contrib/libtests/$(am__dirstamp) + @: >>contrib/libtests/$(am__dirstamp) contrib/libtests/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) contrib/libtests/$(DEPDIR) - @: > contrib/libtests/$(DEPDIR)/$(am__dirstamp) + @: >>contrib/libtests/$(DEPDIR)/$(am__dirstamp) contrib/libtests/pngimage.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ contrib/libtests/$(DEPDIR)/$(am__dirstamp) @@ -1248,7 +1245,7 @@ distclean-compile: $(am__depfiles_remade): @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + @: >>$@ am--depfiles: $(am__depfiles_remade) @@ -1525,7 +1522,6 @@ distclean-tags: am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: - $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ @@ -1601,10 +1597,37 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ + output_system_information () \ + { \ + echo; \ + { uname -a | $(AWK) '{ \ + printf "System information (uname -a):"; \ + for (i = 1; i < NF; ++i) \ + { \ + if (i != 2) \ + printf " %s", $$i; \ + } \ + printf "\n"; \ +}'; } 2>&1; \ + if test -r /etc/os-release; then \ + echo "Distribution information (/etc/os-release):"; \ + sed 8q /etc/os-release; \ + elif test -r /etc/issue; then \ + echo "Distribution information (/etc/issue):"; \ + cat /etc/issue; \ + fi; \ + }; \ + please_report () \ + { \ +echo "Some test(s) failed. Please report this to $(PACKAGE_BUGREPORT),"; \ +echo "together with the test-suite.log file (gzipped) and your system"; \ +echo "information. Thanks."; \ + }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ + output_system_information; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ @@ -1624,26 +1647,25 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG) for debugging.$${std}";\ if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + please_report | sed -e "s/^/$${col}/" -e s/'$$'/"$${std}"/; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__rm_f) $(RECHECK_LOGS) + @$(am__rm_f) $(RECHECK_LOGS:.log=.trs) + @$(am__rm_f) $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__rm_f) $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ @@ -1896,7 +1918,7 @@ distdir: $(BUILT_SOURCES) distdir-am: $(DISTFILES) $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" + $(AM_V_at)$(MKDIR_P) "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -1984,7 +2006,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + eval GZIP= gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -1994,7 +2016,7 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + eval GZIP= gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ *.tar.zst*) \ @@ -2102,36 +2124,36 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + -$(am__rm_f) $(TEST_LOGS) + -$(am__rm_f) $(TEST_LOGS:.log=.trs) + -$(am__rm_f) $(TEST_SUITE_LOG) clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + -$(am__rm_f) $(CLEANFILES) distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f arm/$(DEPDIR)/$(am__dirstamp) - -rm -f arm/$(am__dirstamp) - -rm -f contrib/libtests/$(DEPDIR)/$(am__dirstamp) - -rm -f contrib/libtests/$(am__dirstamp) - -rm -f contrib/tools/$(DEPDIR)/$(am__dirstamp) - -rm -f contrib/tools/$(am__dirstamp) - -rm -f intel/$(DEPDIR)/$(am__dirstamp) - -rm -f intel/$(am__dirstamp) - -rm -f loongarch/$(DEPDIR)/$(am__dirstamp) - -rm -f loongarch/$(am__dirstamp) - -rm -f mips/$(DEPDIR)/$(am__dirstamp) - -rm -f mips/$(am__dirstamp) - -rm -f powerpc/$(DEPDIR)/$(am__dirstamp) - -rm -f powerpc/$(am__dirstamp) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) arm/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) arm/$(am__dirstamp) + -$(am__rm_f) contrib/libtests/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) contrib/libtests/$(am__dirstamp) + -$(am__rm_f) contrib/tools/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) contrib/tools/$(am__dirstamp) + -$(am__rm_f) intel/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) intel/$(am__dirstamp) + -$(am__rm_f) loongarch/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) loongarch/$(am__dirstamp) + -$(am__rm_f) mips/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) mips/$(am__dirstamp) + -$(am__rm_f) powerpc/$(DEPDIR)/$(am__dirstamp) + -$(am__rm_f) powerpc/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -$(am__rm_f) $(BUILT_SOURCES) + -$(am__rm_f) $(MAINTAINERCLEANFILES) @DO_INSTALL_LIBPNG_CONFIG_FALSE@@DO_INSTALL_LINKS_FALSE@install-exec-hook: @DO_INSTALL_LIBPNG_PC_FALSE@@DO_INSTALL_LINKS_FALSE@install-data-hook: @DO_INSTALL_LIBPNG_CONFIG_FALSE@@DO_INSTALL_LIBPNG_PC_FALSE@@DO_INSTALL_LINKS_FALSE@uninstall-hook: @@ -2143,7 +2165,7 @@ clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/png.Plo -rm -f ./$(DEPDIR)/pngerror.Plo -rm -f ./$(DEPDIR)/pngget.Plo -rm -f ./$(DEPDIR)/pngmem.Plo @@ -2230,7 +2252,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/png.Plo -rm -f ./$(DEPDIR)/pngerror.Plo -rm -f ./$(DEPDIR)/pngget.Plo -rm -f ./$(DEPDIR)/pngmem.Plo @@ -2510,3 +2532,10 @@ all-am: $(check_PROGRAMS) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/aclocal.m4 b/aclocal.m4 index 20850042aa..b93b608e44 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.5 -*- Autoconf -*- +# generated automatically by aclocal 1.17 -*- Autoconf -*- -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2021 Free Software Foundation, Inc. +# Copyright (C) 2002-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.16' +[am__api_version='1.17' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.5], [], +m4_if([$1], [1.17], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.5])dnl +[AM_AUTOMAKE_VERSION([1.17])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # Figure out how to run the assembler. -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -78,7 +78,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -130,7 +130,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2021 Free Software Foundation, Inc. +# Copyright (C) 1997-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -161,7 +161,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -293,7 +293,7 @@ AC_CACHE_CHECK([dependency style of $depcc], # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: + # When given -MP, icc 7.0 and 7.1 complain thus: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported @@ -352,7 +352,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -420,7 +420,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -554,7 +554,7 @@ if test -z "$CSCOPE"; then fi AC_SUBST([CSCOPE]) -AC_REQUIRE([AM_SILENT_RULES])dnl +AC_REQUIRE([_AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. @@ -562,47 +562,9 @@ AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. +AC_REQUIRE([_AM_PROG_RM_F]) +AC_REQUIRE([_AM_PROG_XARGS_N]) -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. @@ -635,7 +597,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -656,7 +618,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2021 Free Software Foundation, Inc. +# Copyright (C) 2003-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -678,7 +640,7 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -713,7 +675,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -756,7 +718,7 @@ AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2021 Free Software Foundation, Inc. +# Copyright (C) 1997-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -790,7 +752,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -819,7 +781,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -866,7 +828,23 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_RM_F +# --------------- +# Check whether 'rm -f' without any arguments works. +# https://bugs.gnu.org/10828 +AC_DEFUN([_AM_PROG_RM_F], +[am__rm_f_notfound= +AS_IF([(rm -f && rm -fr && rm -rf) 2>/dev/null], [], [am__rm_f_notfound='""']) +AC_SUBST(am__rm_f_notfound) +]) + +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -885,16 +863,169 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# _AM_SLEEP_FRACTIONAL_SECONDS +# ---------------------------- +AC_DEFUN([_AM_SLEEP_FRACTIONAL_SECONDS], [dnl +AC_CACHE_CHECK([whether sleep supports fractional seconds], + am_cv_sleep_fractional_seconds, [dnl +AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=yes], + [am_cv_sleep_fractional_seconds=no]) +])]) + +# _AM_FILESYSTEM_TIMESTAMP_RESOLUTION +# ----------------------------------- +# Determine the filesystem's resolution for file modification +# timestamps. The coarsest we know of is FAT, with a resolution +# of only two seconds, even with the most recent "exFAT" extensions. +# The finest (e.g. ext4 with large inodes, XFS, ZFS) is one +# nanosecond, matching clock_gettime. However, it is probably not +# possible to delay execution of a shell script for less than one +# millisecond, due to process creation overhead and scheduling +# granularity, so we don't check for anything finer than that. (See below.) +AC_DEFUN([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl +AC_REQUIRE([_AM_SLEEP_FRACTIONAL_SECONDS]) +AC_CACHE_CHECK([filesystem timestamp resolution], + am_cv_filesystem_timestamp_resolution, [dnl +# Default to the worst case. +am_cv_filesystem_timestamp_resolution=2 + +# Only try to go finer than 1 sec if sleep can do it. +# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work, +# - 1 sec is not much of a win compared to 2 sec, and +# - it takes 2 seconds to perform the test whether 1 sec works. +# +# Instead, just use the default 2s on platforms that have 1s resolution, +# accept the extra 1s delay when using $sleep in the Automake tests, in +# exchange for not incurring the 2s delay for running the test for all +# packages. +# +am_try_resolutions= +if test "$am_cv_sleep_fractional_seconds" = yes; then + # Even a millisecond often causes a bunch of false positives, + # so just try a hundredth of a second. The time saved between .001 and + # .01 is not terribly consequential. + am_try_resolutions="0.01 0.1 $am_try_resolutions" +fi + +# In order to catch current-generation FAT out, we must *modify* files +# that already exist; the *creation* timestamp is finer. Use names +# that make ls -t sort them differently when they have equal +# timestamps than when they have distinct timestamps, keeping +# in mind that ls -t prints the *newest* file first. +rm -f conftest.ts? +: > conftest.ts1 +: > conftest.ts2 +: > conftest.ts3 + +# Make sure ls -t actually works. Do 'set' in a subshell so we don't +# clobber the current shell's arguments. (Outer-level square brackets +# are removed by m4; they're present so that m4 does not expand +# ; be careful, easy to get confused.) +if ( + set X `[ls -t conftest.ts[12]]` && + { + test "$[]*" != "X conftest.ts1 conftest.ts2" || + test "$[]*" != "X conftest.ts2 conftest.ts1"; + } +); then :; else + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + _AS_ECHO_UNQUOTED( + ["Bad output from ls -t: \"`[ls -t conftest.ts[12]]`\""], + [AS_MESSAGE_LOG_FD]) + AC_MSG_FAILURE([ls -t produces unexpected output. +Make sure there is not a broken ls alias in your environment.]) +fi + +for am_try_res in $am_try_resolutions; do + # Any one fine-grained sleep might happen to cross the boundary + # between two values of a coarser actual resolution, but if we do + # two fine-grained sleeps in a row, at least one of them will fall + # entirely within a coarse interval. + echo alpha > conftest.ts1 + sleep $am_try_res + echo beta > conftest.ts2 + sleep $am_try_res + echo gamma > conftest.ts3 + + # We assume that 'ls -t' will make use of high-resolution + # timestamps if the operating system supports them at all. + if (set X `ls -t conftest.ts?` && + test "$[]2" = conftest.ts3 && + test "$[]3" = conftest.ts2 && + test "$[]4" = conftest.ts1); then + # + # Ok, ls -t worked. If we're at a resolution of 1 second, we're done, + # because we don't need to test make. + make_ok=true + if test $am_try_res != 1; then + # But if we've succeeded so far with a subsecond resolution, we + # have one more thing to check: make. It can happen that + # everything else supports the subsecond mtimes, but make doesn't; + # notably on macOS, which ships make 3.81 from 2006 (the last one + # released under GPLv2). https://bugs.gnu.org/68808 + # + # We test $MAKE if it is defined in the environment, else "make". + # It might get overridden later, but our hope is that in practice + # it does not matter: it is the system "make" which is (by far) + # the most likely to be broken, whereas if the user overrides it, + # probably they did so with a better, or at least not worse, make. + # https://lists.gnu.org/archive/html/automake/2024-06/msg00051.html + # + # Create a Makefile (real tab character here): + rm -f conftest.mk + echo 'conftest.ts1: conftest.ts2' >conftest.mk + echo ' touch conftest.ts2' >>conftest.mk + # + # Now, running + # touch conftest.ts1; touch conftest.ts2; make + # should touch ts1 because ts2 is newer. This could happen by luck, + # but most often, it will fail if make's support is insufficient. So + # test for several consecutive successes. + # + # (We reuse conftest.ts[12] because we still want to modify existing + # files, not create new ones, per above.) + n=0 + make=${MAKE-make} + until test $n -eq 3; do + echo one > conftest.ts1 + sleep $am_try_res + echo two > conftest.ts2 # ts2 should now be newer than ts1 + if $make -f conftest.mk | grep 'up to date' >/dev/null; then + make_ok=false + break # out of $n loop + fi + n=`expr $n + 1` + done + fi + # + if $make_ok; then + # Everything we know to check worked out, so call this resolution good. + am_cv_filesystem_timestamp_resolution=$am_try_res + break # out of $am_try_res loop + fi + # Otherwise, we'll go on to check the next resolution. + fi +done +rm -f conftest.ts? +# (end _am_filesystem_timestamp_resolution) +])]) + # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) +[AC_REQUIRE([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION]) +# This check should not be cached, as it may vary across builds of +# different projects. +AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -913,49 +1044,40 @@ esac # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! +am_build_env_is_sane=no +am_has_slept=no +rm -f conftest.file +for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[]*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + test "$[]2" = conftest.file + ); then + am_build_env_is_sane=yes + break + fi + # Just in case. + sleep "$am_cv_filesystem_timestamp_resolution" + am_has_slept=yes +done + +AC_MSG_RESULT([$am_build_env_is_sane]) +if test "$am_build_env_is_sane" = no; then + AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT([yes]) + # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & +AS_IF([test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1],, [dnl + ( sleep "$am_cv_filesystem_timestamp_resolution" ) & am_sleep_pid=$! -fi +]) AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then @@ -966,18 +1088,18 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2021 Free Software Foundation, Inc. +# Copyright (C) 2009-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl +# _AM_SILENT_RULES +# ---------------- +# Enable less verbose build rules support. +AC_DEFUN([_AM_SILENT_RULES], +[AM_DEFAULT_VERBOSITY=1 +AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) @@ -985,11 +1107,6 @@ AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. @@ -1008,14 +1125,6 @@ am__doit: else am_cv_make_support_nested_variables=no fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl @@ -1024,9 +1133,33 @@ AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +dnl Delay evaluation of AM_DEFAULT_VERBOSITY to the end to allow multiple calls +dnl to AM_SILENT_RULES to change the default value. +AC_CONFIG_COMMANDS_PRE([dnl +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; +esac +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +])dnl ]) -# Copyright (C) 2001-2021 Free Software Foundation, Inc. +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Set the default verbosity level to DEFAULT ("yes" being less verbose, "no" or +# empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_REQUIRE([_AM_SILENT_RULES]) +AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1])]) + +# Copyright (C) 2001-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1054,7 +1187,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2021 Free Software Foundation, Inc. +# Copyright (C) 2006-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1073,7 +1206,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2021 Free Software Foundation, Inc. +# Copyright (C) 2004-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1119,15 +1252,19 @@ m4_if([$1], [v7], am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) + if test x$am_uid = xunknown; then + AC_MSG_WARN([ancient id detected; assuming current UID is ok, but dist-ustar might not work]) + elif test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) else - AC_MSG_RESULT([no]) - _am_tools=none + AC_MSG_RESULT([no]) + _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) + if test x$gm_gid = xunknown; then + AC_MSG_WARN([ancient id detected; assuming current GID is ok, but dist-ustar might not work]) + elif test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none @@ -1204,6 +1341,26 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +# Copyright (C) 2022-2024 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_PROG_XARGS_N +# ---------------- +# Check whether 'xargs -n' works. It should work everywhere, so the fallback +# is not optimized at all as we never expect to use it. +AC_DEFUN([_AM_PROG_XARGS_N], +[AC_CACHE_CHECK([xargs -n works], am_cv_xargs_n_works, [dnl +AS_IF([test "`echo 1 2 3 | xargs -n2 echo`" = "1 2 +3"], [am_cv_xargs_n_works=yes], [am_cv_xargs_n_works=no])]) +AS_IF([test "$am_cv_xargs_n_works" = yes], [am__xargs_n='xargs -n'], [dnl + am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read am__xargs_n_arg; do "$@" "$am__xargs_n_arg"; done; }' +])dnl +AC_SUBST(am__xargs_n) +]) + m4_include([scripts/autoconf/libtool.m4]) m4_include([scripts/autoconf/ltoptions.m4]) m4_include([scripts/autoconf/ltsugar.m4]) diff --git a/compile b/compile index df363c8fbf..49b3d05fde 100755 --- a/compile +++ b/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -143,7 +143,7 @@ func_cl_wrapper () # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in - *.o | *.[oO][bB][jJ]) + *.o | *.lo | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift @@ -248,14 +248,17 @@ If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . +GNU Automake home page: . +General help using GNU software: . EOF exit $? ;; -v | --v*) - echo "compile $scriptversion" + echo "compile (GNU Automake) $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + clang-cl | *[/\\]clang-cl | clang-cl.exe | *[/\\]clang-cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; diff --git a/config.guess b/config.guess index cdfc439204..f6d217a49f 100755 --- a/config.guess +++ b/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2023 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2023-08-22' +timestamp='2024-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -60,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2023 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -165,6 +165,8 @@ Linux|GNU|GNU/*) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm #else #include /* First heuristic to detect musl libc. */ @@ -1593,6 +1595,9 @@ EOF *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; esac # Do we have a guess based on uname results? diff --git a/config.sub b/config.sub index defe52c0c8..2c6a07ab3c 100755 --- a/config.sub +++ b/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2023 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2023-09-19' +timestamp='2024-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -76,7 +76,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2023 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -1222,6 +1222,7 @@ case $cpu-$vendor in | moxie \ | mt \ | msp430 \ + | nanomips* \ | nds32 | nds32le | nds32be \ | nfp \ | nios | nios2 | nios2eb | nios2el \ @@ -1253,6 +1254,7 @@ case $cpu-$vendor in | ubicom32 \ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ | vax \ + | vc4 \ | visium \ | w65 \ | wasm32 | wasm64 \ @@ -1597,7 +1599,7 @@ case $cpu-$vendor in os= obj=elf ;; - mips*-*) + mips*-*|nanomips*-*) os= obj=elf ;; @@ -1721,7 +1723,7 @@ fi case $os in # Sometimes we do "kernel-libc", so those need to count as OSes. - musl* | newlib* | relibc* | uclibc*) + llvm* | musl* | newlib* | relibc* | uclibc*) ;; # Likewise for "kernel-abi" eabi* | gnueabi*) @@ -1766,12 +1768,19 @@ case $os in | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ - | fiwix* | mlibc* | cos* | mbr* ) + | fiwix* | mlibc* | cos* | mbr* | ironclad* ) ;; # This one is extra strict with allowed versions sco3.2v2 | sco3.2v[4-9]* | sco5v6*) # Don't forget version if it is 3.2v4 or newer. ;; + # This refers to builds using the UEFI calling convention + # (which depends on the architecture) and PE file format. + # Note that this is both a different calling convention and + # different file format than that of GNU-EFI + # (x86_64-w64-mingw32). + uefi) + ;; none) ;; kernel* | msvc* ) @@ -1818,8 +1827,9 @@ esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os-$obj in - linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \ - | linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- ) + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- ) ;; uclinux-uclibc*- ) ;; @@ -1827,7 +1837,8 @@ case $kernel-$os-$obj in ;; windows*-msvc*-) ;; - -dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- ) + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 diff --git a/configure b/configure index ee7d0eadac..0718e6e1b4 100755 --- a/configure +++ b/configure @@ -753,6 +753,8 @@ CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE +am__xargs_n +am__rm_f_notfound AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V @@ -2729,7 +2731,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # dist-xz requires automake 1.11 or later # 1.12.2 fixes a security issue in 1.11.2 and 1.12.1 # 1.13 is required for parallel tests -am__api_version='1.16' +am__api_version='1.17' @@ -2832,6 +2834,165 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether sleep supports fractional seconds" >&5 +printf %s "checking whether sleep supports fractional seconds... " >&6; } +if test ${am_cv_sleep_fractional_seconds+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if sleep 0.001 2>/dev/null +then : + am_cv_sleep_fractional_seconds=yes +else case e in #( + e) am_cv_sleep_fractional_seconds=no ;; +esac +fi + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_sleep_fractional_seconds" >&5 +printf "%s\n" "$am_cv_sleep_fractional_seconds" >&6; } + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking filesystem timestamp resolution" >&5 +printf %s "checking filesystem timestamp resolution... " >&6; } +if test ${am_cv_filesystem_timestamp_resolution+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) # Default to the worst case. +am_cv_filesystem_timestamp_resolution=2 + +# Only try to go finer than 1 sec if sleep can do it. +# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work, +# - 1 sec is not much of a win compared to 2 sec, and +# - it takes 2 seconds to perform the test whether 1 sec works. +# +# Instead, just use the default 2s on platforms that have 1s resolution, +# accept the extra 1s delay when using $sleep in the Automake tests, in +# exchange for not incurring the 2s delay for running the test for all +# packages. +# +am_try_resolutions= +if test "$am_cv_sleep_fractional_seconds" = yes; then + # Even a millisecond often causes a bunch of false positives, + # so just try a hundredth of a second. The time saved between .001 and + # .01 is not terribly consequential. + am_try_resolutions="0.01 0.1 $am_try_resolutions" +fi + +# In order to catch current-generation FAT out, we must *modify* files +# that already exist; the *creation* timestamp is finer. Use names +# that make ls -t sort them differently when they have equal +# timestamps than when they have distinct timestamps, keeping +# in mind that ls -t prints the *newest* file first. +rm -f conftest.ts? +: > conftest.ts1 +: > conftest.ts2 +: > conftest.ts3 + +# Make sure ls -t actually works. Do 'set' in a subshell so we don't +# clobber the current shell's arguments. (Outer-level square brackets +# are removed by m4; they're present so that m4 does not expand +# ; be careful, easy to get confused.) +if ( + set X `ls -t conftest.ts[12]` && + { + test "$*" != "X conftest.ts1 conftest.ts2" || + test "$*" != "X conftest.ts2 conftest.ts1"; + } +); then :; else + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + printf "%s\n" ""Bad output from ls -t: \"`ls -t conftest.ts[12]`\""" >&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "ls -t produces unexpected output. +Make sure there is not a broken ls alias in your environment. +See 'config.log' for more details" "$LINENO" 5; } +fi + +for am_try_res in $am_try_resolutions; do + # Any one fine-grained sleep might happen to cross the boundary + # between two values of a coarser actual resolution, but if we do + # two fine-grained sleeps in a row, at least one of them will fall + # entirely within a coarse interval. + echo alpha > conftest.ts1 + sleep $am_try_res + echo beta > conftest.ts2 + sleep $am_try_res + echo gamma > conftest.ts3 + + # We assume that 'ls -t' will make use of high-resolution + # timestamps if the operating system supports them at all. + if (set X `ls -t conftest.ts?` && + test "$2" = conftest.ts3 && + test "$3" = conftest.ts2 && + test "$4" = conftest.ts1); then + # + # Ok, ls -t worked. If we're at a resolution of 1 second, we're done, + # because we don't need to test make. + make_ok=true + if test $am_try_res != 1; then + # But if we've succeeded so far with a subsecond resolution, we + # have one more thing to check: make. It can happen that + # everything else supports the subsecond mtimes, but make doesn't; + # notably on macOS, which ships make 3.81 from 2006 (the last one + # released under GPLv2). https://bugs.gnu.org/68808 + # + # We test $MAKE if it is defined in the environment, else "make". + # It might get overridden later, but our hope is that in practice + # it does not matter: it is the system "make" which is (by far) + # the most likely to be broken, whereas if the user overrides it, + # probably they did so with a better, or at least not worse, make. + # https://lists.gnu.org/archive/html/automake/2024-06/msg00051.html + # + # Create a Makefile (real tab character here): + rm -f conftest.mk + echo 'conftest.ts1: conftest.ts2' >conftest.mk + echo ' touch conftest.ts2' >>conftest.mk + # + # Now, running + # touch conftest.ts1; touch conftest.ts2; make + # should touch ts1 because ts2 is newer. This could happen by luck, + # but most often, it will fail if make's support is insufficient. So + # test for several consecutive successes. + # + # (We reuse conftest.ts[12] because we still want to modify existing + # files, not create new ones, per above.) + n=0 + make=${MAKE-make} + until test $n -eq 3; do + echo one > conftest.ts1 + sleep $am_try_res + echo two > conftest.ts2 # ts2 should now be newer than ts1 + if $make -f conftest.mk | grep 'up to date' >/dev/null; then + make_ok=false + break # out of $n loop + fi + n=`expr $n + 1` + done + fi + # + if $make_ok; then + # Everything we know to check worked out, so call this resolution good. + am_cv_filesystem_timestamp_resolution=$am_try_res + break # out of $am_try_res loop + fi + # Otherwise, we'll go on to check the next resolution. + fi +done +rm -f conftest.ts? +# (end _am_filesystem_timestamp_resolution) + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_filesystem_timestamp_resolution" >&5 +printf "%s\n" "$am_cv_filesystem_timestamp_resolution" >&6; } + +# This check should not be cached, as it may vary across builds of +# different projects. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 printf %s "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory @@ -2852,49 +3013,45 @@ esac # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error $? "newly created file is older than distributed files! +am_build_env_is_sane=no +am_has_slept=no +rm -f conftest.file +for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + test "$2" = conftest.file + ); then + am_build_env_is_sane=yes + break + fi + # Just in case. + sleep "$am_cv_filesystem_timestamp_resolution" + am_has_slept=yes +done + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_build_env_is_sane" >&5 +printf "%s\n" "$am_build_env_is_sane" >&6; } +if test "$am_build_env_is_sane" = no; then + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & +if test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1 +then : + +else case e in #( + e) ( sleep "$am_cv_filesystem_timestamp_resolution" ) & am_sleep_pid=$! + ;; +esac fi rm -f conftest.file @@ -3184,17 +3341,13 @@ else fi rmdir .tst 2>/dev/null +AM_DEFAULT_VERBOSITY=1 # Check whether --enable-silent-rules was given. if test ${enable_silent_rules+y} then : enableval=$enable_silent_rules; fi -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=1;; -esac am_make=${MAKE-make} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 printf %s "checking whether $am_make supports nested variables... " >&6; } @@ -3217,15 +3370,45 @@ esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi AM_BACKSLASH='\' +am__rm_f_notfound= +if (rm -f && rm -fr && rm -rf) 2>/dev/null +then : + +else case e in #( + e) am__rm_f_notfound='""' ;; +esac +fi + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking xargs -n works" >&5 +printf %s "checking xargs -n works... " >&6; } +if test ${am_cv_xargs_n_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test "`echo 1 2 3 | xargs -n2 echo`" = "1 2 +3" +then : + am_cv_xargs_n_works=yes +else case e in #( + e) am_cv_xargs_n_works=no ;; +esac +fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_xargs_n_works" >&5 +printf "%s\n" "$am_cv_xargs_n_works" >&6; } +if test "$am_cv_xargs_n_works" = yes +then : + am__xargs_n='xargs -n' +else case e in #( + e) am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read am__xargs_n_arg; do "" "$am__xargs_n_arg"; done; }' + ;; +esac +fi + if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." @@ -3309,47 +3492,9 @@ fi -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 - fi -fi # The following line causes --disable-maintainer-mode to be the default to # configure. This is necessary because libpng distributions cannot rely on the @@ -4644,7 +4789,7 @@ else case e in #( # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: + # When given -MP, icc 7.0 and 7.1 complain thus: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported @@ -4779,7 +4924,7 @@ else case e in #( # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: + # When given -MP, icc 7.0 and 7.1 complain thus: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported @@ -14905,6 +15050,18 @@ printf %s "checking that generated files are newer than configure... " >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5 printf "%s\n" "done" >&6; } +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; +esac +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi + if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' diff --git a/depcomp b/depcomp index 715e34311e..1f0aa972c9 100755 --- a/depcomp +++ b/depcomp @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 1999-2021 Free Software Foundation, Inc. +# Copyright (C) 1999-2024 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,11 +47,13 @@ Environment variables: libtool Whether libtool is used (yes/no). Report bugs to . +GNU Automake home page: . +General help using GNU software: . EOF exit $? ;; -v | --v*) - echo "depcomp $scriptversion" + echo "depcomp (GNU Automake) $scriptversion" exit $? ;; esac @@ -113,7 +115,6 @@ nl=' # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz -digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then @@ -128,7 +129,7 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" -# Avoid interferences from the environment. +# Avoid interference from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We @@ -198,8 +199,8 @@ gcc3) ;; gcc) -## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. -## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## Note that this doesn't just cater to obsolete pre-3.x GCC compilers. +## but also to in-use compilers like IBM xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: diff --git a/install-sh b/install-sh index 7c56c9c015..b1d7a6f67f 100755 --- a/install-sh +++ b/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2023-11-23.18; # UTC +scriptversion=2024-06-19.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -170,7 +170,7 @@ while test $# -ne 0; do -T) is_target_a_directory=never;; - --version) echo "$0 $scriptversion"; exit $?;; + --version) echo "$0 (GNU Automake) $scriptversion"; exit $?;; --) shift break;; @@ -345,7 +345,7 @@ do ' 0 # Because "mkdir -p" follows existing symlinks and we likely work - # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directly in world-writable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && @@ -353,7 +353,7 @@ do exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. + # Check for POSIX incompatibility with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. diff --git a/missing b/missing index 1fe1611f18..7e7d78ec52 100755 --- a/missing +++ b/missing @@ -1,9 +1,11 @@ #! /bin/sh -# Common wrapper for a few potentially missing GNU programs. +# Common wrapper for a few potentially missing GNU and other programs. -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-07.14; # UTC -# Copyright (C) 1996-2021 Free Software Foundation, Inc. +# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells + +# Copyright (C) 1996-2024 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -54,18 +56,20 @@ Options: -v, --version output version information and exit Supported PROGRAM values: - aclocal autoconf autoheader autom4te automake makeinfo - bison yacc flex lex help2man +aclocal autoconf autogen autoheader autom4te automake autoreconf +bison flex help2man lex makeinfo perl yacc Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. -Send bug reports to ." +Report bugs to . +GNU Automake home page: . +General help using GNU software: ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" + echo "missing (GNU Automake) $scriptversion" exit $? ;; @@ -108,7 +112,7 @@ gnu_software_URL=https://www.gnu.org/software program_details () { case $1 in - aclocal|automake) + aclocal|automake|autoreconf) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" @@ -123,6 +127,9 @@ program_details () echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; + *) + : + ;; esac } @@ -137,48 +144,55 @@ give_advice () printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + autoheader_deps="'acconfig.h'" + automake_deps="'Makefile.am'" + aclocal_deps="'acinclude.m4'" case $normalized_program in + aclocal*) + echo "You should only need it if you modified $aclocal_deps or" + echo "$configure_deps." + ;; autoconf*) - echo "You should only need it if you modified 'configure.ac'," - echo "or m4 files included by it." - program_details 'autoconf' + echo "You should only need it if you modified $configure_deps." + ;; + autogen*) + echo "You should only need it if you modified a '.def' or '.tpl' file." + echo "You may want to install the GNU AutoGen package:" + echo "<$gnu_software_URL/autogen/>" ;; autoheader*) - echo "You should only need it if you modified 'acconfig.h' or" + echo "You should only need it if you modified $autoheader_deps or" echo "$configure_deps." - program_details 'autoheader' ;; automake*) - echo "You should only need it if you modified 'Makefile.am' or" - echo "$configure_deps." - program_details 'automake' - ;; - aclocal*) - echo "You should only need it if you modified 'acinclude.m4' or" + echo "You should only need it if you modified $automake_deps or" echo "$configure_deps." - program_details 'aclocal' ;; - autom4te*) + autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." - program_details 'autom4te' + ;; + autoreconf*) + echo "You should only need it if you modified $aclocal_deps or" + echo "$automake_deps or $autoheader_deps or $automake_deps or" + echo "$configure_deps." ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; - lex*|flex*) - echo "You should only need it if you modified a '.l' file." - echo "You may want to install the Fast Lexical Analyzer package:" - echo "<$flex_URL>" - ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." @@ -189,6 +203,12 @@ give_advice () echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; + perl*) + echo "You should only need it to run GNU Autoconf, GNU Automake, " + echo " assorted other tools, or if you modified a Perl source file." + echo "You may want to install the Perl 5 language interpreter:" + echo "<$perl_URL>" + ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" @@ -197,6 +217,7 @@ give_advice () echo "case some other package contains this missing '$1' program." ;; esac + program_details "$normalized_program" } give_advice "$1" | sed -e '1s/^/WARNING: /' \ diff --git a/test-driver b/test-driver index be73b80adf..dc38f623f4 100755 --- a/test-driver +++ b/test-driver @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2018-03-07.03; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 2011-2021 Free Software Foundation, Inc. +# Copyright (C) 2011-2024 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,11 +44,16 @@ print_usage () Usage: test-driver --test-name NAME --log-file PATH --trs-file PATH [--expect-failure {yes|no}] [--color-tests {yes|no}] + [--collect-skipped-logs {yes|no}] [--enable-hard-errors {yes|no}] [--] TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] The '--test-name', '--log-file' and '--trs-file' options are mandatory. See the GNU Automake documentation for information. + +Report bugs to . +GNU Automake home page: . +General help using GNU software: . END } @@ -57,15 +62,17 @@ log_file= # Where to save the output of the test script. trs_file= # Where to save the metadata of the test run. expect_failure=no color_tests=no +collect_skipped_logs=yes enable_hard_errors=yes while test $# -gt 0; do case $1 in --help) print_usage; exit $?;; - --version) echo "test-driver $scriptversion"; exit $?;; + --version) echo "test-driver (GNU Automake) $scriptversion"; exit $?;; --test-name) test_name=$2; shift;; --log-file) log_file=$2; shift;; --trs-file) trs_file=$2; shift;; --color-tests) color_tests=$2; shift;; + --collect-skipped-logs) collect_skipped_logs=$2; shift;; --expect-failure) expect_failure=$2; shift;; --enable-hard-errors) enable_hard_errors=$2; shift;; --) shift; break;; @@ -121,7 +128,7 @@ fi case $tweaked_estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; - 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 77:*) col=$blu res=SKIP recheck=no gcopy=$collect_skipped_logs;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; From f5e92d76973a7a53f517579bc95d61483bf108c0 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 12 Sep 2024 23:44:44 +0300 Subject: [PATCH 044/112] Release libpng version 1.6.44 --- ANNOUNCE | 67 ++++++++++++++--------------------- CHANGES | 22 +++++++++++- CMakeLists.txt | 4 +-- README | 4 +-- configure | 22 ++++++------ configure.ac | 4 +-- libpng-manual.txt | 2 +- libpng.3 | 6 ++-- libpngpf.3 | 4 +-- png.5 | 2 +- png.c | 4 +-- png.h | 16 ++++----- pngconf.h | 2 +- pngtest.c | 2 +- scripts/libpng-config-head.in | 2 +- scripts/libpng.pc.in | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 17 files changed, 86 insertions(+), 81 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6361247876..a2a7ac363a 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,13 +1,5 @@ -libpng 1.6.44.git -================= - -This is a development version, not intended to be a public release. -It will be replaced by a public release, or by another development -version, at a later time. - - -libpng 1.6.43 - February 23, 2024 -================================= +libpng 1.6.44 - September 12, 2024 +================================== This is a public release of libpng, intended for use in production code. @@ -17,13 +9,13 @@ Files available for download Source files with LF line endings (for Unix/Linux): - * libpng-1.6.43.tar.xz (LZMA-compressed, recommended) - * libpng-1.6.43.tar.gz (deflate-compressed) + * libpng-1.6.44.tar.xz (LZMA-compressed, recommended) + * libpng-1.6.44.tar.gz (deflate-compressed) Source files with CRLF line endings (for Windows): - * lpng1643.7z (LZMA-compressed, recommended) - * lpng1643.zip (deflate-compressed) + * lpng1644.7z (LZMA-compressed, recommended) + * lpng1644.zip (deflate-compressed) Other information: @@ -33,36 +25,29 @@ Other information: * TRADEMARK.md -Changes from version 1.6.42 to version 1.6.43 +Changes from version 1.6.43 to version 1.6.44 --------------------------------------------- - * Fixed the row width check in png_check_IHDR(). - This corrected a bug that was specific to the 16-bit platforms, - and removed a spurious compiler warning from the 64-bit builds. - (Reported by Jacek Caban; fixed by John Bowler) - * Added eXIf chunk support to the push-mode reader in pngpread.c. - (Contributed by Chris Blume) - * Added contrib/pngexif for the benefit of the users who would like - to inspect the content of eXIf chunks. - * Added contrib/conftest/basic.dfa, a basic build-time configuration. - (Contributed by John Bowler) - * Fixed a preprocessor condition in pngread.c that broke build-time - configurations like contrib/conftest/pngcp.dfa. + * Hardened calculations in chroma handling to prevent overflows, and + relaxed a constraint in cHRM validation to accomodate the standard + ACES AP1 set of color primaries. (Contributed by John Bowler) - * Added CMake build support for LoongArch LSX. - (Contributed by GuXiWei) - * Fixed a CMake build error that occurred under a peculiar state of the - dependency tree. This was a regression introduced in libpng-1.6.41. - (Contributed by Dan Rosser) - * Marked the installed libpng headers as system headers in CMake. - (Contributed by Benjamin Buch) - * Updated the build support for RISCOS. - (Contributed by Cameron Cawley) - * Updated the makefiles to allow cross-platform builds to initialize - conventional make variables like AR and ARFLAGS. - * Added various improvements to the CI scripts in areas like version - consistency verification and text linting. - * Added version consistency verification to pngtest.c also. + * Removed the ASM implementation of ARM Neon optimizations and updated + the build accordingly. Only the remaining C implementation shall be + used from now on, thus ensuring the support of the PAC/BTI security + features on ARM64. + (Contributed by Ross Burton and John Bowler) + * Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the + CMake build on FreeBSD/amd64. This is an important performance fix + on this platform. + * Applied various fixes and improvements to the CMake build. + (Contributed by Eric Riff, Benjamin Buch and Erik Scholz) + * Added fuzzing targets for the simplified read API. + (Contributed by Mikhail Khachayants) + * Fixed a build error involving pngtest.c under a custom config. + This was a regression introduced in a code cleanup in libpng-1.6.43. + (Contributed by Ben Wagner) + * Fixed and improved the config files for AppVeyor CI and Travis CI. Send comments/corrections/commendations to png-mng-implement at lists.sf.net. diff --git a/CHANGES b/CHANGES index 6eab52bae7..724ccca2d6 100644 --- a/CHANGES +++ b/CHANGES @@ -6196,7 +6196,27 @@ Version 1.6.43 [February 23, 2024] consistency verification and text linting. Added version consistency verification to pngtest.c also. -Version 1.6.44 [TODO] +Version 1.6.44 [September 12, 2024] + Hardened calculations in chroma handling to prevent overflows, and + relaxed a constraint in cHRM validation to accomodate the standard + ACES AP1 set of color primaries. + (Contributed by John Bowler) + Removed the ASM implementation of ARM Neon optimizations and updated + the build accordingly. Only the remaining C implementation shall be + used from now on, thus ensuring the support of the PAC/BTI security + features on ARM64. + (Contributed by Ross Burton and John Bowler) + Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the + CMake build on FreeBSD/amd64. This is an important performance fix + on this platform. + Applied various fixes and improvements to the CMake build. + (Contributed by Eric Riff, Benjamin Buch and Erik Scholz) + Added fuzzing targets for the simplified read API. + (Contributed by Mikhail Khachayants) + Fixed a build error involving pngtest.c under a custom config. + This was a regression introduced in a code cleanup in libpng-1.6.43. + (Contributed by Ben Wagner) + Fixed and improved the config files for AppVeyor CI and Travis CI. Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit diff --git a/CMakeLists.txt b/CMakeLists.txt index fc5256393d..16cc2617df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,8 @@ cmake_minimum_required(VERSION 3.6) set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) set(PNGLIB_REVISION 44) -#set(PNGLIB_SUBREVISION 0) -set(PNGLIB_SUBREVISION "git") +set(PNGLIB_SUBREVISION 0) +#set(PNGLIB_SUBREVISION "git") set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) diff --git a/README b/README index d0a3635bdf..3af606889b 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -README for libpng version 1.6.44.git -==================================== +README for libpng version 1.6.44 +================================ See the note about version numbers near the top of `png.h`. See `INSTALL` for instructions on how to install libpng. diff --git a/configure b/configure index 0718e6e1b4..f2048dd7f6 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for libpng 1.6.44.git. +# Generated by GNU Autoconf 2.72 for libpng 1.6.44. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.6.44.git' -PACKAGE_STRING='libpng 1.6.44.git' +PACKAGE_VERSION='1.6.44' +PACKAGE_STRING='libpng 1.6.44' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -1419,7 +1419,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures libpng 1.6.44.git to adapt to many kinds of systems. +'configure' configures libpng 1.6.44 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1490,7 +1490,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.6.44.git:";; + short | recursive ) echo "Configuration of libpng 1.6.44:";; esac cat <<\_ACEOF @@ -1687,7 +1687,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.6.44.git +libpng configure 1.6.44 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -1950,7 +1950,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.6.44.git, which was +It was created by libpng $as_me 1.6.44, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3431,7 +3431,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.6.44.git' + VERSION='1.6.44' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -3526,7 +3526,7 @@ fi -PNGLIB_VERSION=1.6.44.git +PNGLIB_VERSION=1.6.44 PNGLIB_MAJOR=1 PNGLIB_MINOR=6 PNGLIB_RELEASE=44 @@ -15539,7 +15539,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.6.44.git, which was +This file was extended by libpng $as_me 1.6.44, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15607,7 +15607,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libpng config.status 1.6.44.git +libpng config.status 1.6.44 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 2c6b3333c6..22113b265c 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng],[1.6.44.git],[png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng],[1.6.44],[png-mng-implement@lists.sourceforge.net]) AC_CONFIG_MACRO_DIR([scripts/autoconf]) # libpng does not follow GNU file name conventions (hence 'foreign') @@ -46,7 +46,7 @@ dnl automake, so the following is not necessary (and is not defined anyway): dnl AM_PREREQ([1.11.2]) dnl stop configure from automagically running automake -PNGLIB_VERSION=1.6.44.git +PNGLIB_VERSION=1.6.44 PNGLIB_MAJOR=1 PNGLIB_MINOR=6 PNGLIB_RELEASE=44 diff --git a/libpng-manual.txt b/libpng-manual.txt index 7988057599..2ce366d679 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -9,7 +9,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng version 1.6.36, December 2018, through 1.6.43 - February 2024 + libpng version 1.6.36, December 2018, through 1.6.44 - September 2024 Updated and distributed by Cosmin Truta Copyright (c) 2018-2024 Cosmin Truta diff --git a/libpng.3 b/libpng.3 index 45e76e4837..5a3c89cb9c 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "February 23, 2024" +.TH LIBPNG 3 "September 12, 2024" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.6.43 +libpng \- Portable Network Graphics (PNG) Reference Library 1.6.44 .SH SYNOPSIS \fB#include \fP @@ -528,7 +528,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng version 1.6.36, December 2018, through 1.6.43 - February 2024 + libpng version 1.6.36, December 2018, through 1.6.44 - September 2024 Updated and distributed by Cosmin Truta Copyright (c) 2018-2024 Cosmin Truta diff --git a/libpngpf.3 b/libpngpf.3 index 0abec74a2d..b7557ca27e 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,6 +1,6 @@ -.TH LIBPNGPF 3 "February 23, 2024" +.TH LIBPNGPF 3 "September 12, 2024" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.6.43 +libpng \- Portable Network Graphics (PNG) Reference Library 1.6.44 (private functions) .SH SYNOPSIS diff --git a/png.5 b/png.5 index a8a681813f..14a3c432bf 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "February 23, 2024" +.TH PNG 5 "September 12, 2024" .SH NAME png \- Portable Network Graphics (PNG) format diff --git a/png.c b/png.c index 465f758484..9a9fb23d94 100644 --- a/png.c +++ b/png.c @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_44_git Your_png_h_is_not_version_1_6_44_git; +typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -794,7 +794,7 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.44.git" PNG_STRING_NEWLINE \ + "libpng version 1.6.44" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index 6ac0171d9e..04a233f393 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.44.git + * libpng version 1.6.44 * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson @@ -15,7 +15,7 @@ * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.35, July 2018: * Glenn Randers-Pehrson - * libpng versions 1.6.36, December 2018, through 1.6.43, February 2024: + * libpng versions 1.6.36, December 2018, through 1.6.44, September 2024: * Cosmin Truta * See also "Contributing Authors", below. */ @@ -239,7 +239,7 @@ * ... * 1.5.30 15 10530 15.so.15.30[.0] * ... - * 1.6.43 16 10643 16.so.16.43[.0] + * 1.6.44 16 10644 16.so.16.44[.0] * * Henceforth the source version will match the shared-library major and * minor numbers; the shared-library major version number will be used for @@ -275,7 +275,7 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.44.git" +#define PNG_LIBPNG_VER_STRING "1.6.44" #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n" /* The versions of shared library builds should stay in sync, going forward */ @@ -291,7 +291,7 @@ /* This should be zero for a public release, or non-zero for a * development version. */ -#define PNG_LIBPNG_VER_BUILD 1 +#define PNG_LIBPNG_VER_BUILD 0 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -308,7 +308,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE /* Careful here. At one time, Guy wanted to use 082, but that * would be octal. We must not include leading zeros. @@ -317,7 +317,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10644 /* 1.6.44.git */ +#define PNG_LIBPNG_VER 10644 /* 1.6.44 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -427,7 +427,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_44_git; +typedef char* png_libpng_version_1_6_44; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * diff --git a/pngconf.h b/pngconf.h index 41785a3ca2..4a4b58ac81 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine-configurable file for libpng * - * libpng version 1.6.44.git + * libpng version 1.6.44 * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson diff --git a/pngtest.c b/pngtest.c index a4621a60f3..5969f50310 100644 --- a/pngtest.c +++ b/pngtest.c @@ -51,7 +51,7 @@ #define STDERR stdout /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_44_git Your_png_h_is_not_version_1_6_44_git; +typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44; /* Ensure that all version numbers in png.h are consistent with one another. */ #if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \ diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in index 2fb79d428a..3d26a0a6a2 100644 --- a/scripts/libpng-config-head.in +++ b/scripts/libpng-config-head.in @@ -11,7 +11,7 @@ # Modeled after libxml-config. -version=1.6.44.git +version=1.6.44 prefix="" libdir="" libs="" diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in index 73ed7f54dd..fc3f6f67fb 100644 --- a/scripts/libpng.pc.in +++ b/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng16 Name: libpng Description: Loads and saves PNG files -Version: 1.6.44.git +Version: 1.6.44 Libs: -L${libdir} -lpng16 Cflags: -I${includedir} diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 2c95cd5df2..f5ce441ecb 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -1,6 +1,6 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.6.44.git */ +/* libpng version 1.6.44 */ /* Copyright (c) 2018-2024 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ From ef153d5325600689e52f9685c8315f05c32cea65 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 11:46:34 +0300 Subject: [PATCH 045/112] Bump version to 1.6.45.git --- ANNOUNCE | 8 ++++++++ CHANGES | 2 ++ CMakeLists.txt | 6 +++--- README | 4 ++-- configure | 24 ++++++++++++------------ configure.ac | 6 +++--- png.c | 4 ++-- png.h | 14 +++++++------- pngconf.h | 2 +- pngtest.c | 2 +- scripts/libpng-config-head.in | 2 +- scripts/libpng.pc.in | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 13 files changed, 44 insertions(+), 34 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index a2a7ac363a..812507985b 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,3 +1,11 @@ +libpng 1.6.45.git +================= + +This is a development version, not intended to be a public release. +It will be replaced by a public release, or by another development +version, at a later time. + + libpng 1.6.44 - September 12, 2024 ================================== diff --git a/CHANGES b/CHANGES index 724ccca2d6..eff6fb0f49 100644 --- a/CHANGES +++ b/CHANGES @@ -6218,6 +6218,8 @@ Version 1.6.44 [September 12, 2024] (Contributed by Ben Wagner) Fixed and improved the config files for AppVeyor CI and Travis CI. +Version 1.6.45 [TODO] + Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/CMakeLists.txt b/CMakeLists.txt index 16cc2617df..ddda7c1cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,9 +19,9 @@ cmake_minimum_required(VERSION 3.6) set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) -set(PNGLIB_REVISION 44) -set(PNGLIB_SUBREVISION 0) -#set(PNGLIB_SUBREVISION "git") +set(PNGLIB_REVISION 45) +#set(PNGLIB_SUBREVISION 0) +set(PNGLIB_SUBREVISION "git") set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) diff --git a/README b/README index 3af606889b..5b4d13352e 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -README for libpng version 1.6.44 -================================ +README for libpng version 1.6.45.git +==================================== See the note about version numbers near the top of `png.h`. See `INSTALL` for instructions on how to install libpng. diff --git a/configure b/configure index f2048dd7f6..a7b74490d4 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for libpng 1.6.44. +# Generated by GNU Autoconf 2.72 for libpng 1.6.45.git. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.6.44' -PACKAGE_STRING='libpng 1.6.44' +PACKAGE_VERSION='1.6.45.git' +PACKAGE_STRING='libpng 1.6.45.git' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -1419,7 +1419,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures libpng 1.6.44 to adapt to many kinds of systems. +'configure' configures libpng 1.6.45.git to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1490,7 +1490,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.6.44:";; + short | recursive ) echo "Configuration of libpng 1.6.45.git:";; esac cat <<\_ACEOF @@ -1687,7 +1687,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.6.44 +libpng configure 1.6.45.git generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -1950,7 +1950,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.6.44, which was +It was created by libpng $as_me 1.6.45.git, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3431,7 +3431,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.6.44' + VERSION='1.6.45.git' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -3526,10 +3526,10 @@ fi -PNGLIB_VERSION=1.6.44 +PNGLIB_VERSION=1.6.45.git PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=44 +PNGLIB_RELEASE=45 @@ -15539,7 +15539,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.6.44, which was +This file was extended by libpng $as_me 1.6.45.git, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15607,7 +15607,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libpng config.status 1.6.44 +libpng config.status 1.6.45.git configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 22113b265c..012ae15dbd 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng],[1.6.44],[png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng],[1.6.45.git],[png-mng-implement@lists.sourceforge.net]) AC_CONFIG_MACRO_DIR([scripts/autoconf]) # libpng does not follow GNU file name conventions (hence 'foreign') @@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway): dnl AM_PREREQ([1.11.2]) dnl stop configure from automagically running automake -PNGLIB_VERSION=1.6.44 +PNGLIB_VERSION=1.6.45.git PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=44 +PNGLIB_RELEASE=45 dnl End of version number stuff diff --git a/png.c b/png.c index 9a9fb23d94..500daea5f4 100644 --- a/png.c +++ b/png.c @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44; +typedef png_libpng_version_1_6_45_git Your_png_h_is_not_version_1_6_45_git; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -794,7 +794,7 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.44" PNG_STRING_NEWLINE \ + "libpng version 1.6.45.git" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index 04a233f393..50834ad332 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.44 + * libpng version 1.6.45.git * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson @@ -275,7 +275,7 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.44" +#define PNG_LIBPNG_VER_STRING "1.6.45.git" #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n" /* The versions of shared library builds should stay in sync, going forward */ @@ -286,12 +286,12 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 44 +#define PNG_LIBPNG_VER_RELEASE 45 /* This should be zero for a public release, or non-zero for a * development version. */ -#define PNG_LIBPNG_VER_BUILD 0 +#define PNG_LIBPNG_VER_BUILD 1 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -308,7 +308,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA /* Careful here. At one time, Guy wanted to use 082, but that * would be octal. We must not include leading zeros. @@ -317,7 +317,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10644 /* 1.6.44 */ +#define PNG_LIBPNG_VER 10645 /* 1.6.45.git */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -427,7 +427,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_44; +typedef char* png_libpng_version_1_6_45_git; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * diff --git a/pngconf.h b/pngconf.h index 4a4b58ac81..77e7c2a149 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine-configurable file for libpng * - * libpng version 1.6.44 + * libpng version 1.6.45.git * * Copyright (c) 2018-2024 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson diff --git a/pngtest.c b/pngtest.c index 5969f50310..e19ed41ee2 100644 --- a/pngtest.c +++ b/pngtest.c @@ -51,7 +51,7 @@ #define STDERR stdout /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44; +typedef png_libpng_version_1_6_45_git Your_png_h_is_not_version_1_6_45_git; /* Ensure that all version numbers in png.h are consistent with one another. */ #if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \ diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in index 3d26a0a6a2..17e233432f 100644 --- a/scripts/libpng-config-head.in +++ b/scripts/libpng-config-head.in @@ -11,7 +11,7 @@ # Modeled after libxml-config. -version=1.6.44 +version=1.6.45.git prefix="" libdir="" libs="" diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in index fc3f6f67fb..f9a0835349 100644 --- a/scripts/libpng.pc.in +++ b/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng16 Name: libpng Description: Loads and saves PNG files -Version: 1.6.44 +Version: 1.6.45.git Libs: -L${libdir} -lpng16 Cflags: -I${includedir} diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index f5ce441ecb..c46f7c4035 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -1,6 +1,6 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.6.44 */ +/* libpng version 1.6.45.git */ /* Copyright (c) 2018-2024 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ From b7276eca0182bb6ad174ef044bb5f6f0504451af Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 13:40:59 +0300 Subject: [PATCH 046/112] oss-fuzz: Transfer to an external repo and remove from this repo A new repository named "pngfuzz", dedicated to fuzz testing PNG processing software in general and libpng in particular, has been created: https://github.com/pnggroup/pngfuzz Signed-off-by: Cosmin Truta --- contrib/oss-fuzz/Dockerfile | 28 --- contrib/oss-fuzz/README.txt | 40 ---- contrib/oss-fuzz/build.sh | 47 ---- contrib/oss-fuzz/libpng_read_fuzzer.cc | 224 -------------------- contrib/oss-fuzz/libpng_read_fuzzer.options | 2 - contrib/oss-fuzz/png.dict | 39 ---- 6 files changed, 380 deletions(-) delete mode 100644 contrib/oss-fuzz/Dockerfile delete mode 100644 contrib/oss-fuzz/README.txt delete mode 100755 contrib/oss-fuzz/build.sh delete mode 100644 contrib/oss-fuzz/libpng_read_fuzzer.cc delete mode 100644 contrib/oss-fuzz/libpng_read_fuzzer.options delete mode 100644 contrib/oss-fuzz/png.dict diff --git a/contrib/oss-fuzz/Dockerfile b/contrib/oss-fuzz/Dockerfile deleted file mode 100644 index c9bc4145e0..0000000000 --- a/contrib/oss-fuzz/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2024 Cosmin Truta -# Copyright 2017 Glenn Randers-Pehrson -# Copyright 2016 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -################################################################################ - -FROM gcr.io/oss-fuzz-base/base-builder - -RUN apt-get update && \ - apt-get install -y make autoconf automake libtool zlib1g-dev - -RUN git clone --depth=1 https://github.com/pnggroup/libpng.git && \ - git clone --depth=1 https://github.com/madler/zlib.git && \ - cp libpng/contrib/oss-fuzz/build.sh $SRC - -WORKDIR /home/libpng diff --git a/contrib/oss-fuzz/README.txt b/contrib/oss-fuzz/README.txt deleted file mode 100644 index b01af52acc..0000000000 --- a/contrib/oss-fuzz/README.txt +++ /dev/null @@ -1,40 +0,0 @@ -libpng additions to oss-fuzz -============================ - -Copyright (c) 2024 Cosmin Truta -Copyright (c) 2017 Glenn Randers-Pehrson - -This code is released under the libpng license. -For conditions of distribution and use, see the disclaimer -and license in png.h - -Files in this directory are used by the oss-fuzz project -(https://github.com/google/oss-fuzz/tree/master/projects/libpng). -for "fuzzing" libpng. - -They were licensed by Google Inc, using the BSD-like Chromium license, -which may be found at https://cs.chromium.org/chromium/src/LICENSE, or, if -noted in the source, under the Apache-2.0 license, which may -be found at http://www.apache.org/licenses/LICENSE-2.0 . -If they have been modified, the derivatives are copyright Glenn Randers-Pehrson -and are released under the same licenses as the originals. Several of -the original files (libpng_read_fuzzer.options, png.dict, project.yaml) -had no licensing information; we assumed that these were under the Chromium -license. Any new files are released under the libpng license (see png.h). - -The files are - Original - Filename or derived Copyright License - ========================= ========== ================ ========== - Dockerfile* derived 2017, Glenn R-P Apache 2.0 - build.sh derived 2017, Glenn R-P Apache 2.0 - libpng_read_fuzzer.cc derived 2017, Glenn R-P Chromium - libpng_read_fuzzer.options original 2015, Chrome Devs Chromium - png.dict original 2015, Chrome Devs Chromium - README.txt (this file) original 2017, Glenn R-P libpng - - * Dockerfile is a copy of the file used by oss-fuzz. build.sh, - png.dict and libpng_read_fuzzer.* are the actual files used by oss-fuzz, - which retrieves them from the libpng repository at Github. - -To do: exercise the progressive reader and the png encoder. diff --git a/contrib/oss-fuzz/build.sh b/contrib/oss-fuzz/build.sh deleted file mode 100755 index 1970f9c06c..0000000000 --- a/contrib/oss-fuzz/build.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -set -eu - -# Copyright 2024 Cosmin Truta -# Copyright 2017 Glenn Randers-Pehrson -# Copyright 2016 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -################################################################################ - -# Disable logging via library build configuration control. -sed -e "s/option STDIO/option STDIO disabled/" \ - -e "s/option WARNING /option WARNING disabled/" \ - -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ - scripts/pnglibconf.dfa >scripts/pnglibconf.dfa.tmp -mv -f scripts/pnglibconf.dfa.tmp scripts/pnglibconf.dfa - -# Build the libpng library ("libpng16.la"), excluding the auxiliary tools. -autoreconf -f -i -./configure --with-libpng-prefix=OSS_FUZZ_ -make -j$(nproc) clean -make -j$(nproc) libpng16.la - -# Build libpng_read_fuzzer. -$CXX $CXXFLAGS -std=c++11 -I. \ - $SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \ - -o $OUT/libpng_read_fuzzer \ - -lFuzzingEngine .libs/libpng16.a -lz - -# Add seed corpus. -find $SRC/libpng -name "*.png" | grep -v crashers | \ - xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip - -cp $SRC/libpng/contrib/oss-fuzz/*.dict \ - $SRC/libpng/contrib/oss-fuzz/*.options \ - $OUT/ diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.cc b/contrib/oss-fuzz/libpng_read_fuzzer.cc deleted file mode 100644 index ad9f9adc6a..0000000000 --- a/contrib/oss-fuzz/libpng_read_fuzzer.cc +++ /dev/null @@ -1,224 +0,0 @@ - -// libpng_read_fuzzer.cc -// Copyright 2017-2018 Glenn Randers-Pehrson -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that may -// be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE - -// The modifications in 2017 by Glenn Randers-Pehrson include -// 1. addition of a PNG_CLEANUP macro, -// 2. setting the option to ignore ADLER32 checksums, -// 3. adding "#include " which is needed on some platforms -// to provide memcpy(). -// 4. adding read_end_info() and creating an end_info structure. -// 5. adding calls to png_set_*() transforms commonly used by browsers. - -#include -#include -#include -#include - -#include - -#define PNG_INTERNAL -#include "png.h" - -#define PNG_CLEANUP \ - if(png_handler.png_ptr) \ - { \ - if (png_handler.row_ptr) \ - png_free(png_handler.png_ptr, png_handler.row_ptr); \ - if (png_handler.end_info_ptr) \ - png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\ - &png_handler.end_info_ptr); \ - else if (png_handler.info_ptr) \ - png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\ - nullptr); \ - else \ - png_destroy_read_struct(&png_handler.png_ptr, nullptr, nullptr); \ - png_handler.png_ptr = nullptr; \ - png_handler.row_ptr = nullptr; \ - png_handler.info_ptr = nullptr; \ - png_handler.end_info_ptr = nullptr; \ - } - -struct BufState { - const uint8_t* data; - size_t bytes_left; -}; - -struct PngObjectHandler { - png_infop info_ptr = nullptr; - png_structp png_ptr = nullptr; - png_infop end_info_ptr = nullptr; - png_voidp row_ptr = nullptr; - BufState* buf_state = nullptr; - - ~PngObjectHandler() { - if (row_ptr) - png_free(png_ptr, row_ptr); - if (end_info_ptr) - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info_ptr); - else if (info_ptr) - png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); - else - png_destroy_read_struct(&png_ptr, nullptr, nullptr); - delete buf_state; - } -}; - -void user_read_data(png_structp png_ptr, png_bytep data, size_t length) { - BufState* buf_state = static_cast(png_get_io_ptr(png_ptr)); - if (length > buf_state->bytes_left) { - png_error(png_ptr, "read error"); - } - memcpy(data, buf_state->data, length); - buf_state->bytes_left -= length; - buf_state->data += length; -} - -void* limited_malloc(png_structp, png_alloc_size_t size) { - // libpng may allocate large amounts of memory that the fuzzer reports as - // an error. In order to silence these errors, make libpng fail when trying - // to allocate a large amount. This allocator used to be in the Chromium - // version of this fuzzer. - // This number is chosen to match the default png_user_chunk_malloc_max. - if (size > 8000000) - return nullptr; - - return malloc(size); -} - -void default_free(png_structp, png_voidp ptr) { - return free(ptr); -} - -static const int kPngHeaderSize = 8; - -// Entry point for LibFuzzer. -// Roughly follows the libpng book example: -// http://www.libpng.org/pub/png/book/chapter13.html -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - if (size < kPngHeaderSize) { - return 0; - } - - std::vector v(data, data + size); - if (png_sig_cmp(v.data(), 0, kPngHeaderSize)) { - // not a PNG. - return 0; - } - - PngObjectHandler png_handler; - png_handler.png_ptr = nullptr; - png_handler.row_ptr = nullptr; - png_handler.info_ptr = nullptr; - png_handler.end_info_ptr = nullptr; - - png_handler.png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); - if (!png_handler.png_ptr) { - return 0; - } - - png_handler.info_ptr = png_create_info_struct(png_handler.png_ptr); - if (!png_handler.info_ptr) { - PNG_CLEANUP - return 0; - } - - png_handler.end_info_ptr = png_create_info_struct(png_handler.png_ptr); - if (!png_handler.end_info_ptr) { - PNG_CLEANUP - return 0; - } - - // Use a custom allocator that fails for large allocations to avoid OOM. - png_set_mem_fn(png_handler.png_ptr, nullptr, limited_malloc, default_free); - - png_set_crc_action(png_handler.png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); -#ifdef PNG_IGNORE_ADLER32 - png_set_option(png_handler.png_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON); -#endif - - // Setting up reading from buffer. - png_handler.buf_state = new BufState(); - png_handler.buf_state->data = data + kPngHeaderSize; - png_handler.buf_state->bytes_left = size - kPngHeaderSize; - png_set_read_fn(png_handler.png_ptr, png_handler.buf_state, user_read_data); - png_set_sig_bytes(png_handler.png_ptr, kPngHeaderSize); - - if (setjmp(png_jmpbuf(png_handler.png_ptr))) { - PNG_CLEANUP - return 0; - } - - // Reading. - png_read_info(png_handler.png_ptr, png_handler.info_ptr); - - // reset error handler to put png_deleter into scope. - if (setjmp(png_jmpbuf(png_handler.png_ptr))) { - PNG_CLEANUP - return 0; - } - - png_uint_32 width, height; - int bit_depth, color_type, interlace_type, compression_type; - int filter_type; - - if (!png_get_IHDR(png_handler.png_ptr, png_handler.info_ptr, &width, - &height, &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_type)) { - PNG_CLEANUP - return 0; - } - - // This is going to be too slow. - if (width && height > 100000000 / width) { - PNG_CLEANUP - return 0; - } - - // Set several transforms that browsers typically use: - png_set_gray_to_rgb(png_handler.png_ptr); - png_set_expand(png_handler.png_ptr); - png_set_packing(png_handler.png_ptr); - png_set_scale_16(png_handler.png_ptr); - png_set_tRNS_to_alpha(png_handler.png_ptr); - - int passes = png_set_interlace_handling(png_handler.png_ptr); - - png_read_update_info(png_handler.png_ptr, png_handler.info_ptr); - - png_handler.row_ptr = png_malloc( - png_handler.png_ptr, png_get_rowbytes(png_handler.png_ptr, - png_handler.info_ptr)); - - for (int pass = 0; pass < passes; ++pass) { - for (png_uint_32 y = 0; y < height; ++y) { - png_read_row(png_handler.png_ptr, - static_cast(png_handler.row_ptr), nullptr); - } - } - - png_read_end(png_handler.png_ptr, png_handler.end_info_ptr); - - PNG_CLEANUP - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED - // Simplified READ API - png_image image; - memset(&image, 0, (sizeof image)); - image.version = PNG_IMAGE_VERSION; - - if (!png_image_begin_read_from_memory(&image, data, size)) { - return 0; - } - - image.format = PNG_FORMAT_RGBA; - std::vector buffer(PNG_IMAGE_SIZE(image)); - png_image_finish_read(&image, NULL, buffer.data(), 0, NULL); -#endif - - return 0; -} diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.options b/contrib/oss-fuzz/libpng_read_fuzzer.options deleted file mode 100644 index 2005291a0f..0000000000 --- a/contrib/oss-fuzz/libpng_read_fuzzer.options +++ /dev/null @@ -1,2 +0,0 @@ -[libfuzzer] -dict = png.dict diff --git a/contrib/oss-fuzz/png.dict b/contrib/oss-fuzz/png.dict deleted file mode 100644 index 3a8a113830..0000000000 --- a/contrib/oss-fuzz/png.dict +++ /dev/null @@ -1,39 +0,0 @@ -# -# AFL dictionary for PNG images -# ----------------------------- -# -# Just the basic, standard-originating sections; does not include vendor -# extensions. -# -# Created by Michal Zalewski -# - -header_png="\x89PNG\x0d\x0a\x1a\x0a" - -section_IDAT="IDAT" -section_IEND="IEND" -section_IHDR="IHDR" -section_PLTE="PLTE" -section_bKGD="bKGD" -section_cHRM="cHRM" -section_eXIf="eXIf" -section_fRAc="fRAc" -section_gAMA="gAMA" -section_gIFg="gIFg" -section_gIFt="gIFt" -section_gIFx="gIFx" -section_hIST="hIST" -section_iCCP="iCCP" -section_iTXt="iTXt" -section_oFFs="oFFs" -section_pCAL="pCAL" -section_pHYs="pHYs" -section_sBIT="sBIT" -section_sCAL="sCAL" -section_sPLT="sPLT" -section_sRGB="sRGB" -section_sTER="sTER" -section_tEXt="tEXt" -section_tIME="tIME" -section_tRNS="tRNS" -section_zTXt="zTXt" From e3c7b26fbda501013742d49df37abede3901026d Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 16:38:02 +0300 Subject: [PATCH 047/112] ci: Fix bad (but innocuous) copy pasta in ci_verify_version.sh --- ci/ci_verify_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/ci_verify_version.sh b/ci/ci_verify_version.sh index c786f06acd..c8ed225062 100755 --- a/ci/ci_verify_version.sh +++ b/ci/ci_verify_version.sh @@ -89,9 +89,9 @@ function ci_verify_version { fi if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_STABLE ]] then - ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_BETA" + ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_STABLE" else - ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_BETA" + ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_STABLE" fi elif [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect".git ]] then From 222dd7ca495fb18c6d29c3e46574093d178d0b22 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 18:53:00 +0300 Subject: [PATCH 048/112] doc: Make a small correction about branches in the libpng manual --- libpng-manual.txt | 2 +- libpng.3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libpng-manual.txt b/libpng-manual.txt index 2ce366d679..ce7bbd3182 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -5173,7 +5173,7 @@ a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes it possible to skip IDAT chunks in the sequential reader. The machine-generated configure files are no longer included in branches -libpng16 and later of the GIT repository. They continue to be included +libpng17 and later of the GIT repository. They continue to be included in the tarball releases, however. Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT diff --git a/libpng.3 b/libpng.3 index 5a3c89cb9c..4bb92d422e 100644 --- a/libpng.3 +++ b/libpng.3 @@ -5692,7 +5692,7 @@ a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes it possible to skip IDAT chunks in the sequential reader. The machine-generated configure files are no longer included in branches -libpng16 and later of the GIT repository. They continue to be included +libpng17 and later of the GIT repository. They continue to be included in the tarball releases, however. Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT From c0f3dd43d877f6f07e19043295e82f224eddfc2f Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 22:35:51 +0300 Subject: [PATCH 049/112] doc: Update the README and TODO files --- README | 2 - TODO | 43 +++++++------- contrib/README.txt | 2 + scripts/README.txt | 136 ++++++++++++++++++++++----------------------- 4 files changed, 88 insertions(+), 95 deletions(-) diff --git a/README b/README index 5b4d13352e..a4a32ec25c 100644 --- a/README +++ b/README @@ -157,8 +157,6 @@ Files included in this distribution "PNG: The Definitive Guide" by Greg Roelofs, O'Reilly, 1999 libtests/ => Test programs - oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing - libpng pngexif/ => Program to inspect the EXIF information in PNG files pngminim/ => Minimal decoder, encoder, and progressive decoder programs demonstrating the use of pngusr.dfa diff --git a/TODO b/TODO index 562dab0696..8ddb7d123c 100644 --- a/TODO +++ b/TODO @@ -1,23 +1,22 @@ -TODO - list of things to do for libpng: +TODO list for libpng +-------------------- -* Fix all defects (duh!) -* Better C++ wrapper / full C++ implementation (?) -* Fix the problems with C++ and 'extern "C"'. -* cHRM transformation. -* Palette creation. -* "grayscale->palette" transformation and "palette->grayscale" detection. -* Improved dithering. -* Multi-lingual error and warning message support. -* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.) -* Man pages for function calls. -* Better documentation. -* Better filter selection - (e.g., counting huffman bits/precompression; filter inertia; filter costs). -* Histogram creation. -* Text conversion between different code pages (e.g., Latin-1 -> Mac). -* Avoid building gamma tables whenever possible. -* Greater precision in changing to linear gamma for compositing against - background, and in doing rgb-to-gray transformations. -* Investigate pre-incremented loop counters and other loop constructions. -* Interpolated method of handling interlacing. -* More validations for libpng transformations. + * Fix all defects (duh!) + * cHRM transformation. + * Palette creation. + * "grayscale->palette" transformation and "palette->grayscale" detection. + * Improved dithering. + * Multi-lingual error and warning message support. + * Complete sRGB transformation. (Currently it simply uses gamma=0.45455.) + * Man pages for function calls. + * Better documentation. + * Better filter selection + (e.g., counting huffman bits/precompression; filter inertia; filter costs). + * Histogram creation. + * Text conversion between different code pages (e.g., Latin-1 to Mac). + * Avoid building gamma tables whenever possible. + * Greater precision in changing to linear gamma for compositing against + background, and in doing rgb-to-gray transformations. + * Investigate pre-incremented loop counters and other loop constructions. + * Interpolated method of handling interlacing. + * More validations for libpng transformations. diff --git a/contrib/README.txt b/contrib/README.txt index 97963c6d54..34dfbae4c4 100644 --- a/contrib/README.txt +++ b/contrib/README.txt @@ -1,3 +1,5 @@ +External contributions to libpng +-------------------------------- This "contrib" directory contains contributions which are not necessarily under the libpng license, although all are open source. They are not part of diff --git a/scripts/README.txt b/scripts/README.txt index 326160cbb2..3764e79a71 100644 --- a/scripts/README.txt +++ b/scripts/README.txt @@ -1,79 +1,73 @@ +Scripts and makefiles for libpng +-------------------------------- -Makefiles for libpng + pnglibconf.h.prebuilt => Configuration settings -pnglibconf.h.prebuilt => Configuration settings - makefile.linux => Linux/ELF makefile - (gcc, creates shared libpng16.so.16.1.6.*) - makefile.linux-opt=> Linux/ELF makefile with hardware optimizations on - (gcc, creates shared libpng16.so.16.1.6.*) - makefile.gcc => Generic makefile (gcc, creates static libpng.a) - makefile.acorn => Acorn makefile - makefile.aix => AIX/gcc makefile - makefile.amiga => Amiga makefile - makefile.atari => Atari makefile - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.beos => BeOS makefile - makefile.clang => Generic clang makefile - makefile.darwin => Darwin makefile, for macOS (formerly Mac OS X) - makefile.dec => DEC Alpha UNIX makefile - makefile.dj2 => DJGPP 2 makefile - makefile.freebsd => FreeBSD makefile - makefile.gcc => Generic gcc makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) - makefile.intel => Intel C/C++ version 4.0 and later - makefile.mips => MIPS makefile - makefile.netbsd => NetBSD/cc makefile, makes shared libpng.so - makefile.openbsd => OpenBSD makefile - makefile.sco => SCO OSr5 ELF and Unixware 7 with Native cc - makefile.sggcc => Silicon Graphics makefile - (gcc, creates shared libpng16.so.16.1.6.*) - makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) - makefile.solaris => Solaris 2.X makefile - (gcc, creates shared libpng16.so.16.1.6.*) - makefile.so9 => Solaris 9 makefile - (gcc, creates shared libpng16.so.16.1.6.*) - makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.sunos => Sun makefile - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later - makevms.com => VMS build script - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler - (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) + makefile.aix => AIX/gcc makefile + makefile.amiga => Amiga makefile + makefile.atari => Atari makefile + makefile.bc32 => Borland C makefile, for Win32 + makefile.beos => BeOS makefile + makefile.clang => Generic clang makefile + makefile.darwin => Darwin makefile, for macOS (formerly Mac OS X) + makefile.dec => DEC Alpha UNIX makefile + makefile.dj2 => DJGPP 2 makefile + makefile.emcc => Emscripten makefile + makefile.freebsd => FreeBSD makefile + makefile.gcc => Generic gcc makefile + makefile.hpgcc => HPUX makefile using gcc + makefile.hpux => HPUX (10.20 and 11.00) makefile + makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit + makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static lib) + makefile.intel => Intel C/C++ version 4.0 and later + makefile.linux => Linux/ELF makefile + (gcc, creates shared libpng16.so.16.1.6.*) + makefile.mips => MIPS makefile + makefile.msys => MSYS (MinGW) makefile + makefile.netbsd => NetBSD/cc makefile, makes shared libpng.so + makefile.openbsd => OpenBSD makefile + makefile.riscos => Acorn RISCOS makefile + makefile.sco => SCO OSr5 ELF and Unixware 7 with Native cc + makefile.sgi => Silicon Graphics IRIX makefile (cc, static lib) + makefile.sggcc => Silicon Graphics makefile + (gcc, creates shared libpng16.so.16.1.6.*) + makefile.solaris => Solaris 2.X makefile + (gcc, creates shared libpng16.so.16.1.6.*) + makefile.so9 => Solaris 9 makefile + (gcc, creates shared libpng16.so.16.1.6.*) + makefile.std => Generic UNIX makefile (cc, static lib) + makefile.sunos => Sun makefile + makefile.32sunu => Sun Ultra 32-bit makefile + makefile.64sunu => Sun Ultra 64-bit makefile + makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later + makevms.com => VMS build script + smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler + (Requires SCOPTIONS, copied from SCOPTIONS.ppc) -Other supporting scripts: - README.txt => This file - descrip.mms => VMS makefile for MMS or MMK - libpng-config-body.in => used by several makefiles to create libpng-config - libpng-config-head.in => used by several makefiles to create libpng-config - libpng.pc.in => Used by several makefiles to create libpng.pc - pngwin.rc => Used by the visualc71 project - pngwin.def => Used by makefile.os2 - pngwin.dfn => Used to maintain pngwin.def - SCOPTIONS.ppc => Used with smakefile.ppc +Other supporting scripts +------------------------ - checksym.awk => Used for maintaining pnglibconf.h - def.dfn => Used for maintaining pnglibconf.h - options.awk => Used for maintaining pnglibconf.h - pnglibconf.dfa => Used for maintaining pnglibconf.h - pnglibconf.mak => Used for maintaining pnglibconf.h - sym.dfn => Used for symbol versioning - symbols.def => Used for symbol versioning - symbols.dfn => Used for symbol versioning - vers.dfn => Used for symbol versioning + README.txt => This file + descrip.mms => VMS makefile for MMS or MMK + libpng-config-body.in => used by several makefiles to create libpng-config + libpng-config-head.in => used by several makefiles to create libpng-config + libpng.pc.in => Used by several makefiles to create libpng.pc + macro.lst => Used by GNU Autotools + pngwin.rc => Used by the visualc71 project + pngwin.def => Used by makefile.os2 + pngwin.dfn => Used to maintain pngwin.def + SCOPTIONS.ppc => Used with smakefile.ppc - libtool.m4 => Used by autoconf tools - ltoptions.m4 => Used by autoconf tools - ltsugar.m4 => Used by autoconf tools - ltversion.m4 => Used by autoconf tools - lt~obsolete.m4 => Used by autoconf tools - - intprefix.dfn => Used by autoconf tools - macro.lst => Used by autoconf tools - prefix.dfn => Used by autoconf tools + checksym.awk => Used for maintaining pnglibconf.h + dfn.awk => Used for maintaining pnglibconf.h + options.awk => Used for maintaining pnglibconf.h + pnglibconf.dfa => Used for maintaining pnglibconf.h + pnglibconf.mak => Used for maintaining pnglibconf.h + intprefix.c => Used for symbol versioning + prefix.c => Used for symbol versioning + sym.c => Used for symbol versioning + symbols.c => Used for symbol versioning + vers.c => Used for symbol versioning Further information can be found in comments in the individual scripts and makefiles. From 68d7ce8040a611e9166890e02ecc409a03d76c2e Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 22:41:01 +0300 Subject: [PATCH 050/112] ci: Get ready for the upcoming branch 'libpng18' --- .appveyor.yml | 2 +- .github/workflows/lint.yml | 2 ++ .travis.yml | 2 +- ci/ci_verify_version.sh | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ee3d27ad34..495d90afb4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ version: 1.6.x-{build} branches: except: - - /libpng[0-1][0-7]/ + - /libpng[0-1][0-8]/ - /v[0-1][.][0-7][.][0-9]+/ image: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b41c103287..ddc483d999 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,9 +4,11 @@ on: push: branches: - libpng16 + - libpng18 pull_request: branches: - libpng16 + - libpng18 jobs: lint: diff --git a/.travis.yml b/.travis.yml index f14e7c1cad..5b3369e25f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ branches: except: - - /libpng[0-1][0-7]/ + - /libpng[0-1][0-8]/ - /v[0-1][.][0-7][.][0-9]+/ language: c diff --git a/ci/ci_verify_version.sh b/ci/ci_verify_version.sh index c8ed225062..3203b201f0 100755 --- a/ci/ci_verify_version.sh +++ b/ci/ci_verify_version.sh @@ -101,11 +101,11 @@ function ci_verify_version { else ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -eq 0" fi - if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_BETA ]] + if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -ne $PNG_LIBPNG_BUILD_STABLE ]] then - ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_BETA" + ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_STABLE" else - ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_BETA" + ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_STABLE" fi else ci_err "unexpected: \$PNG_LIBPNG_VER_STRING == '$PNG_LIBPNG_VER_STRING'" From 18ab7d09dd297a27b863a9ab28c84563fa57f146 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 15 Sep 2024 20:03:45 +0300 Subject: [PATCH 051/112] [libpng16] chore: Reorganize and update .gitignore Ignore the files and the directories that are typically produced by text editors, development tools, development environments, etc. This is a cherry-pick of commit 050aa7bb936c8889a41942b0b83f5db8582bce17 from branch 'libpng18'. --- .gitignore | 96 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 52e789d2b1..d00305acf2 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ # Compiled executables *.app/ *.exe +a.out # Debug files *.dSYM/ @@ -38,24 +39,95 @@ *.pdb *.su +# Tag files +TAGS +.TAGS +!TAGS/ +tags +.tags +!tags/ +gtags.files +GTAGS +GRTAGS +GPATH +GSYMS +cscope.files +cscope.out +cscope.*.out + +# Text editing and text processing artifacts +\#*\# +.\#* +[._]*.sw[a-p] +[._]sw[a-p] +*.bak +*.orig +*.rej +*.tmp +*~ + +# IDE files and directories +## Eclipse +.cproject/ +.project/ +.settings/ +## JetBrains +.idea/ +## NetBeans +nbbuild/ +nbdist/ +nbproject/ +## Visual Studio +.vs/ +### Visual Studio user files +*.rsuser +*.sln.docstates +*.suo +*.user +*.userosscache +*.userprefs +### Visual Studio cache files (for older versions) +*.aps +*.cachefile +*.ncb +*.opensdf +*.sdf +*.VC.db +*.VC.opendb +ipch/ +## Visual Studio Code +.vscode/* +!.vscode/extensions.json +!.vscode/launch.json +!.vscode/settings.json +!.vscode/tasks.json +## (Various) +[._]*_history +.history/ + +# Build, test and CI output directories +*[Dd]ebug/ +*[Rr]elease/ +*[Rr]eleases/ +[Ll]og/ +[Ll]ogs/ +[Oo]ut/ + # Libpng configuration and build artifacts *.out +*out.png .deps/ .dirstamp /Makefile /autom4te.cache/ -/config.guess~ -/config.h.in~ +/config*~ +/config.h /config.log /config.status -/config.sub~ -/configure~ -/install-sh~ -/libpng-config -/libpng.pc +/install*~ +/libpng*-config +/libpng*.pc /libpng.vers -/libpng16-config -/libpng16.pc /libtool /stamp-h1 pnglibconf.[ch] @@ -63,7 +135,7 @@ pnglibconf.dfn pnglibconf.pre pngprefix.h -# Libpng test artifacts +# Libpng test programs png-fix-itxt pngcp pngfix @@ -73,7 +145,3 @@ pngtest pngunknown pngvalid timepng -pngout.png - -# Libpng CI artifacts -out/ From cb08862674242d071c39045c43ac38ff1b3c5910 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 15 Sep 2024 22:33:31 +0300 Subject: [PATCH 052/112] [libpng16] chore: Set the `indent_size` fields in .editorconfig Also add an .editorconfig-checker.json file. We need to instruct the editorconfig-checker program to skip the checks for the indent size. (As of this commit time, editorconfig-checker is too rigid to recognize "smart indentations".) This is a cherry-pick of commit 67c99f75cf05b354f89c01c8fc15948300e84143 from branch 'libpng18'. Co-authored-by: John Bowler Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- .editorconfig | 16 ++++++++++++++-- .editorconfig-checker.json | 9 +++++++++ contrib/.editorconfig | 2 ++ contrib/pngexif/.editorconfig | 1 + contrib/visupng/.editorconfig | 3 ++- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .editorconfig-checker.json diff --git a/.editorconfig b/.editorconfig index f49b2a3e47..3497949882 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,29 +8,41 @@ insert_final_newline = true trim_trailing_whitespace = true [*.txt] +indent_size = unset indent_style = space [*.[chS]] +indent_size = 3 indent_style = space max_doc_length = 80 max_line_length = 80 [*.dfa] +indent_size = 3 indent_style = space max_doc_length = 80 max_line_length = 80 -[*.{awk,cmake}] +[*.awk] +indent_size = 3 indent_style = space max_doc_length = 80 max_line_length = 100 -[*.{in,sh}] +[*.cmake] +indent_size = 2 +indent_style = space +max_doc_length = 80 +max_line_length = 100 + +[*.sh] +indent_size = 4 indent_style = space max_doc_length = 100 max_line_length = 100 [{Makefile.in,ltmain.sh}] +indent_size = unset indent_style = unset insert_final_newline = unset max_doc_length = unset diff --git a/.editorconfig-checker.json b/.editorconfig-checker.json new file mode 100644 index 0000000000..ef08e0801e --- /dev/null +++ b/.editorconfig-checker.json @@ -0,0 +1,9 @@ +{ + "Disable": { + "IndentSize": true + }, + "Exclude": [ + ".git/", + "out/" + ] +} diff --git a/contrib/.editorconfig b/contrib/.editorconfig index e1b551df73..8b1466b1d9 100644 --- a/contrib/.editorconfig +++ b/contrib/.editorconfig @@ -3,5 +3,7 @@ root = false [*.[ch]] +indent_size = unset +indent_style = unset max_doc_length = unset max_line_length = unset diff --git a/contrib/pngexif/.editorconfig b/contrib/pngexif/.editorconfig index ce8fbbfc1b..e00082696d 100644 --- a/contrib/pngexif/.editorconfig +++ b/contrib/pngexif/.editorconfig @@ -4,6 +4,7 @@ root = true [*] charset = utf-8 +indent_size = 4 indent_style = space insert_final_newline = true max_doc_length = 79 diff --git a/contrib/visupng/.editorconfig b/contrib/visupng/.editorconfig index d946b14461..d5bcb53121 100644 --- a/contrib/visupng/.editorconfig +++ b/contrib/visupng/.editorconfig @@ -5,7 +5,8 @@ root = true [*] charset = utf-8 end_of_line = unset -indent_style = unset +indent_size = 4 +indent_style = space insert_final_newline = true max_doc_length = 80 max_line_length = 100 From bcb312414161d339fa97fec4d8d14e483a1efc07 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 17 Sep 2024 16:00:48 +0300 Subject: [PATCH 053/112] [libpng16] ci: Update ci_lint.sh to recognize .editorconfig-checker.json As the editorconfig-checker program is transitioning from using the .ecrc config file to the .editorconfig-checker.json config file, the older program versions do not recognize the new config file name. Update ci_lint.sh to instruct editorconfig-checker to pick up its configuration from the new config file name, regardless of the program version. Also update ci_lint.sh to instruct yamllint to check all *.json files, including .editorconfig-checker.json. This is a cherry-pick of commit 77f88338a19a223cc678e1a6a04888a31c78dabf from branch 'libpng18'. --- ci/ci_lint.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/ci_lint.sh b/ci/ci_lint.sh index d1754715d2..163d955ded 100755 --- a/ci/ci_lint.sh +++ b/ci/ci_lint.sh @@ -80,7 +80,7 @@ function ci_lint_text_files { } ci_info "## LINTING: text files ##" ci_spawn "$CI_EDITORCONFIG_CHECKER" --version - ci_spawn "$CI_EDITORCONFIG_CHECKER" || { + ci_spawn "$CI_EDITORCONFIG_CHECKER" --config .editorconfig-checker.json || { # Linting failed. return 1 } @@ -93,7 +93,9 @@ function ci_lint_yaml_files { } ci_info "## LINTING: YAML files ##" ci_spawn "$CI_YAMLLINT" --version - find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" | { + # Considering that the YAML format is an extension of the JSON format, + # we can lint both the YAML files and the plain JSON files here. + find . \( -iname "*.yml" -o -iname "*.yaml" -o -iname "*.json" \) -not -path "./out/*" | { local my_file while IFS="" read -r my_file do From cd5e582fd6217fad4a2f5b1535089f328318335a Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 19 Sep 2024 21:26:25 +0300 Subject: [PATCH 054/112] Revert "oss-fuzz: Transfer to an external repo and remove from this repo" This reverts commit b7276eca0182bb6ad174ef044bb5f6f0504451af. Although the brand new pngfuzz repo is coming up next, it turned out that the deletion of contrib/oss-fuzz/ from the 'libpng16' branch was premature. (Oopsie!) Signed-off-by: Cosmin Truta --- contrib/oss-fuzz/Dockerfile | 28 +++ contrib/oss-fuzz/README.txt | 40 ++++ contrib/oss-fuzz/build.sh | 47 ++++ contrib/oss-fuzz/libpng_read_fuzzer.cc | 224 ++++++++++++++++++++ contrib/oss-fuzz/libpng_read_fuzzer.options | 2 + contrib/oss-fuzz/png.dict | 39 ++++ 6 files changed, 380 insertions(+) create mode 100644 contrib/oss-fuzz/Dockerfile create mode 100644 contrib/oss-fuzz/README.txt create mode 100755 contrib/oss-fuzz/build.sh create mode 100644 contrib/oss-fuzz/libpng_read_fuzzer.cc create mode 100644 contrib/oss-fuzz/libpng_read_fuzzer.options create mode 100644 contrib/oss-fuzz/png.dict diff --git a/contrib/oss-fuzz/Dockerfile b/contrib/oss-fuzz/Dockerfile new file mode 100644 index 0000000000..c9bc4145e0 --- /dev/null +++ b/contrib/oss-fuzz/Dockerfile @@ -0,0 +1,28 @@ +# Copyright 2024 Cosmin Truta +# Copyright 2017 Glenn Randers-Pehrson +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder + +RUN apt-get update && \ + apt-get install -y make autoconf automake libtool zlib1g-dev + +RUN git clone --depth=1 https://github.com/pnggroup/libpng.git && \ + git clone --depth=1 https://github.com/madler/zlib.git && \ + cp libpng/contrib/oss-fuzz/build.sh $SRC + +WORKDIR /home/libpng diff --git a/contrib/oss-fuzz/README.txt b/contrib/oss-fuzz/README.txt new file mode 100644 index 0000000000..b01af52acc --- /dev/null +++ b/contrib/oss-fuzz/README.txt @@ -0,0 +1,40 @@ +libpng additions to oss-fuzz +============================ + +Copyright (c) 2024 Cosmin Truta +Copyright (c) 2017 Glenn Randers-Pehrson + +This code is released under the libpng license. +For conditions of distribution and use, see the disclaimer +and license in png.h + +Files in this directory are used by the oss-fuzz project +(https://github.com/google/oss-fuzz/tree/master/projects/libpng). +for "fuzzing" libpng. + +They were licensed by Google Inc, using the BSD-like Chromium license, +which may be found at https://cs.chromium.org/chromium/src/LICENSE, or, if +noted in the source, under the Apache-2.0 license, which may +be found at http://www.apache.org/licenses/LICENSE-2.0 . +If they have been modified, the derivatives are copyright Glenn Randers-Pehrson +and are released under the same licenses as the originals. Several of +the original files (libpng_read_fuzzer.options, png.dict, project.yaml) +had no licensing information; we assumed that these were under the Chromium +license. Any new files are released under the libpng license (see png.h). + +The files are + Original + Filename or derived Copyright License + ========================= ========== ================ ========== + Dockerfile* derived 2017, Glenn R-P Apache 2.0 + build.sh derived 2017, Glenn R-P Apache 2.0 + libpng_read_fuzzer.cc derived 2017, Glenn R-P Chromium + libpng_read_fuzzer.options original 2015, Chrome Devs Chromium + png.dict original 2015, Chrome Devs Chromium + README.txt (this file) original 2017, Glenn R-P libpng + + * Dockerfile is a copy of the file used by oss-fuzz. build.sh, + png.dict and libpng_read_fuzzer.* are the actual files used by oss-fuzz, + which retrieves them from the libpng repository at Github. + +To do: exercise the progressive reader and the png encoder. diff --git a/contrib/oss-fuzz/build.sh b/contrib/oss-fuzz/build.sh new file mode 100755 index 0000000000..1970f9c06c --- /dev/null +++ b/contrib/oss-fuzz/build.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +set -eu + +# Copyright 2024 Cosmin Truta +# Copyright 2017 Glenn Randers-Pehrson +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# Disable logging via library build configuration control. +sed -e "s/option STDIO/option STDIO disabled/" \ + -e "s/option WARNING /option WARNING disabled/" \ + -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ + scripts/pnglibconf.dfa >scripts/pnglibconf.dfa.tmp +mv -f scripts/pnglibconf.dfa.tmp scripts/pnglibconf.dfa + +# Build the libpng library ("libpng16.la"), excluding the auxiliary tools. +autoreconf -f -i +./configure --with-libpng-prefix=OSS_FUZZ_ +make -j$(nproc) clean +make -j$(nproc) libpng16.la + +# Build libpng_read_fuzzer. +$CXX $CXXFLAGS -std=c++11 -I. \ + $SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \ + -o $OUT/libpng_read_fuzzer \ + -lFuzzingEngine .libs/libpng16.a -lz + +# Add seed corpus. +find $SRC/libpng -name "*.png" | grep -v crashers | \ + xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip + +cp $SRC/libpng/contrib/oss-fuzz/*.dict \ + $SRC/libpng/contrib/oss-fuzz/*.options \ + $OUT/ diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.cc b/contrib/oss-fuzz/libpng_read_fuzzer.cc new file mode 100644 index 0000000000..ad9f9adc6a --- /dev/null +++ b/contrib/oss-fuzz/libpng_read_fuzzer.cc @@ -0,0 +1,224 @@ + +// libpng_read_fuzzer.cc +// Copyright 2017-2018 Glenn Randers-Pehrson +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that may +// be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE + +// The modifications in 2017 by Glenn Randers-Pehrson include +// 1. addition of a PNG_CLEANUP macro, +// 2. setting the option to ignore ADLER32 checksums, +// 3. adding "#include " which is needed on some platforms +// to provide memcpy(). +// 4. adding read_end_info() and creating an end_info structure. +// 5. adding calls to png_set_*() transforms commonly used by browsers. + +#include +#include +#include +#include + +#include + +#define PNG_INTERNAL +#include "png.h" + +#define PNG_CLEANUP \ + if(png_handler.png_ptr) \ + { \ + if (png_handler.row_ptr) \ + png_free(png_handler.png_ptr, png_handler.row_ptr); \ + if (png_handler.end_info_ptr) \ + png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\ + &png_handler.end_info_ptr); \ + else if (png_handler.info_ptr) \ + png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\ + nullptr); \ + else \ + png_destroy_read_struct(&png_handler.png_ptr, nullptr, nullptr); \ + png_handler.png_ptr = nullptr; \ + png_handler.row_ptr = nullptr; \ + png_handler.info_ptr = nullptr; \ + png_handler.end_info_ptr = nullptr; \ + } + +struct BufState { + const uint8_t* data; + size_t bytes_left; +}; + +struct PngObjectHandler { + png_infop info_ptr = nullptr; + png_structp png_ptr = nullptr; + png_infop end_info_ptr = nullptr; + png_voidp row_ptr = nullptr; + BufState* buf_state = nullptr; + + ~PngObjectHandler() { + if (row_ptr) + png_free(png_ptr, row_ptr); + if (end_info_ptr) + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info_ptr); + else if (info_ptr) + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + else + png_destroy_read_struct(&png_ptr, nullptr, nullptr); + delete buf_state; + } +}; + +void user_read_data(png_structp png_ptr, png_bytep data, size_t length) { + BufState* buf_state = static_cast(png_get_io_ptr(png_ptr)); + if (length > buf_state->bytes_left) { + png_error(png_ptr, "read error"); + } + memcpy(data, buf_state->data, length); + buf_state->bytes_left -= length; + buf_state->data += length; +} + +void* limited_malloc(png_structp, png_alloc_size_t size) { + // libpng may allocate large amounts of memory that the fuzzer reports as + // an error. In order to silence these errors, make libpng fail when trying + // to allocate a large amount. This allocator used to be in the Chromium + // version of this fuzzer. + // This number is chosen to match the default png_user_chunk_malloc_max. + if (size > 8000000) + return nullptr; + + return malloc(size); +} + +void default_free(png_structp, png_voidp ptr) { + return free(ptr); +} + +static const int kPngHeaderSize = 8; + +// Entry point for LibFuzzer. +// Roughly follows the libpng book example: +// http://www.libpng.org/pub/png/book/chapter13.html +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + if (size < kPngHeaderSize) { + return 0; + } + + std::vector v(data, data + size); + if (png_sig_cmp(v.data(), 0, kPngHeaderSize)) { + // not a PNG. + return 0; + } + + PngObjectHandler png_handler; + png_handler.png_ptr = nullptr; + png_handler.row_ptr = nullptr; + png_handler.info_ptr = nullptr; + png_handler.end_info_ptr = nullptr; + + png_handler.png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); + if (!png_handler.png_ptr) { + return 0; + } + + png_handler.info_ptr = png_create_info_struct(png_handler.png_ptr); + if (!png_handler.info_ptr) { + PNG_CLEANUP + return 0; + } + + png_handler.end_info_ptr = png_create_info_struct(png_handler.png_ptr); + if (!png_handler.end_info_ptr) { + PNG_CLEANUP + return 0; + } + + // Use a custom allocator that fails for large allocations to avoid OOM. + png_set_mem_fn(png_handler.png_ptr, nullptr, limited_malloc, default_free); + + png_set_crc_action(png_handler.png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); +#ifdef PNG_IGNORE_ADLER32 + png_set_option(png_handler.png_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON); +#endif + + // Setting up reading from buffer. + png_handler.buf_state = new BufState(); + png_handler.buf_state->data = data + kPngHeaderSize; + png_handler.buf_state->bytes_left = size - kPngHeaderSize; + png_set_read_fn(png_handler.png_ptr, png_handler.buf_state, user_read_data); + png_set_sig_bytes(png_handler.png_ptr, kPngHeaderSize); + + if (setjmp(png_jmpbuf(png_handler.png_ptr))) { + PNG_CLEANUP + return 0; + } + + // Reading. + png_read_info(png_handler.png_ptr, png_handler.info_ptr); + + // reset error handler to put png_deleter into scope. + if (setjmp(png_jmpbuf(png_handler.png_ptr))) { + PNG_CLEANUP + return 0; + } + + png_uint_32 width, height; + int bit_depth, color_type, interlace_type, compression_type; + int filter_type; + + if (!png_get_IHDR(png_handler.png_ptr, png_handler.info_ptr, &width, + &height, &bit_depth, &color_type, &interlace_type, + &compression_type, &filter_type)) { + PNG_CLEANUP + return 0; + } + + // This is going to be too slow. + if (width && height > 100000000 / width) { + PNG_CLEANUP + return 0; + } + + // Set several transforms that browsers typically use: + png_set_gray_to_rgb(png_handler.png_ptr); + png_set_expand(png_handler.png_ptr); + png_set_packing(png_handler.png_ptr); + png_set_scale_16(png_handler.png_ptr); + png_set_tRNS_to_alpha(png_handler.png_ptr); + + int passes = png_set_interlace_handling(png_handler.png_ptr); + + png_read_update_info(png_handler.png_ptr, png_handler.info_ptr); + + png_handler.row_ptr = png_malloc( + png_handler.png_ptr, png_get_rowbytes(png_handler.png_ptr, + png_handler.info_ptr)); + + for (int pass = 0; pass < passes; ++pass) { + for (png_uint_32 y = 0; y < height; ++y) { + png_read_row(png_handler.png_ptr, + static_cast(png_handler.row_ptr), nullptr); + } + } + + png_read_end(png_handler.png_ptr, png_handler.end_info_ptr); + + PNG_CLEANUP + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED + // Simplified READ API + png_image image; + memset(&image, 0, (sizeof image)); + image.version = PNG_IMAGE_VERSION; + + if (!png_image_begin_read_from_memory(&image, data, size)) { + return 0; + } + + image.format = PNG_FORMAT_RGBA; + std::vector buffer(PNG_IMAGE_SIZE(image)); + png_image_finish_read(&image, NULL, buffer.data(), 0, NULL); +#endif + + return 0; +} diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.options b/contrib/oss-fuzz/libpng_read_fuzzer.options new file mode 100644 index 0000000000..2005291a0f --- /dev/null +++ b/contrib/oss-fuzz/libpng_read_fuzzer.options @@ -0,0 +1,2 @@ +[libfuzzer] +dict = png.dict diff --git a/contrib/oss-fuzz/png.dict b/contrib/oss-fuzz/png.dict new file mode 100644 index 0000000000..3a8a113830 --- /dev/null +++ b/contrib/oss-fuzz/png.dict @@ -0,0 +1,39 @@ +# +# AFL dictionary for PNG images +# ----------------------------- +# +# Just the basic, standard-originating sections; does not include vendor +# extensions. +# +# Created by Michal Zalewski +# + +header_png="\x89PNG\x0d\x0a\x1a\x0a" + +section_IDAT="IDAT" +section_IEND="IEND" +section_IHDR="IHDR" +section_PLTE="PLTE" +section_bKGD="bKGD" +section_cHRM="cHRM" +section_eXIf="eXIf" +section_fRAc="fRAc" +section_gAMA="gAMA" +section_gIFg="gIFg" +section_gIFt="gIFt" +section_gIFx="gIFx" +section_hIST="hIST" +section_iCCP="iCCP" +section_iTXt="iTXt" +section_oFFs="oFFs" +section_pCAL="pCAL" +section_pHYs="pHYs" +section_sBIT="sBIT" +section_sCAL="sCAL" +section_sPLT="sPLT" +section_sRGB="sRGB" +section_sTER="sTER" +section_tEXt="tEXt" +section_tIME="tIME" +section_tRNS="tRNS" +section_zTXt="zTXt" From 529e69e76a82af577cd2871db7da1ab3c7a0aaf7 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 19 Sep 2024 21:37:52 +0300 Subject: [PATCH 055/112] Revert "oss-fuzz: Update the README file, the Docker file and the build script" This reverts commit 3117b5f94a06aaf52a7365074e8199909680e52e. A regression was introduced. (Oopsie!) Signed-off-by: Cosmin Truta --- contrib/oss-fuzz/Dockerfile | 15 ++++++--------- contrib/oss-fuzz/README.txt | 4 ---- contrib/oss-fuzz/build.sh | 31 +++++++++++++++++-------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/contrib/oss-fuzz/Dockerfile b/contrib/oss-fuzz/Dockerfile index c9bc4145e0..f5bc1a985d 100644 --- a/contrib/oss-fuzz/Dockerfile +++ b/contrib/oss-fuzz/Dockerfile @@ -1,5 +1,3 @@ -# Copyright 2024 Cosmin Truta -# Copyright 2017 Glenn Randers-Pehrson # Copyright 2016 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,12 +15,11 @@ ################################################################################ FROM gcr.io/oss-fuzz-base/base-builder - +MAINTAINER glennrp@gmail.com RUN apt-get update && \ - apt-get install -y make autoconf automake libtool zlib1g-dev - -RUN git clone --depth=1 https://github.com/pnggroup/libpng.git && \ - git clone --depth=1 https://github.com/madler/zlib.git && \ - cp libpng/contrib/oss-fuzz/build.sh $SRC + apt-get install -y make autoconf automake libtool -WORKDIR /home/libpng +RUN git clone --depth 1 https://github.com/madler/zlib.git +RUN git clone --depth 1 https://github.com/glennrp/libpng.git +RUN cp libpng/contrib/oss-fuzz/build.sh $SRC +WORKDIR libpng diff --git a/contrib/oss-fuzz/README.txt b/contrib/oss-fuzz/README.txt index b01af52acc..66d5242c57 100644 --- a/contrib/oss-fuzz/README.txt +++ b/contrib/oss-fuzz/README.txt @@ -1,7 +1,3 @@ -libpng additions to oss-fuzz -============================ - -Copyright (c) 2024 Cosmin Truta Copyright (c) 2017 Glenn Randers-Pehrson This code is released under the libpng license. diff --git a/contrib/oss-fuzz/build.sh b/contrib/oss-fuzz/build.sh index 1970f9c06c..7b8f026397 100755 --- a/contrib/oss-fuzz/build.sh +++ b/contrib/oss-fuzz/build.sh @@ -1,8 +1,6 @@ -#!/usr/bin/env bash -set -eu +#!/bin/bash -eu -# Copyright 2024 Cosmin Truta -# Copyright 2017 Glenn Randers-Pehrson +# Copyright 2017-2018 Glenn Randers-Pehrson # Copyright 2016 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,31 +15,36 @@ set -eu # See the License for the specific language governing permissions and # limitations under the License. # +# Revisions by Glenn Randers-Pehrson, 2017: +# 1. Build only the library, not the tools (changed "make -j$(nproc) all" to +# "make -j$(nproc) libpng16.la"). +# 2. Disabled WARNING and WRITE options in pnglibconf.dfa. +# 3. Build zlib alongside libpng ################################################################################ # Disable logging via library build configuration control. -sed -e "s/option STDIO/option STDIO disabled/" \ - -e "s/option WARNING /option WARNING disabled/" \ - -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ - scripts/pnglibconf.dfa >scripts/pnglibconf.dfa.tmp -mv -f scripts/pnglibconf.dfa.tmp scripts/pnglibconf.dfa +cat scripts/pnglibconf.dfa | \ + sed -e "s/option STDIO/option STDIO disabled/" \ + -e "s/option WARNING /option WARNING disabled/" \ + -e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \ +> scripts/pnglibconf.dfa.temp +mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa -# Build the libpng library ("libpng16.la"), excluding the auxiliary tools. +# build the libpng library. autoreconf -f -i ./configure --with-libpng-prefix=OSS_FUZZ_ make -j$(nproc) clean make -j$(nproc) libpng16.la -# Build libpng_read_fuzzer. +# build libpng_read_fuzzer. $CXX $CXXFLAGS -std=c++11 -I. \ $SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \ -o $OUT/libpng_read_fuzzer \ -lFuzzingEngine .libs/libpng16.a -lz -# Add seed corpus. +# add seed corpus. find $SRC/libpng -name "*.png" | grep -v crashers | \ xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip cp $SRC/libpng/contrib/oss-fuzz/*.dict \ - $SRC/libpng/contrib/oss-fuzz/*.options \ - $OUT/ + $SRC/libpng/contrib/oss-fuzz/*.options $OUT/ From b8a0a5401f5bf27180ae94e1479be8a13305cfea Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sun, 15 Sep 2024 10:43:41 -0700 Subject: [PATCH 056/112] [libpng16] test: Fix "make check" in all branches beyond 'libpng16' This corrects the checks to that libpng 10800 does not turn on the enhanced transform checks in either pngvalid or pngstest. The correct fix is to change the 10700 code for comments which explain what aspect or aspects of the transforms are broken (ideally) or at least state that the transforms are broken. This is a cherry-pick of commit aec888ab80f5d2241b3515b60f0f9337108fb624 from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- contrib/libtests/pngstest.c | 2 +- contrib/libtests/pngvalid.c | 52 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c index 973e60f525..b4e9c5e6bb 100644 --- a/contrib/libtests/pngstest.c +++ b/contrib/libtests/pngstest.c @@ -3500,7 +3500,7 @@ main(int argc, char **argv) int retval = 0; int c; -#if PNG_LIBPNG_VER >= 10700 +#if PNG_LIBPNG_VER == 10700 /* This error should not exist in 1.7 or later: */ opts |= GBG_ERROR; #endif diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 3d66154dd4..71b7b52784 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -2574,7 +2574,7 @@ modifier_init(png_modifier *pm) * in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5 * algorithm. */ -#define DIGITIZE PNG_LIBPNG_VER < 10700 +#define DIGITIZE PNG_LIBPNG_VER != 10700 /* If pm->calculations_use_input_precision is set then operations will happen * with the precision of the input, not the precision of the output depth. @@ -3986,7 +3986,7 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX], # define check_interlace_type(type) ((void)(type)) # define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp) # define do_own_interlace 0 -#elif PNG_LIBPNG_VER < 10700 +#elif PNG_LIBPNG_VER != 10700 # define set_write_interlace_handling(pp,type) (1) static void check_interlace_type(int const interlace_type) @@ -4014,7 +4014,7 @@ check_interlace_type(int const interlace_type) # define do_own_interlace 1 #endif /* WRITE_INTERLACING tests */ -#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED +#if PNG_LIBPNG_VER == 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED # define CAN_WRITE_INTERLACE 1 #else # define CAN_WRITE_INTERLACE 0 @@ -4633,10 +4633,10 @@ static const struct { /* no warnings makes these errors undetectable prior to 1.7.0 */ { sBIT0_error_fn, "sBIT(0): failed to detect error", - PNG_LIBPNG_VER < 10700 }, + PNG_LIBPNG_VER != 10700 }, { sBIT_error_fn, "sBIT(too big): failed to detect error", - PNG_LIBPNG_VER < 10700 }, + PNG_LIBPNG_VER != 10700 }, }; static void @@ -6236,7 +6236,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display, { if (this->colour_type == PNG_COLOR_TYPE_GRAY) { -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 if (!for_background && this->bit_depth < 8) this->bit_depth = this->sample_depth = 8; # endif @@ -6246,7 +6246,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display, /* After 1.7 the expansion of bit depth only happens if there is a * tRNS chunk to expand at this point. */ -# if PNG_LIBPNG_VER >= 10700 +# if PNG_LIBPNG_VER == 10700 if (!for_background && this->bit_depth < 8) this->bit_depth = this->sample_depth = 8; # endif @@ -7127,7 +7127,7 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this, image_pixel *that, png_const_structp pp, const transform_display *display) { -#if PNG_LIBPNG_VER < 10700 +#if PNG_LIBPNG_VER != 10700 /* LIBPNG BUG: this always forces palette images to RGB. */ if (that->colour_type == PNG_COLOR_TYPE_PALETTE) image_pixel_convert_PLTE(that); @@ -7137,13 +7137,13 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this, * convert to an alpha channel. */ if (that->have_tRNS) -# if PNG_LIBPNG_VER >= 10700 +# if PNG_LIBPNG_VER == 10700 if (that->colour_type != PNG_COLOR_TYPE_PALETTE && (that->colour_type & PNG_COLOR_MASK_ALPHA) == 0) # endif image_pixel_add_alpha(that, &display->this, 0/*!for background*/); -#if PNG_LIBPNG_VER < 10700 +#if PNG_LIBPNG_VER != 10700 /* LIBPNG BUG: otherwise libpng still expands to 8 bits! */ else { @@ -7172,7 +7172,7 @@ image_transform_png_set_tRNS_to_alpha_add(image_transform *this, * any action on a palette image. */ return -# if PNG_LIBPNG_VER >= 10700 +# if PNG_LIBPNG_VER == 10700 colour_type != PNG_COLOR_TYPE_PALETTE && # endif (colour_type & PNG_COLOR_MASK_ALPHA) == 0; @@ -7313,7 +7313,7 @@ image_transform_png_set_expand_gray_1_2_4_to_8_mod( const image_transform *this, image_pixel *that, png_const_structp pp, const transform_display *display) { -#if PNG_LIBPNG_VER < 10700 +#if PNG_LIBPNG_VER != 10700 image_transform_png_set_expand_mod(this, that, pp, display); #else /* Only expand grayscale of bit depth less than 8: */ @@ -7329,7 +7329,7 @@ static int image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this, const image_transform **that, png_byte colour_type, png_byte bit_depth) { -#if PNG_LIBPNG_VER < 10700 +#if PNG_LIBPNG_VER != 10700 return image_transform_png_set_expand_add(this, that, colour_type, bit_depth); #else @@ -7359,7 +7359,7 @@ image_transform_png_set_expand_16_set(const image_transform *this, png_set_expand_16(pp); /* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */ -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 if (that->this.has_tRNS) that->this.is_transparent = 1; # endif @@ -7412,7 +7412,7 @@ image_transform_png_set_scale_16_set(const image_transform *this, transform_display *that, png_structp pp, png_infop pi) { png_set_scale_16(pp); -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 /* libpng will limit the gamma table size: */ that->max_gamma_8 = PNG_MAX_GAMMA_8; # endif @@ -7460,7 +7460,7 @@ image_transform_png_set_strip_16_set(const image_transform *this, transform_display *that, png_structp pp, png_infop pi) { png_set_strip_16(pp); -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 /* libpng will limit the gamma table size: */ that->max_gamma_8 = PNG_MAX_GAMMA_8; # endif @@ -7647,7 +7647,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this, else { /* The default (built in) coefficients, as above: */ -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 data.red_coefficient = 6968 / 32768.; data.green_coefficient = 23434 / 32768.; data.blue_coefficient = 2366 / 32768.; @@ -7730,7 +7730,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this, * conversion adds another +/-2 in the 16-bit case and * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. */ -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 if (that->this.bit_depth < 16) that->max_gamma_8 = PNG_MAX_GAMMA_8; # endif @@ -7907,7 +7907,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this, { double gray, err; -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 if (that->colour_type == PNG_COLOR_TYPE_PALETTE) image_pixel_convert_PLTE(that); # endif @@ -8094,7 +8094,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this, double b = that->bluef; double be = that->bluee; -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 /* The true gray case involves no math in earlier versions (not * true, there was some if gamma correction was happening too.) */ @@ -9873,7 +9873,7 @@ gamma_component_validate(const char *name, const validate_info *vi, * lost. This can result in up to a +/-1 error in the presence of * an sbit less than the bit depth. */ -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 # define SBIT_ERROR .5 # else # define SBIT_ERROR 1. @@ -10733,7 +10733,7 @@ static void perform_gamma_scale16_tests(png_modifier *pm) # ifndef PNG_MAX_GAMMA_8 # define PNG_MAX_GAMMA_8 11 # endif -# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700 +# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER != 10700 # define SBIT_16_TO_8 PNG_MAX_GAMMA_8 # else # define SBIT_16_TO_8 16 @@ -11736,7 +11736,7 @@ int main(int argc, char **argv) * code that 16-bit arithmetic is used for 8-bit samples when it would make a * difference. */ - pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700; + pm.assume_16_bit_calculations = PNG_LIBPNG_VER == 10700; /* Currently 16 bit expansion happens at the end of the pipeline, so the * calculations are done in the input bit depth not the output. @@ -11760,13 +11760,13 @@ int main(int argc, char **argv) pm.test_lbg_gamma_threshold = 1; pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600; pm.test_lbg_gamma_sbit = 1; - pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700; + pm.test_lbg_gamma_composition = PNG_LIBPNG_VER == 10700; /* And the test encodings */ pm.encodings = test_encodings; pm.nencodings = ARRAY_SIZE(test_encodings); -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ # else pm.sbitlow = 1U; @@ -11796,7 +11796,7 @@ int main(int argc, char **argv) pm.maxout16 = .499; /* Error in *encoded* value */ pm.maxabs16 = .00005;/* 1/20000 */ pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */ -# if PNG_LIBPNG_VER < 10700 +# if PNG_LIBPNG_VER != 10700 pm.maxcalcG = 1./((1< Date: Mon, 23 Sep 2024 16:58:34 +0300 Subject: [PATCH 057/112] [libpng16] projects: Adjust settings in the Visual Studio project Adjust the warning levels across the entire solution in order to tidy up the build log. Also remove the vestigial macro definition _USRDLL and add the missing macro definition _CRT_SECURE_NO_WARNINGS. This is a cherry-pick of commit 719705a2ab932a353748371c2e57f39ebc4bb8a3 from branch 'libpng18'. --- projects/vstudio/libpng/libpng.vcxproj | 38 ++++++++-------- .../vstudio/pnglibconf/pnglibconf.vcxproj | 4 +- projects/vstudio/pngstest/pngstest.vcxproj | 24 +++++----- projects/vstudio/pngtest/pngtest.vcxproj | 24 +++++----- .../vstudio/pngunknown/pngunknown.vcxproj | 24 +++++----- projects/vstudio/pngvalid/pngvalid.vcxproj | 24 +++++----- projects/vstudio/zlib.props | 45 +++++++++---------- projects/vstudio/zlib/zlib.vcxproj | 40 ++++++++--------- 8 files changed, 111 insertions(+), 112 deletions(-) diff --git a/projects/vstudio/libpng/libpng.vcxproj b/projects/vstudio/libpng/libpng.vcxproj index e10f4ff8b4..1044fe1d64 100644 --- a/projects/vstudio/libpng/libpng.vcxproj +++ b/projects/vstudio/libpng/libpng.vcxproj @@ -158,11 +158,11 @@ Use - $(WarningLevel) + Level3 false ProgramDatabase EnableFastChecks - WIN32;_DEBUG;_USRDLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true false @@ -173,7 +173,7 @@ true $(DisableSpecificWarnings) $(ZLibSrcDir);%(AdditionalIncludeDirectories) - $(TreatWarningAsError) + false Disabled MultiThreadedDebugDLL @@ -188,11 +188,11 @@ Use - $(WarningLevel) + Level3 false ProgramDatabase EnableFastChecks - WIN32;_DEBUG;_USRDLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true false @@ -203,7 +203,7 @@ true $(DisableSpecificWarnings) $(ZLibSrcDir);%(AdditionalIncludeDirectories) - $(TreatWarningAsError) + false Disabled MultiThreadedDebugDLL @@ -223,7 +223,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true false @@ -250,7 +250,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true false @@ -271,12 +271,12 @@ - $(WarningLevel) + Level3 Use ProgramDatabase true true - WIN32;NDEBUG;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false false pngpriv.h @@ -286,7 +286,7 @@ false $(DisableSpecificWarnings) $(ZLibSrcDir);%(AdditionalIncludeDirectories) - $(TreatWarningAsError) + false Full @@ -301,12 +301,12 @@ - $(WarningLevel) + Level3 Use ProgramDatabase true true - WIN32;NDEBUG;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false false pngpriv.h @@ -316,7 +316,7 @@ false $(DisableSpecificWarnings) $(ZLibSrcDir);%(AdditionalIncludeDirectories) - $(TreatWarningAsError) + false Full @@ -337,7 +337,7 @@ MultiThreaded true true - WIN32;NDEBUG;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false false pngpriv.h @@ -369,7 +369,7 @@ MultiThreaded true true - WIN32;NDEBUG;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false false pngpriv.h @@ -396,7 +396,7 @@ true - WIN32;_DEBUG;PNG_ARM_NEON_OPT=1;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;PNG_ARM_NEON_OPT=1;%(PreprocessorDefinitions) NotUsing NotUsing NotUsing @@ -405,7 +405,7 @@ NotUsing - WIN32;_DEBUG;PNG_ARM_NEON_OPT=1;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;PNG_ARM_NEON_OPT=1;%(PreprocessorDefinitions) NotUsing NotUsing NotUsing @@ -413,7 +413,7 @@ NotUsing - WIN32;_DEBUG;PNG_ARM_NEON_OPT=1;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;PNG_ARM_NEON_OPT=1;%(PreprocessorDefinitions) NotUsing NotUsing NotUsing diff --git a/projects/vstudio/pnglibconf/pnglibconf.vcxproj b/projects/vstudio/pnglibconf/pnglibconf.vcxproj index e0a3887a47..f033f5061b 100644 --- a/projects/vstudio/pnglibconf/pnglibconf.vcxproj +++ b/projects/vstudio/pnglibconf/pnglibconf.vcxproj @@ -48,7 +48,7 @@ - $(WarningLevel) + Level3 MaxSpeed true true @@ -73,7 +73,7 @@ - $(WarningLevel) + Level3 MaxSpeed true true diff --git a/projects/vstudio/pngstest/pngstest.vcxproj b/projects/vstudio/pngstest/pngstest.vcxproj index 3937cb41da..e59459818d 100644 --- a/projects/vstudio/pngstest/pngstest.vcxproj +++ b/projects/vstudio/pngstest/pngstest.vcxproj @@ -149,7 +149,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -182,7 +182,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -216,7 +216,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -249,7 +249,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -275,17 +275,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -310,17 +310,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -352,7 +352,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -388,7 +388,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false diff --git a/projects/vstudio/pngtest/pngtest.vcxproj b/projects/vstudio/pngtest/pngtest.vcxproj index 72beced2bc..58f662fcdc 100644 --- a/projects/vstudio/pngtest/pngtest.vcxproj +++ b/projects/vstudio/pngtest/pngtest.vcxproj @@ -149,7 +149,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -182,7 +182,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -216,7 +216,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -249,7 +249,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -275,17 +275,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -310,17 +310,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -352,7 +352,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -389,7 +389,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false diff --git a/projects/vstudio/pngunknown/pngunknown.vcxproj b/projects/vstudio/pngunknown/pngunknown.vcxproj index f4d130d0b8..c1568feb64 100644 --- a/projects/vstudio/pngunknown/pngunknown.vcxproj +++ b/projects/vstudio/pngunknown/pngunknown.vcxproj @@ -149,7 +149,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -182,7 +182,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -216,7 +216,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -249,7 +249,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -275,17 +275,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -310,17 +310,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -352,7 +352,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -388,7 +388,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false diff --git a/projects/vstudio/pngvalid/pngvalid.vcxproj b/projects/vstudio/pngvalid/pngvalid.vcxproj index 3726193bfe..d016df8152 100644 --- a/projects/vstudio/pngvalid/pngvalid.vcxproj +++ b/projects/vstudio/pngvalid/pngvalid.vcxproj @@ -149,7 +149,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -182,7 +182,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -216,7 +216,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -249,7 +249,7 @@ Disabled EnableFastChecks MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -275,17 +275,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -310,17 +310,17 @@ - $(WarningLevel) + Level3 NotUsing ProgramDatabase Full false true - WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false - $(TreatWarningAsError) + false true false true @@ -352,7 +352,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false @@ -388,7 +388,7 @@ MultiThreaded false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) $(DisableSpecificWarnings) false diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props index 8786279661..b84a2c0fc6 100644 --- a/projects/vstudio/zlib.props +++ b/projects/vstudio/zlib.props @@ -2,7 +2,7 @@ + xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ..\..\..\..\zlib true - - EnableAllWarnings - true - 4255;4668;4710;4711;4746;4820;4996 + Level3 + false diff --git a/projects/vstudio/zlib/zlib.vcxproj b/projects/vstudio/zlib/zlib.vcxproj index 23e6065178..7858706eff 100644 --- a/projects/vstudio/zlib/zlib.vcxproj +++ b/projects/vstudio/zlib/zlib.vcxproj @@ -154,13 +154,13 @@ WIN32;_DEBUG;Z_SOLO;%(PreprocessorDefinitions) MultiThreadedDebug - Level3 + $(WarningLevel) ProgramDatabase Disabled true true - $(DisableSpecificWarnings);4127;4131;4242;4244 - false + $(DisableSpecificWarnings) + $(TreatWarningAsError) MachineX86 @@ -172,13 +172,13 @@ WIN32;_DEBUG;Z_SOLO;%(PreprocessorDefinitions) MultiThreadedDebug - Level3 + $(WarningLevel) ProgramDatabase Disabled true true - $(DisableSpecificWarnings);4127;4131;4242;4244 - false + $(DisableSpecificWarnings) + $(TreatWarningAsError) true @@ -188,13 +188,13 @@ WIN32;_DEBUG;Z_SOLO;%(PreprocessorDefinitions) - Level3 + $(WarningLevel) ProgramDatabase Disabled true true - $(DisableSpecificWarnings);4127;4131;4242;4244 - false + $(DisableSpecificWarnings) + $(TreatWarningAsError) MultiThreadedDebugDLL @@ -206,13 +206,13 @@ WIN32;_DEBUG;Z_SOLO;%(PreprocessorDefinitions) - Level3 + $(WarningLevel) ProgramDatabase Disabled true true - $(DisableSpecificWarnings);4127;4131;4242;4244 - false + $(DisableSpecificWarnings) + $(TreatWarningAsError) MultiThreadedDebugDLL @@ -222,7 +222,7 @@ - Level3 + $(WarningLevel) ProgramDatabase Full true @@ -230,8 +230,8 @@ false true true - $(DisableSpecificWarnings);4127;4131;4242;4244 - false + $(DisableSpecificWarnings) + $(TreatWarningAsError) MultiThreaded WIN32;NDEBUG;Z_SOLO;%(PreprocessorDefinitions) @@ -246,7 +246,7 @@ - Level3 + $(WarningLevel) ProgramDatabase Full true @@ -254,8 +254,8 @@ false true true - $(DisableSpecificWarnings);4127;4131;4242;4244 - false + $(DisableSpecificWarnings) + $(TreatWarningAsError) MultiThreaded WIN32;NDEBUG;Z_SOLO;%(PreprocessorDefinitions) @@ -277,7 +277,7 @@ false true true - $(DisableSpecificWarnings);4127;4131;4242;4244 + $(DisableSpecificWarnings) $(TreatWarningAsError) WIN32;NDEBUG;Z_SOLO;%(PreprocessorDefinitions) @@ -302,7 +302,7 @@ false true true - $(DisableSpecificWarnings);4127;4131;4242;4244 + $(DisableSpecificWarnings) $(TreatWarningAsError) WIN32;NDEBUG;Z_SOLO;%(PreprocessorDefinitions) From d161ce61160c8d5ce8d18e9d61a7ab5f3e2f9c29 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 23 Sep 2024 20:14:19 +0300 Subject: [PATCH 058/112] [libpng16] projects: Add a build launcher to the Visual Studio project Add projects/vstudio/build.bat, a wrapper for `devenv [...] /build`. This is a cherry-pick of commit f1c01b5c36fc4fdcd9238c5295cc5565a9caa43e from branch 'libpng18'. --- projects/vstudio/build.bat | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 projects/vstudio/build.bat diff --git a/projects/vstudio/build.bat b/projects/vstudio/build.bat new file mode 100644 index 0000000000..d129d4b6e0 --- /dev/null +++ b/projects/vstudio/build.bat @@ -0,0 +1,25 @@ +@echo off +@setlocal enableextensions + +if "%~1" == "/?" goto :help +if "%~1" == "-?" goto :help +if "%~1" == "/help" goto :help +if "%~1" == "-help" goto :help +if "%~1" == "--help" goto :help +goto :run + +:help +echo Usage: +echo %~nx0 [SOLUTION_CONFIG] +echo Examples: +echo %~nx0 "Release|Win32" (default) +echo %~nx0 "Debug|Win32" +echo %~nx0 "Release|ARM64" +echo %~nx0 "Debug|ARM64" +echo etc. +exit /b 2 + +:run +set _SOLUTION_CONFIG="%~1" +if %_SOLUTION_CONFIG% == "" set _SOLUTION_CONFIG="Release|Win32" +devenv "%~dp0.\vstudio.sln" /build %_SOLUTION_CONFIG% From f3a45ac2e9c87f5e28737130cecbb79db1310bd0 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 24 Sep 2024 17:11:12 +0300 Subject: [PATCH 059/112] [libpng16] chore: Update .gitignore Ignore artifacts produced by IDEs such as Embarcadero RAD Studio, JetBrains Fleet, Qt Creator, and possibly others. Also update the list of artifacts produced by C/C++ workflows and CMake workflows in Microsoft Visual Studio and Qt Creator. This is a cherry-pick of commit 10c76f3a1a9096f9b7cf64dd7abf5035e379e47f from branch 'libpng18'. --- .gitignore | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index d00305acf2..7245e536b1 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,9 @@ cscope.*.out .cproject/ .project/ .settings/ +## Embarcadero RAD Studio +*.cbproj.* +__recovery/ ## JetBrains .idea/ ## NetBeans @@ -84,11 +87,9 @@ nbproject/ *.sln.docstates *.suo *.user -*.userosscache *.userprefs ### Visual Studio cache files (for older versions) *.aps -*.cachefile *.ncb *.opensdf *.sdf @@ -102,21 +103,25 @@ ipch/ !.vscode/settings.json !.vscode/tasks.json ## (Various) +*.*cache +*.cache* [._]*_history .history/ +[Bb]ackup*/ # Build, test and CI output directories *[Dd]ebug/ +[Dd]ebug*/ *[Rr]elease/ -*[Rr]eleases/ -[Ll]og/ -[Ll]ogs/ -[Oo]ut/ +[Rr]elease*/ +[._]build*/ +/[Bb]uild*/ +/[Oo]ut/ -# Libpng configuration and build artifacts +# Libpng configuration and auxiliary build artifacts *.out *out.png -.deps/ +[._]deps/ .dirstamp /Makefile /autom4te.cache/ @@ -130,6 +135,9 @@ ipch/ /libpng.vers /libtool /stamp-h1 +CMake*.json +!CMakePresets.json +CMakeLists.txt.* pnglibconf.[ch] pnglibconf.dfn pnglibconf.pre From 65cd5fa3e5c466c3f3ce797883f040a3702f9f19 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 24 Sep 2024 22:12:25 +0300 Subject: [PATCH 060/112] ci: Fix the configuration for Travis CI and AppVeyor CI --- .appveyor.yml | 6 +++--- .travis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 495d90afb4..70d5e00d44 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,7 +3,7 @@ version: 1.6.x-{build} branches: except: - /libpng[0-1][0-8]/ - - /v[0-1][.][0-7][.][0-9]+/ + - /v[0-1][.][0-8][.][0-9]+/ image: - Visual Studio 2022 @@ -77,5 +77,5 @@ build_script: - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="makefiles" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_makefiles.sh"' cache: - - C:\tools\vcpkg\installed - - C:\msys64\var\cache\pacman + - 'C:\tools\vcpkg\installed' + - 'C:\msys64\var\cache\pacman' diff --git a/.travis.yml b/.travis.yml index 5b3369e25f..b93aa77d93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ branches: except: - /libpng[0-1][0-8]/ - - /v[0-1][.][0-7][.][0-9]+/ + - /v[0-1][.][0-8][.][0-9]+/ language: c From 0a27b48e948904d42528b40a06772852480bbc61 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sun, 22 Sep 2024 18:41:12 -0700 Subject: [PATCH 061/112] [libpng16] mips: Eliminate use of non-ISO-C90 features The MIPS MSA code contains // comments and the use of an "asm" directive, neither of which are part of ISO-C90. This removes the // comments and converts asm to __asm__, which GCC allows. The code compiles but maintenance is required; it's not clear it will work on anything other than one specific compiler/isa combination. It should be rewritten using intrinsics, not assembler; as it stands it is a security risk. This is a cherry-pick of commit bd39ebbcfd64d785f907b5e8dd4055a97a34f2cf from branch 'libpng18'. Co-authored-by: Cosmin Truta Reviewed-by: Chris Blume Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- mips/filter_msa_intrinsics.c | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/mips/filter_msa_intrinsics.c b/mips/filter_msa_intrinsics.c index 1b734f4d9a..614898e211 100644 --- a/mips/filter_msa_intrinsics.c +++ b/mips/filter_msa_intrinsics.c @@ -47,7 +47,7 @@ uint8_t *psrc_lw_m = (uint8_t *) (psrc); \ uint32_t val_m; \ \ - asm volatile ( \ + __asm__ volatile ( \ "lw %[val_m], %[psrc_lw_m] \n\t" \ \ : [val_m] "=r" (val_m) \ @@ -62,7 +62,7 @@ uint8_t *pdst_sh_m = (uint8_t *) (pdst); \ uint16_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "sh %[val_m], %[pdst_sh_m] \n\t" \ \ : [pdst_sh_m] "=m" (*pdst_sh_m) \ @@ -75,7 +75,7 @@ uint8_t *pdst_sw_m = (uint8_t *) (pdst); \ uint32_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "sw %[val_m], %[pdst_sw_m] \n\t" \ \ : [pdst_sw_m] "=m" (*pdst_sw_m) \ @@ -83,20 +83,20 @@ ); \ } - #if (__mips == 64) + #if __mips == 64 #define SD(val, pdst) \ { \ uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ uint64_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "sd %[val_m], %[pdst_sd_m] \n\t" \ \ : [pdst_sd_m] "=m" (*pdst_sd_m) \ : [val_m] "r" (val_m) \ ); \ } - #else + #else #define SD(val, pdst) \ { \ uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ @@ -108,17 +108,17 @@ SW(val0_m, pdst_sd_m); \ SW(val1_m, pdst_sd_m + 4); \ } - #endif + #endif /* __mips == 64 */ #else #define MSA_SRLI_B(a, b) (a >> b) -#if (__mips_isa_rev >= 6) +#if __mips_isa_rev >= 6 #define LW(psrc) \ ( { \ uint8_t *psrc_lw_m = (uint8_t *) (psrc); \ uint32_t val_m; \ \ - asm volatile ( \ + __asm__ volatile ( \ "lw %[val_m], %[psrc_lw_m] \n\t" \ \ : [val_m] "=r" (val_m) \ @@ -133,7 +133,7 @@ uint8_t *pdst_sh_m = (uint8_t *) (pdst); \ uint16_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "sh %[val_m], %[pdst_sh_m] \n\t" \ \ : [pdst_sh_m] "=m" (*pdst_sh_m) \ @@ -146,7 +146,7 @@ uint8_t *pdst_sw_m = (uint8_t *) (pdst); \ uint32_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "sw %[val_m], %[pdst_sw_m] \n\t" \ \ : [pdst_sw_m] "=m" (*pdst_sw_m) \ @@ -154,20 +154,20 @@ ); \ } - #if (__mips == 64) + #if __mips == 64 #define SD(val, pdst) \ { \ uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ uint64_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "sd %[val_m], %[pdst_sd_m] \n\t" \ \ : [pdst_sd_m] "=m" (*pdst_sd_m) \ : [val_m] "r" (val_m) \ ); \ } - #else + #else #define SD(val, pdst) \ { \ uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ @@ -179,14 +179,14 @@ SW(val0_m, pdst_sd_m); \ SW(val1_m, pdst_sd_m + 4); \ } - #endif -#else // !(__mips_isa_rev >= 6) + #endif /* __mips == 64 */ +#else #define LW(psrc) \ ( { \ uint8_t *psrc_lw_m = (uint8_t *) (psrc); \ uint32_t val_m; \ \ - asm volatile ( \ + __asm__ volatile ( \ "ulw %[val_m], %[psrc_lw_m] \n\t" \ \ : [val_m] "=r" (val_m) \ @@ -201,7 +201,7 @@ uint8_t *pdst_sh_m = (uint8_t *) (pdst); \ uint16_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "ush %[val_m], %[pdst_sh_m] \n\t" \ \ : [pdst_sh_m] "=m" (*pdst_sh_m) \ @@ -214,7 +214,7 @@ uint8_t *pdst_sw_m = (uint8_t *) (pdst); \ uint32_t val_m = (val); \ \ - asm volatile ( \ + __asm__ volatile ( \ "usw %[val_m], %[pdst_sw_m] \n\t" \ \ : [pdst_sw_m] "=m" (*pdst_sw_m) \ @@ -222,7 +222,7 @@ ); \ } - #define SD(val, pdst) \ + #define SD(val, pdst) \ { \ uint8_t *pdst_sd_m = (uint8_t *) (pdst); \ uint32_t val0_m, val1_m; \ @@ -238,14 +238,14 @@ { \ uint8_t *pdst_m = (uint8_t *) (pdst); \ \ - asm volatile ( \ + __asm__ volatile ( \ "usw $0, %[pdst_m] \n\t" \ \ : [pdst_m] "=m" (*pdst_m) \ : \ ); \ } -#endif // (__mips_isa_rev >= 6) +#endif /* __mips_isa_rev >= 6 */ #endif #define LD_B(RTYPE, psrc) *((RTYPE *) (psrc)) From d288a1dd3658b64b4109e0def691f411ae6ac717 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Mon, 16 Sep 2024 17:30:38 -0700 Subject: [PATCH 062/112] fix: Adjust colorspace calculations for ACES AP0 The subtracts in PNG_XYZ_from_xy are producing integer overflow with some valid but extreme xy values. This re-introduces the previous checks, but with less limited bounds; sufficient to accomodate the ACEScg end points (ACES AP1), but not for the ACES AP0 end points. Those were not working anyway because libpng reads the cHRM parameters as unsigned values, so they must always be at least 0. A better solution requires recognizing reasonable negative values (ones which violate the current spec) and allowing them too, at least on read. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- png.c | 156 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 36 deletions(-) diff --git a/png.c b/png.c index 500daea5f4..8a1e2a4510 100644 --- a/png.c +++ b/png.c @@ -1203,22 +1203,66 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) #endif /* GAMMA */ #ifdef PNG_COLORSPACE_SUPPORTED -static int -png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1, - png_int_32 addend2) { - /* Safely add three integers. Returns 0 on success, 1 on overlow. +static png_int_32 +png_fp_add(png_int_32 addend0, png_int_32 addend1, int *error) +{ + /* Safely add two fixed point values setting an error flag and returning 0.5 + * on overflow. * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore * relying on addition of two positive values producing a negative one is not * safe. */ - int addend0 = *addend0_and_result; - if (0x7fffffff - addend0 < addend1) - return 1; - addend0 += addend1; - if (0x7fffffff - addend1 < addend2) - return 1; - *addend0_and_result = addend0 + addend2; - return 0; + if (addend0 > 0) + { + if (0x7fffffff - addend0 >= addend1) + return addend0+addend1; + } + else if (addend0 < 0) + { + if (-0x7fffffff - addend0 <= addend1) + return addend0+addend1; + } + else + return addend1; + + *error = 1; + return PNG_FP_1/2; +} + +static png_int_32 +png_fp_sub(png_int_32 addend0, png_int_32 addend1, int *error) +{ + /* As above but calculate addend0-addend1. */ + if (addend1 > 0) + { + if (-0x7fffffff + addend1 <= addend0) + return addend0-addend1; + } + else if (addend1 < 0) + { + if (0x7fffffff + addend1 >= addend0) + return addend0+addend1; + } + else + return addend0; + + *error = 1; + return PNG_FP_1/2; +} + +static int +png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1, + png_int_32 addend2) +{ + /* Safely add three integers. Returns 0 on success, 1 on overflow. Does not + * set the result on overflow. + */ + int error = 0; + int result = png_fp_add(*addend0_and_result, + png_fp_add(addend1, addend2, &error), + &error); + if (!error) *addend0_and_result = result; + return error; } /* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for @@ -1289,6 +1333,29 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) png_fixed_point red_inverse, green_inverse, blue_scale; png_fixed_point left, right, denominator; + /* Check xy and, implicitly, z. Note that wide gamut color spaces typically + * have end points with 0 tristimulus values (these are impossible end + * points, but they are used to cover the possible colors). We check + * xy->whitey against 5, not 0, to avoid a possible integer overflow. + * + * The limits here will *not* accept ACES AP0, where bluey is -7700 + * (-0.0770) because the PNG spec itself requires the xy values to be + * unsigned. whitey is also required to be 5 or more to avoid overflow. + * + * Instead the upper limits have been relaxed to accomodate ACES AP1 where + * redz ends up as -600 (-0.006). ProPhotoRGB was already "in range." + * The new limit accomodates the AP0 and AP1 ranges for z but not AP0 redy. + */ + const png_fixed_point fpLimit = PNG_FP_1+(PNG_FP_1/10); + if (xy->redx < 0 || xy->redx > fpLimit) return 1; + if (xy->redy < 0 || xy->redy > fpLimit-xy->redx) return 1; + if (xy->greenx < 0 || xy->greenx > fpLimit) return 1; + if (xy->greeny < 0 || xy->greeny > fpLimit-xy->greenx) return 1; + if (xy->bluex < 0 || xy->bluex > fpLimit) return 1; + if (xy->bluey < 0 || xy->bluey > fpLimit-xy->bluex) return 1; + if (xy->whitex < 0 || xy->whitex > fpLimit) return 1; + if (xy->whitey < 5 || xy->whitey > fpLimit-xy->whitex) return 1; + /* The reverse calculation is more difficult because the original tristimulus * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8 * derived values were recorded in the cHRM chunk; @@ -1432,18 +1499,23 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) * * Accuracy: - * The input values have 5 decimal digits of accuracy. The values are all in - * the range 0 < value < 1, so simple products are in the same range but may - * need up to 10 decimal digits to preserve the original precision and avoid - * underflow. Because we are using a 32-bit signed representation we cannot - * match this; the best is a little over 9 decimal digits, less than 10. + * The input values have 5 decimal digits of accuracy. + * + * In the previous implementation the values were all in the range 0 < value + * < 1, so simple products are in the same range but may need up to 10 + * decimal digits to preserve the original precision and avoid underflow. + * Because we are using a 32-bit signed representation we cannot match this; + * the best is a little over 9 decimal digits, less than 10. + * + * This range has now been extended to allow values up to 1.1, or 110,000 in + * fixed point. * * The approach used here is to preserve the maximum precision within the * signed representation. Because the red-scale calculation above uses the - * difference between two products of values that must be in the range -1..+1 - * it is sufficient to divide the product by 7; ceil(100,000/32767*2). The - * factor is irrelevant in the calculation because it is applied to both - * numerator and denominator. + * difference between two products of values that must be in the range + * -1.1..+1.1 it is sufficient to divide the product by 8; + * ceil(121,000/32767*2). The factor is irrelevant in the calculation + * because it is applied to both numerator and denominator. * * Note that the values of the differences of the products of the * chromaticities in the above equations tend to be small, for example for @@ -1465,19 +1537,25 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * Adobe Wide Gamut RGB * 0.258728243040113 0.724682314948566 0.016589442011321 */ - /* By the argument, above overflow should be impossible here. The return - * value of 2 indicates an internal error to the caller. + int error = 0; + + /* By the argument above overflow should be impossible here, however the + * code now simply returns a failure code. The xy subtracts in the arguments + * to png_muldiv are *not* checked for overflow because the checks at the + * start guarantee they are in the range 0..110000 and png_fixed_point is a + * 32-bit signed number. */ - if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0) + if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 8) == 0) return 1; - if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0) + if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 8) == 0) return 1; - denominator = left - right; + denominator = png_fp_sub(left, right, &error); + if (error) return 1; /* Now find the red numerator. */ - if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) + if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 8) == 0) return 1; - if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0) + if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 8) == 0) return 1; /* Overflow is possible here and it indicates an extreme set of PNG cHRM @@ -1485,29 +1563,35 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * scale value because this allows us to delay the multiplication of white-y * into the denominator, which tends to produce a small number. */ - if (png_muldiv(&red_inverse, xy->whitey, denominator, left-right) == 0 || + if (png_muldiv(&red_inverse, xy->whitey, denominator, + png_fp_sub(left, right, &error)) == 0 || error || red_inverse <= xy->whitey /* r+g+b scales = white scale */) return 1; /* Similarly for green_inverse: */ - if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0) + if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 8) == 0) return 1; - if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) + if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 8) == 0) return 1; - if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 || + if (png_muldiv(&green_inverse, xy->whitey, denominator, + png_fp_sub(left, right, &error)) == 0 || error || green_inverse <= xy->whitey) return 1; /* And the blue scale, the checks above guarantee this can't overflow but it * can still produce 0 for extreme cHRM values. */ - blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) - - png_reciprocal(green_inverse); - if (blue_scale <= 0) + blue_scale = png_fp_sub(png_fp_sub(png_reciprocal(xy->whitey), + png_reciprocal(red_inverse), &error), + png_reciprocal(green_inverse), &error); + if (error || blue_scale <= 0) return 1; - /* And fill in the png_XYZ: */ + /* And fill in the png_XYZ. Again the subtracts are safe because of the + * checks on the xy values at the start (the subtracts just calculate the + * corresponding z values.) + */ if (png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse) == 0) return 1; if (png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse) == 0) From d3cf9b6e22fca25273e87d0b11882a7f886c97fe Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 26 Sep 2024 09:35:34 -0700 Subject: [PATCH 063/112] [libpng16] arm: Use `png_aligncastconst` for an upcast in Neon intrinsics This changes the arm/palette_neon_intrinsics.c code from using a bare cast to using the portable macro `png_aligncastconst`. This removes the `-Wcast-align` warning. The cast is safe because the pointer was allocated by `malloc(1024)`, and `malloc` is required to return a pointer with sufficient alignment for anything the allocation can accomodate. Nevertheless, this is a quick and dirty fix; the use of `png_bytep` in the `png_struct` declaration of the pointer is machine-specific. Other architectures may need different types and, consequently, the only type which is portable to other companies' CPUs is `(void*)`. This is a cherry-pick of commit a604b12c112162bfb45a0476e956777f6ed82d85 from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- arm/palette_neon_intrinsics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arm/palette_neon_intrinsics.c b/arm/palette_neon_intrinsics.c index 92c7d6f9f6..484eb41b74 100644 --- a/arm/palette_neon_intrinsics.c +++ b/arm/palette_neon_intrinsics.c @@ -64,7 +64,7 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info, { png_uint_32 row_width = row_info->width; const png_uint_32 *riffled_palette = - (const png_uint_32 *)png_ptr->riffled_palette; + png_aligncastconst(png_const_uint_32p, png_ptr->riffled_palette); const png_uint_32 pixels_per_chunk = 4; png_uint_32 i; From 642b5d81e31e0d896a5e0c04d6ac75b2efbc16a5 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 14 Sep 2024 23:44:45 +0300 Subject: [PATCH 064/112] [libpng16] build: Raise the minimum required CMake version to 3.14 Start using the features guaranteed to be available in CMake 3.14. Specifically, use the ability of `find_package(ZLIB)` to pick up zlib from the ZLIB_ROOT variable (if given). This is a cherry-pick of commit 00343a761e41e56acaeb0517aec5325d3b951837 from branch 'libpng18'. --- CMakeLists.txt | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddda7c1cca..afce7721da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # # SPDX-License-Identifier: libpng-2.0 -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.14) set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) @@ -30,11 +30,6 @@ project(libpng VERSION ${PNGLIB_VERSION} LANGUAGES C ASM) -if(POLICY CMP0074) - # Allow find_package() to use the ZLIB_ROOT variable, if available. - cmake_policy(SET CMP0074 NEW) -endif() - include(CheckCSourceCompiles) include(GNUInstallDirs) @@ -106,23 +101,22 @@ endif() message(STATUS "Building for target architecture: ${PNG_TARGET_ARCHITECTURE}") # Allow the users to specify a custom location of zlib. -# This option is deprecated, and no longer needed with CMake 3.12 and newer. -# Under the CMake policy CMP0074, if zlib is being built alongside libpng as a -# subproject, its location can be passed on to CMake via the ZLIB_ROOT variable. -option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF) -if(NOT PNG_BUILD_ZLIB) - find_package(ZLIB REQUIRED) -elseif(POLICY CMP0074) +# With CMake 3.12 and newer, this option is no longer necessary. +option(PNG_BUILD_ZLIB "[Deprecated; please use ZLIB_ROOT]" OFF) +if(PNG_BUILD_ZLIB) if("x${ZLIB_ROOT}" STREQUAL "x") - message(DEPRECATION - "The option PNG_BUILD_ZLIB has been deprecated; please use ZLIB_ROOT instead") + message(SEND_ERROR + "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; " + "please use ZLIB_ROOT instead") else() message(SEND_ERROR - "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} and " - "the variable ZLIB_ROOT=\"${ZLIB_ROOT}\" are mutually exclusive") + "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; " + "using ZLIB_ROOT=\"${ZLIB_ROOT}\"") endif() endif() +find_package(ZLIB REQUIRED) + if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN) find_library(M_LIBRARY m) if(M_LIBRARY) From 9ee82380da642aef7d8309dcee772a20e9917871 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 6 Oct 2024 21:22:09 +0300 Subject: [PATCH 065/112] [libpng16] test: Tidy up the logging of test program arguments in CTest This is a cherry-pick of commit 2e416c623d293659a102936870c4b36c00e1b347 from branch 'libpng18'. --- scripts/cmake/test.cmake.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/cmake/test.cmake.in b/scripts/cmake/test.cmake.in index a1cd30f556..b578da9266 100644 --- a/scripts/cmake/test.cmake.in +++ b/scripts/cmake/test.cmake.in @@ -26,7 +26,8 @@ if(WIN32) set(ENV{PATH} "${LIBPNG_DIR};$ENV{PATH}") endif() -message("Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}) +string(JOIN " " TEST_COMMAND_STRING "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}) +message(STATUS "Running ${TEST_COMMAND_STRING}") execute_process(COMMAND "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES} RESULT_VARIABLE TEST_STATUS) if(TEST_STATUS) From 1bf304c43caa94e491e4659362b1252ec50abb3e Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 6 Oct 2024 22:18:55 +0300 Subject: [PATCH 066/112] [libpng16] ci: Use modern CMake command options in ci_verify_cmake.sh Due to raising the minimum CMake version to 3.14, we can now run the CMake build verification (ci_verify_cmake.sh) from the libpng source dir, just as in the other scripts (ci_verify_*.sh). This is possible thanks to the modern CMake command options `cmake -B` and `cmake -S`. We can finally simplify the implementation of ci_verify_cmake.sh by removing a code complication that was annoying, and yet, necessary in peculiar Bash-on-Windows setups. Fun fact: CMake version 3.14 was released on 2019-03-14. Reportedly, on purpose! This is a cherry-pick of commit 558dfbb7570cb74205f978f11504b217a2c03c2c from branch 'libpng18'. --- ci/ci_verify_cmake.sh | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh index 9fe6340263..d48062cf51 100755 --- a/ci/ci_verify_cmake.sh +++ b/ci/ci_verify_cmake.sh @@ -17,12 +17,6 @@ CI_OUT_DIR="$CI_TOPLEVEL_DIR/out" CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build" CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install" -# Keep the following relative paths in sync with the absolute paths. -# We use them for the benefit of native Windows tools that might be -# otherwise confused by the path encoding used by Bash-on-Windows. -CI_BUILD_TO_SRC_RELDIR="../.." -CI_BUILD_TO_INSTALL_RELDIR="../ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install" - function ci_init_build { # Ensure that the mandatory variables are initialized. CI_CMAKE="${CI_CMAKE:-cmake}" @@ -148,40 +142,33 @@ function ci_build { all_cmake_build_flags+=($CI_CMAKE_BUILD_FLAGS) all_ctest_flags+=($CI_CTEST_FLAGS) # And... build! - # Use $CI_BUILD_TO_SRC_RELDIR and $CI_BUILD_TO_INSTALL_RELDIR - # instead of $CI_SRC_DIR and $CI_INSTALL_DIR from this point onwards. ci_spawn mkdir -p "$CI_BUILD_DIR" - ci_spawn cd "$CI_BUILD_DIR" - [[ $CI_BUILD_TO_SRC_RELDIR -ef $CI_SRC_DIR ]] || { - ci_err_internal "bad or missing \$CI_BUILD_TO_SRC_RELDIR" - } - ci_spawn mkdir -p "$CI_INSTALL_DIR" - [[ $CI_BUILD_TO_INSTALL_RELDIR -ef $CI_INSTALL_DIR ]] || { - ci_err_internal "bad or missing \$CI_BUILD_TO_INSTALL_RELDIR" - } # Spawn "cmake ...". - ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_BUILD_TO_INSTALL_RELDIR" \ - "${all_cmake_vars[@]}" \ - "$CI_BUILD_TO_SRC_RELDIR" + ci_spawn "$CI_CMAKE" -B "$CI_BUILD_DIR" \ + -S . \ + -DCMAKE_INSTALL_PREFIX="$CI_INSTALL_DIR" \ + "${all_cmake_vars[@]}" # Spawn "cmake --build ...". - ci_spawn "$CI_CMAKE" --build . \ + ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \ --config "$CI_CMAKE_BUILD_TYPE" \ "${all_cmake_build_flags[@]}" ci_expr $((CI_NO_TEST)) || { # Spawn "ctest" if testing is not disabled. + ci_spawn pushd "$CI_BUILD_DIR" ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \ "${all_ctest_flags[@]}" + ci_spawn popd } ci_expr $((CI_NO_INSTALL)) || { # Spawn "cmake --build ... --target install" if installation is not disabled. - ci_spawn "$CI_CMAKE" --build . \ + ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \ --config "$CI_CMAKE_BUILD_TYPE" \ --target install \ "${all_cmake_build_flags[@]}" } ci_expr $((CI_NO_CLEAN)) || { # Spawn "make --build ... --target clean" if cleaning is not disabled. - ci_spawn "$CI_CMAKE" --build . \ + ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \ --config "$CI_CMAKE_BUILD_TYPE" \ --target clean \ "${all_cmake_build_flags[@]}" From 7c90057cfee7bfcf03f92bf8c837b11790a17aeb Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 7 Oct 2024 20:43:36 +0300 Subject: [PATCH 067/112] [libpng16] ci: Verification should pass regardless of autoconf artifacts Allow ci_verify_configure.sh to pass regardless whether the configure script and the associated configure control files are present. This is necessary for the branches newer than 'libpng16', where these artifacts are no longer auto-generated by default. This is a cherry-pick of commit 09ec97edc099538d548a67253b990660c912af4f from branch 'libpng18'. --- ci/ci_verify_configure.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/ci_verify_configure.sh b/ci/ci_verify_configure.sh index 141c7a2834..b0e4d49445 100755 --- a/ci/ci_verify_configure.sh +++ b/ci/ci_verify_configure.sh @@ -122,6 +122,10 @@ function ci_build { ci_spawn export CFLAGS="${CFLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS" ci_spawn export LDFLAGS="${LDFLAGS}${LDFLAGS:+" "}-fsanitize=$CI_SANITIZERS" } + # Spawn "autogen.sh" if the configure script is not available. + [[ -x "$CI_SRC_DIR/configure" ]] || { + ci_spawn "$CI_SRC_DIR/autogen.sh" --maintainer + } # And... build! ci_spawn mkdir -p "$CI_BUILD_DIR" ci_spawn cd "$CI_BUILD_DIR" From f14d5fcd1efec749d0137162efbee6013757494b Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 10 Oct 2024 08:40:41 -0700 Subject: [PATCH 068/112] [libpng16] fix: Correct the function `png_fp_sub` in png.c The code erroneously evaluated `addend0+addend1` in the case where `addend1` is less than zero. The function is meant to subtract the second argument from the first. This is a cherry-pick of commit 79fd6d1edc8fe8c41ed58c6318bd57761d8f007e from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- png.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/png.c b/png.c index 8a1e2a4510..240db5ab9c 100644 --- a/png.c +++ b/png.c @@ -1241,7 +1241,7 @@ png_fp_sub(png_int_32 addend0, png_int_32 addend1, int *error) else if (addend1 < 0) { if (0x7fffffff + addend1 >= addend0) - return addend0+addend1; + return addend0-addend1; } else return addend0; From d7d950e8bd53913ec14e9a89d8118eff834cd6d6 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 10 Oct 2024 14:09:02 -0700 Subject: [PATCH 069/112] [libpng16] chore: Clean up the leading blank lines from all source files The leading blank lines are apparently an artefact of an older source control system. They are not required and they look like accidents, because starting a source file with a blank line is not a regular habit of software developers nowadays. This is a cherry-pick of commit 37cc20add8fb5b83bb5299a26cd3b41e0f776017 from branch 'libpng18'. Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- CMakeLists.txt | 1 - INSTALL | 1 - arm/arm_init.c | 1 - arm/filter_neon.S | 1 - arm/filter_neon_intrinsics.c | 1 - arm/palette_neon_intrinsics.c | 1 - contrib/examples/README.txt | 1 - contrib/libtests/pngimage.c | 1 - contrib/libtests/pngstest.c | 1 - contrib/libtests/pngunknown.c | 1 - contrib/libtests/pngvalid.c | 1 - contrib/libtests/readpng.c | 1 - contrib/libtests/tarith.c | 1 - contrib/libtests/timepng.c | 1 - contrib/mips-mmi/linux.c | 1 - contrib/mips-msa/linux.c | 1 - contrib/oss-fuzz/libpng_read_fuzzer.cc | 1 - contrib/pngminim/README | 1 - contrib/pngminus/CHANGES.txt | 1 - contrib/pngminus/LICENSE.txt | 1 - contrib/pngsuite/README | 1 - contrib/pngsuite/interlaced/README | 1 - example.c | 1 - intel/filter_sse2_intrinsics.c | 1 - intel/intel_init.c | 1 - mips/filter_msa_intrinsics.c | 1 - mips/mips_init.c | 1 - png.c | 1 - png.h | 1 - pngconf.h | 1 - pngdebug.h | 1 - pngerror.c | 1 - pngget.c | 1 - pnginfo.h | 1 - pngmem.c | 1 - pngpread.c | 1 - pngpriv.h | 1 - pngread.c | 1 - pngrio.c | 1 - pngrtran.c | 1 - pngrutil.c | 1 - pngset.c | 1 - pngstruct.h | 1 - pngtest.c | 1 - pngtrans.c | 1 - pngwio.c | 1 - pngwrite.c | 1 - pngwtran.c | 1 - pngwutil.c | 1 - powerpc/powerpc_init.c | 1 - scripts/descrip.mms | 1 - scripts/intprefix.c | 1 - scripts/libpng-config-body.in | 1 - scripts/prefix.c | 1 - scripts/sym.c | 1 - scripts/symbols.c | 1 - scripts/vers.c | 1 - 57 files changed, 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afce7721da..77eafdb9ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,3 @@ - # CMakeLists.txt - CMake lists for libpng # # Copyright (c) 2018-2024 Cosmin Truta. diff --git a/INSTALL b/INSTALL index 042d729291..df1a494468 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,3 @@ - Installing libpng Contents diff --git a/arm/arm_init.c b/arm/arm_init.c index 84d05556f8..50376081a3 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -1,4 +1,3 @@ - /* arm_init.c - NEON optimised filter functions * * Copyright (c) 2018-2022 Cosmin Truta diff --git a/arm/filter_neon.S b/arm/filter_neon.S index fc3c7a2964..0cbd372cb1 100644 --- a/arm/filter_neon.S +++ b/arm/filter_neon.S @@ -1,4 +1,3 @@ - /* filter_neon.S - placeholder file * * Copyright (c) 2024 Cosmin Truta diff --git a/arm/filter_neon_intrinsics.c b/arm/filter_neon_intrinsics.c index 4466d48b20..7c3e0da4d8 100644 --- a/arm/filter_neon_intrinsics.c +++ b/arm/filter_neon_intrinsics.c @@ -1,4 +1,3 @@ - /* filter_neon_intrinsics.c - NEON optimised filter functions * * Copyright (c) 2018 Cosmin Truta diff --git a/arm/palette_neon_intrinsics.c b/arm/palette_neon_intrinsics.c index 484eb41b74..3068e9b6e6 100644 --- a/arm/palette_neon_intrinsics.c +++ b/arm/palette_neon_intrinsics.c @@ -1,4 +1,3 @@ - /* palette_neon_intrinsics.c - NEON optimised palette expansion functions * * Copyright (c) 2018-2019 Cosmin Truta diff --git a/contrib/examples/README.txt b/contrib/examples/README.txt index 48dab4f0fd..7833d536cc 100644 --- a/contrib/examples/README.txt +++ b/contrib/examples/README.txt @@ -1,4 +1,3 @@ - This directory (contrib/examples) contains examples of libpng usage. NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY. diff --git a/contrib/libtests/pngimage.c b/contrib/libtests/pngimage.c index be176b2bc1..1d65247836 100644 --- a/contrib/libtests/pngimage.c +++ b/contrib/libtests/pngimage.c @@ -1,4 +1,3 @@ - /* pngimage.c * * Copyright (c) 2021 Cosmin Truta diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c index b4e9c5e6bb..1d15421b52 100644 --- a/contrib/libtests/pngstest.c +++ b/contrib/libtests/pngstest.c @@ -1,4 +1,3 @@ - /* pngstest.c * * Copyright (c) 2021 Cosmin Truta diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c index dfa9d10a1a..88133defbe 100644 --- a/contrib/libtests/pngunknown.c +++ b/contrib/libtests/pngunknown.c @@ -1,4 +1,3 @@ - /* pngunknown.c - test the read side unknown chunk handling * * Copyright (c) 2021 Cosmin Truta diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 71b7b52784..74352e5c3d 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -1,4 +1,3 @@ - /* pngvalid.c - validate libpng by constructing then reading png files. * * Copyright (c) 2021 Cosmin Truta diff --git a/contrib/libtests/readpng.c b/contrib/libtests/readpng.c index 7528e90bd9..376616a1fb 100644 --- a/contrib/libtests/readpng.c +++ b/contrib/libtests/readpng.c @@ -1,4 +1,3 @@ - /* readpng.c * * Copyright (c) 2013 John Cunningham Bowler diff --git a/contrib/libtests/tarith.c b/contrib/libtests/tarith.c index e35b7ab266..d41b9e1779 100644 --- a/contrib/libtests/tarith.c +++ b/contrib/libtests/tarith.c @@ -1,4 +1,3 @@ - /* tarith.c * * Copyright (c) 2021 Cosmin Truta diff --git a/contrib/libtests/timepng.c b/contrib/libtests/timepng.c index 0093a4548e..a66f51345f 100644 --- a/contrib/libtests/timepng.c +++ b/contrib/libtests/timepng.c @@ -1,4 +1,3 @@ - /* timepng.c * * Copyright (c) 2013,2016 John Cunningham Bowler diff --git a/contrib/mips-mmi/linux.c b/contrib/mips-mmi/linux.c index 31525fde9a..dc003807c5 100644 --- a/contrib/mips-mmi/linux.c +++ b/contrib/mips-mmi/linux.c @@ -1,4 +1,3 @@ - /* contrib/mips-mmi/linux.c * * Copyright (c) 2024 Cosmin Truta diff --git a/contrib/mips-msa/linux.c b/contrib/mips-msa/linux.c index cae8ca50ff..5651df707e 100644 --- a/contrib/mips-msa/linux.c +++ b/contrib/mips-msa/linux.c @@ -1,4 +1,3 @@ - /* contrib/mips-msa/linux.c * * Copyright (c) 2020-2023 Cosmin Truta diff --git a/contrib/oss-fuzz/libpng_read_fuzzer.cc b/contrib/oss-fuzz/libpng_read_fuzzer.cc index ad9f9adc6a..bfb5d9d3df 100644 --- a/contrib/oss-fuzz/libpng_read_fuzzer.cc +++ b/contrib/oss-fuzz/libpng_read_fuzzer.cc @@ -1,4 +1,3 @@ - // libpng_read_fuzzer.cc // Copyright 2017-2018 Glenn Randers-Pehrson // Copyright 2015 The Chromium Authors. All rights reserved. diff --git a/contrib/pngminim/README b/contrib/pngminim/README index e17fe35b6a..51d5a3c230 100644 --- a/contrib/pngminim/README +++ b/contrib/pngminim/README @@ -1,4 +1,3 @@ - This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa to build minimal decoder, encoder, and progressive reader applications. diff --git a/contrib/pngminus/CHANGES.txt b/contrib/pngminus/CHANGES.txt index 85e590a4a2..12535b13cf 100644 --- a/contrib/pngminus/CHANGES.txt +++ b/contrib/pngminus/CHANGES.txt @@ -1,4 +1,3 @@ - pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file copyright (C) 1999-2019 by Willem van Schaik diff --git a/contrib/pngminus/LICENSE.txt b/contrib/pngminus/LICENSE.txt index a8d4137280..6bdb4f8798 100644 --- a/contrib/pngminus/LICENSE.txt +++ b/contrib/pngminus/LICENSE.txt @@ -1,4 +1,3 @@ - pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file copyright (C) 1999-2019 by Willem van Schaik diff --git a/contrib/pngsuite/README b/contrib/pngsuite/README index d236b02e7c..25f0f54fda 100644 --- a/contrib/pngsuite/README +++ b/contrib/pngsuite/README @@ -1,4 +1,3 @@ - pngsuite -------- Copyright (c) Willem van Schaik, 1999, 2011, 2012 diff --git a/contrib/pngsuite/interlaced/README b/contrib/pngsuite/interlaced/README index f171eee01a..296fffba6f 100644 --- a/contrib/pngsuite/interlaced/README +++ b/contrib/pngsuite/interlaced/README @@ -1,2 +1 @@ - These images fail the "pngimage-quick" and "pngimage-full" tests. diff --git a/example.c b/example.c index 3465fbb372..dd53d8a871 100644 --- a/example.c +++ b/example.c @@ -1,4 +1,3 @@ - #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng diff --git a/intel/filter_sse2_intrinsics.c b/intel/filter_sse2_intrinsics.c index d3c0fe9e2d..2993f650b7 100644 --- a/intel/filter_sse2_intrinsics.c +++ b/intel/filter_sse2_intrinsics.c @@ -1,4 +1,3 @@ - /* filter_sse2_intrinsics.c - SSE2 optimized filter functions * * Copyright (c) 2018 Cosmin Truta diff --git a/intel/intel_init.c b/intel/intel_init.c index 2f8168b7c4..9e4610d25b 100644 --- a/intel/intel_init.c +++ b/intel/intel_init.c @@ -1,4 +1,3 @@ - /* intel_init.c - SSE2 optimized filter functions * * Copyright (c) 2018 Cosmin Truta diff --git a/mips/filter_msa_intrinsics.c b/mips/filter_msa_intrinsics.c index 614898e211..a294f55130 100644 --- a/mips/filter_msa_intrinsics.c +++ b/mips/filter_msa_intrinsics.c @@ -1,4 +1,3 @@ - /* filter_msa_intrinsics.c - MSA optimised filter functions * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/mips/mips_init.c b/mips/mips_init.c index 5c6fa1dbf1..143f0a3714 100644 --- a/mips/mips_init.c +++ b/mips/mips_init.c @@ -1,4 +1,3 @@ - /* mips_init.c - MSA optimised filter functions * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/png.c b/png.c index 240db5ab9c..8cd0179a8f 100644 --- a/png.c +++ b/png.c @@ -1,4 +1,3 @@ - /* png.c - location for general purpose libpng functions * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/png.h b/png.h index 50834ad332..f5aa4c313d 100644 --- a/png.h +++ b/png.h @@ -1,4 +1,3 @@ - /* png.h - header file for PNG reference library * * libpng version 1.6.45.git diff --git a/pngconf.h b/pngconf.h index 77e7c2a149..6060644129 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,4 +1,3 @@ - /* pngconf.h - machine-configurable file for libpng * * libpng version 1.6.45.git diff --git a/pngdebug.h b/pngdebug.h index 00d5a4569e..ab9ea632d9 100644 --- a/pngdebug.h +++ b/pngdebug.h @@ -1,4 +1,3 @@ - /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c * * Copyright (c) 2018 Cosmin Truta diff --git a/pngerror.c b/pngerror.c index 1babf9f8d2..aa0ae58e15 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,4 +1,3 @@ - /* pngerror.c - stub functions for i/o and memory allocation * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngget.c b/pngget.c index 1084b268ff..fac370d044 100644 --- a/pngget.c +++ b/pngget.c @@ -1,4 +1,3 @@ - /* pngget.c - retrieval of values from info struct * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pnginfo.h b/pnginfo.h index 1f98dedc42..ea4f115003 100644 --- a/pnginfo.h +++ b/pnginfo.h @@ -1,4 +1,3 @@ - /* pnginfo.h - header file for PNG reference library * * Copyright (c) 2018 Cosmin Truta diff --git a/pngmem.c b/pngmem.c index 09ed9c1c99..d391c13ff4 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,4 +1,3 @@ - /* pngmem.c - stub functions for memory allocation * * Copyright (c) 2018 Cosmin Truta diff --git a/pngpread.c b/pngpread.c index ffab19c08c..1a59faeb62 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,4 +1,3 @@ - /* pngpread.c - read a png file in push mode * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngpriv.h b/pngpriv.h index b59084e7eb..62615bee88 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -1,4 +1,3 @@ - /* pngpriv.h - private declarations for use inside libpng * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngread.c b/pngread.c index 07a39df6e2..b10b426519 100644 --- a/pngread.c +++ b/pngread.c @@ -1,4 +1,3 @@ - /* pngread.c - read a PNG file * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngrio.c b/pngrio.c index 7946358101..3b137f275f 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,4 +1,3 @@ - /* pngrio.c - functions for data input * * Copyright (c) 2018 Cosmin Truta diff --git a/pngrtran.c b/pngrtran.c index 1526123e02..124906635b 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,4 +1,3 @@ - /* pngrtran.c - transforms the data in a row for PNG readers * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngrutil.c b/pngrutil.c index d31dc21dae..16a3c6273c 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,4 +1,3 @@ - /* pngrutil.c - utilities to read a PNG file * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngset.c b/pngset.c index eb1c8c7a35..b530f65d1e 100644 --- a/pngset.c +++ b/pngset.c @@ -1,4 +1,3 @@ - /* pngset.c - storage of image information into info struct * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngstruct.h b/pngstruct.h index e591d94d58..7e919d0a37 100644 --- a/pngstruct.h +++ b/pngstruct.h @@ -1,4 +1,3 @@ - /* pngstruct.h - header file for PNG reference library * * Copyright (c) 2018-2022 Cosmin Truta diff --git a/pngtest.c b/pngtest.c index e19ed41ee2..bcf0f30b5b 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,4 +1,3 @@ - /* pngtest.c - a test program for libpng * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngtrans.c b/pngtrans.c index 62cb21edf1..222b4987f9 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,4 +1,3 @@ - /* pngtrans.c - transforms the data in a row (used by both readers and writers) * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngwio.c b/pngwio.c index 10e919dd03..38c9c006cb 100644 --- a/pngwio.c +++ b/pngwio.c @@ -1,4 +1,3 @@ - /* pngwio.c - functions for data output * * Copyright (c) 2018 Cosmin Truta diff --git a/pngwrite.c b/pngwrite.c index 77e412f43d..0ed6a551a4 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,4 +1,3 @@ - /* pngwrite.c - general routines to write a PNG file * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/pngwtran.c b/pngwtran.c index 49a13c1e98..a20847023f 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,4 +1,3 @@ - /* pngwtran.c - transforms the data in a row for PNG writers * * Copyright (c) 2018 Cosmin Truta diff --git a/pngwutil.c b/pngwutil.c index 14cc4ce367..9d730712fa 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,4 +1,3 @@ - /* pngwutil.c - utilities to write a PNG file * * Copyright (c) 2018-2024 Cosmin Truta diff --git a/powerpc/powerpc_init.c b/powerpc/powerpc_init.c index 54426c558e..9027480098 100644 --- a/powerpc/powerpc_init.c +++ b/powerpc/powerpc_init.c @@ -1,4 +1,3 @@ - /* powerpc_init.c - POWERPC optimised filter functions * * Copyright (c) 2018 Cosmin Truta diff --git a/scripts/descrip.mms b/scripts/descrip.mms index c440fc3505..f0d0b48969 100644 --- a/scripts/descrip.mms +++ b/scripts/descrip.mms @@ -1,4 +1,3 @@ - cc_defs = /inc=$(ZLIBSRC) c_deb = diff --git a/scripts/intprefix.c b/scripts/intprefix.c index 4085e5401b..3c9dc57a5d 100644 --- a/scripts/intprefix.c +++ b/scripts/intprefix.c @@ -1,4 +1,3 @@ - /* intprefix.c - generate an unprefixed internal symbol list * * Copyright (c) 2013-2014 Glenn Randers-Pehrson diff --git a/scripts/libpng-config-body.in b/scripts/libpng-config-body.in index b466432d54..181984b4b4 100644 --- a/scripts/libpng-config-body.in +++ b/scripts/libpng-config-body.in @@ -1,4 +1,3 @@ - usage() { cat < Date: Fri, 11 Oct 2024 23:24:46 +0300 Subject: [PATCH 070/112] [libpng16] style: Add a cmake-format config file and satisfy cmake-lint Introduce CMake file linting, based on the cmakelang project by Josh Bialkowski (@cheshirekow). Fix various style issues in the CMake files: * Add the missing copyright header to PNGConfig.cmake. * Resolve a "missing docstring" warning raised by cmake-lint. * Rewrite all docstrings in the style of CMake's own documentation. * Fix whitespace inconsistencies. References: * https://pypi.org/project/cmakelang * https://github.com/cheshirekow/cmake_format This is a cherry-pick of commit c317fe31114d92d05d44bf98c9b559edf4656b9c from branch 'libpng18'. --- .cmake-format.yaml | 94 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 37 ++++++++------ scripts/cmake/PNGConfig.cmake | 43 ++++++++++------ 3 files changed, 143 insertions(+), 31 deletions(-) create mode 100644 .cmake-format.yaml diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 0000000000..81a5e26436 --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,94 @@ +# https://pypi.org/project/cmakelang +# https://github.com/cheshirekow/cmake_format + +# ---------------------- +# Options for formatting +# ---------------------- + +# How wide to allow formatted cmake files +# TODO: Reflow the CMake files to allow setting the maximum line width to 100. +line_width: 255 + +# How many spaces to tab for indent +tab_size: 2 + +# If true, lines are indented using tab characters (utf-8 0x09) instead of +# space characters (utf-8 0x20). In cases where the layout would +# require a fractional tab character, the behavior of the fractional +# indentation is governed by +use_tabchars: false + +# If is True, then the value of this variable indicates how +# fractional indentions are handled during whitespace replacement. If set to +# 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set +# to `round-up` fractional indentation is replaced with a single tab character +# (utf-8 0x09) effectively shifting the column to the next tabstop +fractional_tab_policy: "use-space" + +# Enable comment markup parsing and reflow +enable_markup: false + +# ------------------- +# Options for linting +# ------------------- + +# Lint codes to disable +disabled_codes: [ + # TODO: + # Reconcile the CMake variable names with the patterns below, then + # re-enable the "invalid variable name XXX" messages. + "C0103", + + # A custom command with one output doesn't really need a comment because + # the default "generating XXX" is a good message already. + "C0113", +] + +# Regular expression pattern describing valid function names +function_pattern: "[0-9a-z_]+" + +# Regular expression pattern describing valid macro names +macro_pattern: "[0-9A-Z_]+" + +# Regular expression pattern describing valid names for variables with global +# (cache) scope +global_var_pattern: "[A-Z][0-9A-Z_]+" + +# Regular expression pattern describing valid names for variables with global +# scope (but internal semantic) +internal_var_pattern: "_[A-Z][0-9A-Z_]+" + +# Regular expression pattern describing valid names for variables with local +# scope +local_var_pattern: "[a-z][a-z0-9_]+" + +# Regular expression pattern describing valid names for privatedirectory +# variables +private_var_pattern: "_[0-9a-z_]+" + +# Regular expression pattern describing valid names for public directory +# variables +public_var_pattern: "[A-Z][0-9A-Z_]+" + +# Regular expression pattern describing valid names for function/macro +# arguments and loop variables. +argument_var_pattern: "[a-z][a-z0-9_]+" + +# Regular expression pattern describing valid names for keywords used in +# functions or macros +keyword_pattern: "[A-Z][0-9A-Z_]+" + +# In the heuristic for C0201, how many conditionals to match within a loop in +# before considering the loop a parser +max_conditionals_custom_parser: 2 + +# Require at least this many newlines between statements +min_statement_spacing: 1 + +# Require no more than this many newlines between statements +max_statement_spacing: 2 +max_returns: 6 +max_branches: 12 +max_arguments: 5 +max_localvars: 15 +max_statements: 50 diff --git a/CMakeLists.txt b/CMakeLists.txt index 77eafdb9ca..e142761581 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ option(PNG_TESTS "Build the libpng tests" ON) # Same as above, but for the third-party tools. # Although these tools are targetted at development environments only, # the users are allowed to override the option to build by default. -if (ANDROID OR IOS) +if(ANDROID OR IOS) option(PNG_TOOLS "Build the libpng tools" OFF) else() option(PNG_TOOLS "Build the libpng tools" ON) @@ -92,7 +92,7 @@ option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) # to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to # enable. Note that this will fail if you attempt to build a universal binary # in a single CMake invocation. -if (APPLE AND CMAKE_OSX_ARCHITECTURES) +if(APPLE AND CMAKE_OSX_ARCHITECTURES) string(TOLOWER "${CMAKE_OSX_ARCHITECTURES}" PNG_TARGET_ARCHITECTURE) else() string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" PNG_TARGET_ARCHITECTURE) @@ -116,7 +116,9 @@ endif() find_package(ZLIB REQUIRED) -if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN) +if(UNIX + AND NOT (APPLE OR BEOS OR HAIKU) + AND NOT EMSCRIPTEN) find_library(M_LIBRARY m) if(M_LIBRARY) set(M_LIBRARY m) @@ -310,7 +312,7 @@ endif() endif(PNG_HARDWARE_OPTIMIZATIONS) option(ld-version-script "Enable linker version script" ON) -if(ld-version-script AND NOT ANDROID AND NOT APPLE) +if(ld-version-script AND NOT (ANDROID OR APPLE)) # Check if LD supports linker scripts. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" " VERS_1 { global: sym1; local: *; }; @@ -356,7 +358,7 @@ else() message(STATUS "Could not find an AWK-compatible program") endif() -if(NOT AWK OR ANDROID OR IOS) +if(NOT AWK OR (ANDROID OR IOS)) # No awk available to generate sources; use pre-built pnglibconf.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) @@ -377,7 +379,7 @@ else() NEWLINE_STYLE LF) # Generate .chk from .out with awk: - # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + # generate_chk(INPUT OUTPUT [DEPENDS ...]) function(generate_chk) set(options) set(oneValueArgs INPUT OUTPUT) @@ -399,8 +401,8 @@ else() WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction() - # Generate .out from .c with awk - # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + # Generate .out from .c with awk: + # generate_out(INPUT OUTPUT [DEPENDS ...]) function(generate_out) set(options) set(oneValueArgs INPUT OUTPUT) @@ -422,8 +424,8 @@ else() WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction() - # Generate specific source file with awk - # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + # Generate specific source file with awk: + # generate_source(OUTPUT [DEPENDS ...]) function(generate_source) set(options) set(oneValueArgs OUTPUT) @@ -441,8 +443,8 @@ else() WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endfunction() - # Copy file - # generate_copy(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + # Copy file: + # generate_copy(INPUT OUTPUT [DEPENDS ...]) function(generate_copy) set(options) set(oneValueArgs INPUT OUTPUT) @@ -584,7 +586,7 @@ else() "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" png_scripts_symbols_chk "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" png_scripts_symbols_out "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" png_scripts_vers_out) -endif(NOT AWK OR ANDROID OR IOS) +endif(NOT AWK OR (ANDROID OR IOS)) # List the source code files. set(libpng_public_hdrs @@ -598,7 +600,7 @@ set(libpng_private_hdrs pnginfo.h pngstruct.h ) -if(AWK AND NOT ANDROID AND NOT IOS) +if(AWK AND NOT (ANDROID OR IOS)) list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") endif() set(libpng_sources @@ -769,6 +771,8 @@ endif() if(PNG_TESTS AND PNG_SHARED) enable_testing() + # Add a custom target to run a test: + # png_add_test(NAME COMMAND [OPTIONS ...] [FILES ...]) function(png_add_test) set(options) set(oneValueArgs NAME COMMAND) @@ -966,8 +970,9 @@ if(PNG_SHARED AND PNG_TOOLS) list(APPEND PNG_BIN_TARGETS png-fix-itxt) endif() -# Create a symlink from src to dest (if possible), or, alternatively, -# copy src to dest if different. +# Create a symlink that points to a target file (if symlinking is possible), +# or make a copy of the target file (if symlinking is not possible): +# create_symlink( [FILE | TARGET ]) function(create_symlink DEST_FILE) cmake_parse_arguments(_SYM "" "FILE;TARGET" "" ${ARGN}) if(NOT _SYM_FILE AND NOT _SYM_TARGET) diff --git a/scripts/cmake/PNGConfig.cmake b/scripts/cmake/PNGConfig.cmake index 3b6f646de7..b569d45029 100644 --- a/scripts/cmake/PNGConfig.cmake +++ b/scripts/cmake/PNGConfig.cmake @@ -1,15 +1,28 @@ -include(CMakeFindDependencyMacro) - -find_dependency(ZLIB REQUIRED) - -include("${CMAKE_CURRENT_LIST_DIR}/PNGTargets.cmake") - -if(NOT TARGET PNG::PNG) - if(TARGET PNG::png_shared) - add_library(PNG::PNG INTERFACE IMPORTED) - target_link_libraries(PNG::PNG INTERFACE PNG::png_shared) - elseif(TARGET PNG::png_static) - add_library(PNG::PNG INTERFACE IMPORTED) - target_link_libraries(PNG::PNG INTERFACE PNG::png_static) - endif() -endif() +# PNGConfig.cmake +# CMake config file compatible with the FindPNG module. + +# Copyright (c) 2024 Cosmin Truta +# Written by Benjamin Buch, 2024 +# +# Use, modification and distribution are subject to +# the same licensing terms and conditions as libpng. +# Please see the copyright notice in png.h or visit +# http://libpng.org/pub/png/src/libpng-LICENSE.txt +# +# SPDX-License-Identifier: libpng-2.0 + +include(CMakeFindDependencyMacro) + +find_dependency(ZLIB REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/PNGTargets.cmake") + +if(NOT TARGET PNG::PNG) + if(TARGET PNG::png_shared) + add_library(PNG::PNG INTERFACE IMPORTED) + target_link_libraries(PNG::PNG INTERFACE PNG::png_shared) + elseif(TARGET PNG::png_static) + add_library(PNG::PNG INTERFACE IMPORTED) + target_link_libraries(PNG::PNG INTERFACE PNG::png_static) + endif() +endif() From 8b1d489bceb241e1cfdef7a79b91fa72976b9a66 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 12 Oct 2024 19:37:50 +0300 Subject: [PATCH 071/112] [libpng16] style: Resolve the remaining warnings issued by cmake-lint Resolve the indentation issues raised by cmake-lint on a fragment of CMakeLists.txt that no longer exists in branch 'libpng18'. --- CMakeLists.txt | 306 ++++++++++++++++++++++++------------------------- 1 file changed, 153 insertions(+), 153 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e142761581..d624854121 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,183 +131,183 @@ endif() if(PNG_HARDWARE_OPTIMIZATIONS) -# Set definitions and sources for ARM. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") - if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm64|aarch64)") - set(PNG_ARM_NEON_POSSIBLE_VALUES on off) - set(PNG_ARM_NEON "on" - CACHE STRING "Enable ARM NEON optimizations: on|off; on is default") - else() - set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) - set(PNG_ARM_NEON "off" - CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default") - endif() - set_property(CACHE PNG_ARM_NEON - PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES}) - list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) - if(index EQUAL -1) - message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") - elseif(NOT PNG_ARM_NEON STREQUAL "off") - set(libpng_arm_sources - arm/arm_init.c - arm/filter_neon_intrinsics.c - arm/palette_neon_intrinsics.c) - if(PNG_ARM_NEON STREQUAL "on") - add_definitions(-DPNG_ARM_NEON_OPT=2) - elseif(PNG_ARM_NEON STREQUAL "check") - add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) + # Set definitions and sources for ARM. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") + if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm64|aarch64)") + set(PNG_ARM_NEON_POSSIBLE_VALUES on off) + set(PNG_ARM_NEON "on" + CACHE STRING "Enable ARM NEON optimizations: on|off; on is default") + else() + set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) + set(PNG_ARM_NEON "off" + CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default") + endif() + set_property(CACHE PNG_ARM_NEON + PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES}) + list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) + if(index EQUAL -1) + message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") + elseif(NOT PNG_ARM_NEON STREQUAL "off") + set(libpng_arm_sources + arm/arm_init.c + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c) + if(PNG_ARM_NEON STREQUAL "on") + add_definitions(-DPNG_ARM_NEON_OPT=2) + elseif(PNG_ARM_NEON STREQUAL "check") + add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) + endif() + else() + add_definitions(-DPNG_ARM_NEON_OPT=0) endif() - else() - add_definitions(-DPNG_ARM_NEON_OPT=0) endif() -endif() -# Set definitions and sources for PowerPC. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") - set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) - set(PNG_POWERPC_VSX "on" - CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default") - set_property(CACHE PNG_POWERPC_VSX - PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) - list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) - if(index EQUAL -1) - message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") - elseif(NOT PNG_POWERPC_VSX STREQUAL "off") - set(libpng_powerpc_sources - powerpc/powerpc_init.c - powerpc/filter_vsx_intrinsics.c) - if(PNG_POWERPC_VSX STREQUAL "on") - add_definitions(-DPNG_POWERPC_VSX_OPT=2) + # Set definitions and sources for PowerPC. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") + set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) + set(PNG_POWERPC_VSX "on" + CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default") + set_property(CACHE PNG_POWERPC_VSX + PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) + list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) + if(index EQUAL -1) + message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") + elseif(NOT PNG_POWERPC_VSX STREQUAL "off") + set(libpng_powerpc_sources + powerpc/powerpc_init.c + powerpc/filter_vsx_intrinsics.c) + if(PNG_POWERPC_VSX STREQUAL "on") + add_definitions(-DPNG_POWERPC_VSX_OPT=2) + endif() + else() + add_definitions(-DPNG_POWERPC_VSX_OPT=0) endif() - else() - add_definitions(-DPNG_POWERPC_VSX_OPT=0) endif() -endif() -# Set definitions and sources for Intel. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") - set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) - set(PNG_INTEL_SSE "on" - CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default") - set_property(CACHE PNG_INTEL_SSE - PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES}) - list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) - if(index EQUAL -1) - message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") - elseif(NOT PNG_INTEL_SSE STREQUAL "off") - set(libpng_intel_sources - intel/intel_init.c - intel/filter_sse2_intrinsics.c) - if(PNG_INTEL_SSE STREQUAL "on") - add_definitions(-DPNG_INTEL_SSE_OPT=1) + # Set definitions and sources for Intel. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") + set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) + set(PNG_INTEL_SSE "on" + CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default") + set_property(CACHE PNG_INTEL_SSE + PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES}) + list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) + if(index EQUAL -1) + message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") + elseif(NOT PNG_INTEL_SSE STREQUAL "off") + set(libpng_intel_sources + intel/intel_init.c + intel/filter_sse2_intrinsics.c) + if(PNG_INTEL_SSE STREQUAL "on") + add_definitions(-DPNG_INTEL_SSE_OPT=1) + endif() + else() + add_definitions(-DPNG_INTEL_SSE_OPT=0) endif() - else() - add_definitions(-DPNG_INTEL_SSE_OPT=0) endif() -endif() -# Set definitions and sources for MIPS. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") - set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) - set(PNG_MIPS_MSA "on" - CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default") - set_property(CACHE PNG_MIPS_MSA - PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES}) - list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa) - if(index_msa EQUAL -1) - message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") - endif() + # Set definitions and sources for MIPS. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") + set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) + set(PNG_MIPS_MSA "on" + CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default") + set_property(CACHE PNG_MIPS_MSA + PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES}) + list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa) + if(index_msa EQUAL -1) + message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") + endif() - set(PNG_MIPS_MMI_POSSIBLE_VALUES on off) - set(PNG_MIPS_MMI "on" - CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default") - set_property(CACHE PNG_MIPS_MMI - PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES}) - list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi) - if(index_mmi EQUAL -1) - message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]") - endif() + set(PNG_MIPS_MMI_POSSIBLE_VALUES on off) + set(PNG_MIPS_MMI "on" + CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default") + set_property(CACHE PNG_MIPS_MMI + PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES}) + list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi) + if(index_mmi EQUAL -1) + message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]") + endif() - if(PNG_MIPS_MSA STREQUAL "on" AND PNG_MIPS_MMI STREQUAL "on") - set(libpng_mips_sources - mips/mips_init.c - mips/filter_msa_intrinsics.c - mips/filter_mmi_inline_assembly.c) - add_definitions(-DPNG_MIPS_MSA_OPT=2) - add_definitions(-DPNG_MIPS_MMI_OPT=1) - elseif(PNG_MIPS_MSA STREQUAL "on") - set(libpng_mips_sources - mips/mips_init.c - mips/filter_msa_intrinsics.c) - add_definitions(-DPNG_MIPS_MSA_OPT=2) - add_definitions(-DPNG_MIPS_MMI_OPT=0) - elseif(PNG_MIPS_MMI STREQUAL "on") - set(libpng_mips_sources - mips/mips_init.c - mips/filter_mmi_inline_assembly.c) - add_definitions(-DPNG_MIPS_MSA_OPT=0) - add_definitions(-DPNG_MIPS_MMI_OPT=1) + if(PNG_MIPS_MSA STREQUAL "on" AND PNG_MIPS_MMI STREQUAL "on") + set(libpng_mips_sources + mips/mips_init.c + mips/filter_msa_intrinsics.c + mips/filter_mmi_inline_assembly.c) + add_definitions(-DPNG_MIPS_MSA_OPT=2) + add_definitions(-DPNG_MIPS_MMI_OPT=1) + elseif(PNG_MIPS_MSA STREQUAL "on") + set(libpng_mips_sources + mips/mips_init.c + mips/filter_msa_intrinsics.c) + add_definitions(-DPNG_MIPS_MSA_OPT=2) + add_definitions(-DPNG_MIPS_MMI_OPT=0) + elseif(PNG_MIPS_MMI STREQUAL "on") + set(libpng_mips_sources + mips/mips_init.c + mips/filter_mmi_inline_assembly.c) + add_definitions(-DPNG_MIPS_MSA_OPT=0) + add_definitions(-DPNG_MIPS_MMI_OPT=1) else() - add_definitions(-DPNG_MIPS_MSA_OPT=0) - add_definitions(-DPNG_MIPS_MMI_OPT=0) + add_definitions(-DPNG_MIPS_MSA_OPT=0) + add_definitions(-DPNG_MIPS_MMI_OPT=0) endif() -endif() + endif() -# Set definitions and sources for LoongArch. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") - include(CheckCCompilerFlag) - set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off) - set(PNG_LOONGARCH_LSX "on" - CACHE STRING "Enable LOONGARCH_LSX optimizations: on|off; on is default") - set_property(CACHE PNG_LOONGARCH_LSX - PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}) - list(FIND PNG_LOONGARCH_LSX_POSSIBLE_VALUES ${PNG_LOONGARCH_LSX} index) - if(index EQUAL -1) - message(FATAL_ERROR "PNG_LOONGARCH_LSX must be one of [${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}]") - elseif(NOT PNG_LOONGARCH_LSX STREQUAL "off") - CHECK_C_COMPILER_FLAG("-mlsx" COMPILER_SUPPORTS_LSX) - if(COMPILER_SUPPORTS_LSX) - set(libpng_loongarch_sources - loongarch/loongarch_lsx_init.c - loongarch/filter_lsx_intrinsics.c) - set_source_files_properties(${libpng_loongarch_sources} - PROPERTIES - COMPILE_FLAGS "-mlsx") - add_definitions(-DPNG_LOONGARCH_LSX_OPT=1) + # Set definitions and sources for LoongArch. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") + include(CheckCCompilerFlag) + set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off) + set(PNG_LOONGARCH_LSX "on" + CACHE STRING "Enable LOONGARCH_LSX optimizations: on|off; on is default") + set_property(CACHE PNG_LOONGARCH_LSX + PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}) + list(FIND PNG_LOONGARCH_LSX_POSSIBLE_VALUES ${PNG_LOONGARCH_LSX} index) + if(index EQUAL -1) + message(FATAL_ERROR "PNG_LOONGARCH_LSX must be one of [${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}]") + elseif(NOT PNG_LOONGARCH_LSX STREQUAL "off") + CHECK_C_COMPILER_FLAG("-mlsx" COMPILER_SUPPORTS_LSX) + if(COMPILER_SUPPORTS_LSX) + set(libpng_loongarch_sources + loongarch/loongarch_lsx_init.c + loongarch/filter_lsx_intrinsics.c) + set_source_files_properties(${libpng_loongarch_sources} + PROPERTIES + COMPILE_FLAGS "-mlsx") + add_definitions(-DPNG_LOONGARCH_LSX_OPT=1) + else() + message(FATAL_ERROR "Compiler does not support -mlsx option") + endif() else() - message(FATAL_ERROR "Compiler does not support -mlsx option") + add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) endif() - else() - add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) endif() -endif() else(PNG_HARDWARE_OPTIMIZATIONS) -# Set definitions and sources for ARM. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") - add_definitions(-DPNG_ARM_NEON_OPT=0) -endif() + # Set definitions and sources for ARM. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)") + add_definitions(-DPNG_ARM_NEON_OPT=0) + endif() -# Set definitions and sources for PowerPC. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") - add_definitions(-DPNG_POWERPC_VSX_OPT=0) -endif() + # Set definitions and sources for PowerPC. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)") + add_definitions(-DPNG_POWERPC_VSX_OPT=0) + endif() -# Set definitions and sources for Intel. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") - add_definitions(-DPNG_INTEL_SSE_OPT=0) -endif() + # Set definitions and sources for Intel. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)") + add_definitions(-DPNG_INTEL_SSE_OPT=0) + endif() -# Set definitions and sources for MIPS. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") - add_definitions(-DPNG_MIPS_MSA_OPT=0) -endif() + # Set definitions and sources for MIPS. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)") + add_definitions(-DPNG_MIPS_MSA_OPT=0) + endif() -# Set definitions and sources for LoongArch. -if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") - add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) -endif() + # Set definitions and sources for LoongArch. + if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)") + add_definitions(-DPNG_LOONGARCH_LSX_OPT=0) + endif() endif(PNG_HARDWARE_OPTIMIZATIONS) From 65470ac86c9d479e18c58c181170163925b5f9a1 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sat, 12 Oct 2024 14:55:03 -0700 Subject: [PATCH 072/112] fix: Avoid integer overflows in function `png_xy_from_XYZ` This is a cherry-picked of commit f45531cc141dc20dc7a4046bbe92270b1e799a5d from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- png.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/png.c b/png.c index 8cd0179a8f..d99e2643b8 100644 --- a/png.c +++ b/png.c @@ -1272,7 +1272,7 @@ png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1, static int png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) { - png_int_32 d, dred, dgreen, dwhite, whiteX, whiteY; + png_int_32 d, dred, dgreen, dblue, dwhite, whiteX, whiteY; /* 'd' in each of the blocks below is just X+Y+Z for each component, * x, y and z are X,Y,Z/(X+Y+Z). @@ -1280,44 +1280,52 @@ png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) d = XYZ->red_X; if (png_safe_add(&d, XYZ->red_Y, XYZ->red_Z)) return 1; - if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0) + dred = d; + if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, dred) == 0) return 1; - if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0) + if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, dred) == 0) return 1; - dred = d; - whiteX = XYZ->red_X; - whiteY = XYZ->red_Y; d = XYZ->green_X; if (png_safe_add(&d, XYZ->green_Y, XYZ->green_Z)) return 1; - if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0) + dgreen = d; + if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, dgreen) == 0) return 1; - if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0) + if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, dgreen) == 0) return 1; - dgreen = d; - whiteX += XYZ->green_X; - whiteY += XYZ->green_Y; d = XYZ->blue_X; if (png_safe_add(&d, XYZ->blue_Y, XYZ->blue_Z)) return 1; - if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0) + dblue = d; + if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, dblue) == 0) return 1; - if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0) + if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, dblue) == 0) return 1; - whiteX += XYZ->blue_X; - whiteY += XYZ->blue_Y; /* The reference white is simply the sum of the end-point (X,Y,Z) vectors so * the fillowing calculates (X+Y+Z) of the reference white (media white, * encoding white) itself: */ + d = dblue; if (png_safe_add(&d, dred, dgreen)) return 1; - dwhite = d; + /* Find the white X,Y values from the sum of the red, green and blue X,Y + * values. + */ + d = XYZ->red_X; + if (png_safe_add(&d, XYZ->green_X, XYZ->blue_X)) + return 1; + whiteX = d; + + d = XYZ->red_Y; + if (png_safe_add(&d, XYZ->green_Y, XYZ->blue_Y)) + return 1; + whiteY = d; + if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0) return 1; if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0) From 76e5ec217fbdc882bacc40ae3f2276d28507c341 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Mon, 14 Oct 2024 12:26:22 -0700 Subject: [PATCH 073/112] [libpng16] test: Add a compile-time check in pngimage.c to avoid a failure Disable the check on `interlace_method` inside function `compare_read` in pngimage.c, if WRITE_INTERLACING is not supported. If interlaced encoding is disabled inside libpng, the encoded images are non-interlaced silently and unconditionally. This commit updates the image comparison to skip the interlace check in the resultant image; other behavior is still checked. This is a cherry-pick of commit d9f13d8d846e08b00f6530b7a5fe07039d48c78d from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- contrib/libtests/pngimage.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/libtests/pngimage.c b/contrib/libtests/pngimage.c index 1d65247836..d22f7bcd09 100644 --- a/contrib/libtests/pngimage.c +++ b/contrib/libtests/pngimage.c @@ -1018,7 +1018,12 @@ compare_read(struct display *dp, int applied_transforms) C(height); C(bit_depth); C(color_type); - C(interlace_method); +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* If write interlace has been disabled, the PNG file is still + * written correctly, but as a regular (not-interlaced) PNG. + */ + C(interlace_method); +# endif C(compression_method); C(filter_method); From d9d70e6506cd4c168e411899465d4e4c77a50b04 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 17 Oct 2024 12:09:53 +0300 Subject: [PATCH 074/112] [libpng16] refactor: Deduplicate the interlace arrays `png_pass_*` Move the definitions of interlace arrays to the top of their respective translation units, to reduce their repeated copying in various places of the codebase. TODO: As they still exist in three copies, in pngpread.c, in pngrutil.c, and in pngwutil.c, they should all be further moved to a common place. This is a cherry-pick of commit 620a2b73b22df66ed099e1faacac2d92f48252b7 from branch 'libpng18'. --- pngpread.c | 36 ++++++++++++++------------------- pngrutil.c | 47 ++++++++++++++----------------------------- pngwutil.c | 58 +++++++++++++++++------------------------------------- 3 files changed, 48 insertions(+), 93 deletions(-) diff --git a/pngpread.c b/pngpread.c index 1a59faeb62..322b0cf9f1 100644 --- a/pngpread.c +++ b/pngpread.c @@ -31,6 +31,21 @@ if (png_ptr->push_length + 4 > png_ptr->buffer_size) \ if (png_ptr->buffer_size < N) \ { png_push_save_buffer(png_ptr); return; } +#ifdef PNG_READ_INTERLACING_SUPPORTED +/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */ + +/* Start of interlace block */ +static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; +/* Offset to next interlace block */ +static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +/* Start of interlace block in the y direction */ +static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; +/* Offset to next interlace block in the y direction */ +static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + +/* TODO: Move these arrays to a common utility module to avoid duplication. */ +#endif + void PNGAPI png_process_data(png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, size_t buffer_size) @@ -975,27 +990,6 @@ png_push_process_row(png_structrp png_ptr) void /* PRIVATE */ png_read_push_finish_row(png_structrp png_ptr) { -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; diff --git a/pngrutil.c b/pngrutil.c index 16a3c6273c..44b3a68693 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -17,6 +17,21 @@ #ifdef PNG_READ_SUPPORTED +#ifdef PNG_READ_INTERLACING_SUPPORTED +/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */ + +/* Start of interlace block */ +static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; +/* Offset to next interlace block */ +static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +/* Start of interlace block in the y direction */ +static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; +/* Offset to next interlace block in the y direction */ +static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + +/* TODO: Move these arrays to a common utility module to avoid duplication. */ +#endif + png_uint_32 PNGAPI png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf) { @@ -3683,10 +3698,6 @@ void /* PRIVATE */ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations /* Because these may affect the byte layout */) { - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Offset to next interlace block */ - static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) { @@ -4324,20 +4335,6 @@ png_read_finish_IDAT(png_structrp png_ptr) void /* PRIVATE */ png_read_finish_row(png_structrp png_ptr) { - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; - png_debug(1, "in png_read_finish_row"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) @@ -4389,20 +4386,6 @@ png_read_finish_row(png_structrp png_ptr) void /* PRIVATE */ png_read_start_row(png_structrp png_ptr) { - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; - unsigned int max_pixel_depth; size_t row_bytes; diff --git a/pngwutil.c b/pngwutil.c index 9d730712fa..abe7b07f96 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -8,12 +8,30 @@ * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h + * + * This file contains routines that are only called from within + * libpng itself during the course of writing an image. */ #include "pngpriv.h" #ifdef PNG_WRITE_SUPPORTED +#ifdef PNG_WRITE_INTERLACING_SUPPORTED +/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */ + +/* Start of interlace block */ +static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; +/* Offset to next interlace block */ +static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +/* Start of interlace block in the y direction */ +static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; +/* Offset to next interlace block in the y direction */ +static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + +/* TODO: Move these arrays to a common utility module to avoid duplication. */ +#endif + #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED /* Place a 32-bit number into a buffer in PNG byte order. We work * with unsigned numbers for convenience, although one supported @@ -1888,22 +1906,6 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) void /* PRIVATE */ png_write_start_row(png_structrp png_ptr) { -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - png_alloc_size_t buf_size; int usr_pixel_depth; @@ -2003,22 +2005,6 @@ png_write_start_row(png_structrp png_ptr) void /* PRIVATE */ png_write_finish_row(png_structrp png_ptr) { -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - png_debug(1, "in png_write_finish_row"); /* Next row */ @@ -2094,14 +2080,6 @@ png_write_finish_row(png_structrp png_ptr) void /* PRIVATE */ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) { - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - png_debug(1, "in png_do_write_interlace"); /* We don't have to do anything on the last pass (6) */ From c1cc0f3f4c3d4abd11ca68c59446a29ff6f95003 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 18 Oct 2024 16:16:16 +0300 Subject: [PATCH 075/112] [libpng16] build: Rename a private function to benefit C++Builder Embarcadero's compilers, old (Borland-based) and new (Clang-based), do have full support for Standard C. The Clang-based compiler is claiming, through the macro __STDC_VERSION__, to support C99 and C11, whereas the Borland-based compiler supports ANSI C, as it has for decades. However, their run-time library is exposing global functions beyond the scope of Standard C, for backwards compatibility with the older Borland products. One of these functions is `randomize`, which clashes with a function inside pngvalid.c that incidentally has the same name. Building libpng in "Strict ANSI C" mode, in which all Borland-specific globals are hidden (e.g. via `bcc32 -A`), would have been a workable solution for the Borland-based ANSI C compiler, but no such solution appears to exist for the Clang-based C90/C99/C11 compiler. Fortunately, renaming a private function inside a test program is a cost-free alternative fix. This is a cherry-pick of commit 6184164aa73ee764b1822f44d3db7619cf84f3fa from branch 'libpng18'. --- contrib/libtests/pngvalid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 74352e5c3d..bddf32141b 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -303,20 +303,20 @@ make_four_random_bytes(png_uint_32* seed, png_bytep bytes) #if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED ||\ defined PNG_WRITE_FILTER_SUPPORTED static void -randomize(void *pv, size_t size) +randomize_bytes(void *pv, size_t size) { static png_uint_32 random_seed[2] = {0x56789abc, 0xd}; make_random_bytes(random_seed, pv, size); } -#define R8(this) randomize(&(this), sizeof (this)) +#define R8(this) randomize_bytes(&(this), sizeof (this)) #ifdef PNG_READ_SUPPORTED static png_byte random_byte(void) { unsigned char b1[1]; - randomize(b1, sizeof b1); + randomize_bytes(b1, sizeof b1); return b1[0]; } #endif /* READ */ @@ -325,7 +325,7 @@ static png_uint_16 random_u16(void) { unsigned char b2[2]; - randomize(b2, sizeof b2); + randomize_bytes(b2, sizeof b2); return png_get_uint_16(b2); } @@ -335,7 +335,7 @@ static png_uint_32 random_u32(void) { unsigned char b4[4]; - randomize(b4, sizeof b4); + randomize_bytes(b4, sizeof b4); return png_get_uint_32(b4); } #endif /* READ_FILLER || READ_RGB_TO_GRAY */ From 6f786ff0f6bf4b971a7159d2b4a95e8a0770892f Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 2 Jan 2025 11:08:58 +0200 Subject: [PATCH 076/112] Update the copyright year Signed-off-by: Cosmin Truta --- LICENSE | 4 ++-- png.c | 4 ++-- png.h | 6 +++--- scripts/pnglibconf.dfa | 2 +- scripts/pnglibconf.h.prebuilt | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 25f298f0fc..ea6df986cb 100644 --- a/LICENSE +++ b/LICENSE @@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE PNG Reference Library License version 2 --------------------------------------- - * Copyright (c) 1995-2024 The PNG Reference Library Authors. - * Copyright (c) 2018-2024 Cosmin Truta. + * Copyright (c) 1995-2025 The PNG Reference Library Authors. + * Copyright (c) 2018-2025 Cosmin Truta. * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * Copyright (c) 1996-1997 Andreas Dilger. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. diff --git a/png.c b/png.c index d99e2643b8..36d3dd947c 100644 --- a/png.c +++ b/png.c @@ -1,6 +1,6 @@ /* png.c - location for general purpose libpng functions * - * Copyright (c) 2018-2024 Cosmin Truta + * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -794,7 +794,7 @@ png_get_copyright(png_const_structrp png_ptr) #else return PNG_STRING_NEWLINE \ "libpng version 1.6.45.git" PNG_STRING_NEWLINE \ - "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \ + "Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ diff --git a/png.h b/png.h index f5aa4c313d..e288f88447 100644 --- a/png.h +++ b/png.h @@ -2,7 +2,7 @@ * * libpng version 1.6.45.git * - * Copyright (c) 2018-2024 Cosmin Truta + * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -26,8 +26,8 @@ * PNG Reference Library License version 2 * --------------------------------------- * - * * Copyright (c) 1995-2024 The PNG Reference Library Authors. - * * Copyright (c) 2018-2024 Cosmin Truta. + * * Copyright (c) 1995-2025 The PNG Reference Library Authors. + * * Copyright (c) 2018-2025 Cosmin Truta. * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * * Copyright (c) 1996-1997 Andreas Dilger. * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index fe8e481238..0648f07217 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration com version com -com Copyright (c) 2018-2024 Cosmin Truta +com Copyright (c) 2018-2025 Cosmin Truta com Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson com com This code is released under the libpng license. diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index c46f7c4035..6c3e43ecd5 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -2,7 +2,7 @@ /* libpng version 1.6.45.git */ -/* Copyright (c) 2018-2024 Cosmin Truta */ +/* Copyright (c) 2018-2025 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ From 75748d93ce7b6084381d369ec79d1587b5793f69 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sat, 22 Jun 2024 00:35:55 -0400 Subject: [PATCH 077/112] [libpng16] Add support for reading and writing the cICP chunk This chunk was added in the third edition of the PNG specification and contains Coding Independent Code Points (related to color space description). It is fairly simple as it only contains four fields of one byte each: Colour Primaries, Transfer Function, Matrix Coefficients, Video Full Range Flag. The test file originally comes from the related WPT test case: https://github.com/web-platform-tests/wpt/blob/master/png/support/cicp-display-p3.png Note that I reencoded the file to make it match libpng's default encoding parameters (it only modifies the IDAT chunk). This is a cherry-pick of commit 65925ad4b2cbed934d5d850fe764dc46c4becbcb from branch 'libpng18'. Reviewed-by: John Bowler Reviewed-by: Chris Blume Reviewed-by: Cosmin Truta Signed-off-by: Cosmin Truta --- AUTHORS | 1 + CMakeLists.txt | 4 ++++ cicp-display-p3_reencoded.png | Bin 0 -> 142 bytes png.h | 14 ++++++++++++- pngget.c | 25 +++++++++++++++++++++++ pnginfo.h | 8 ++++++++ pngpread.c | 8 ++++++++ pngpriv.h | 12 +++++++++++ pngread.c | 4 ++++ pngrutil.c | 37 ++++++++++++++++++++++++++++++++++ pngset.c | 20 ++++++++++++++++++ pngtest.c | 17 ++++++++++++++++ pngwrite.c | 10 +++++++++ pngwutil.c | 20 ++++++++++++++++++ scripts/pnglibconf.dfa | 1 + scripts/pnglibconf.h.prebuilt | 3 +++ scripts/symbols.def | 2 ++ 17 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 cicp-display-p3_reencoded.png diff --git a/AUTHORS b/AUTHORS index 544341694a..f30a4ee192 100644 --- a/AUTHORS +++ b/AUTHORS @@ -17,6 +17,7 @@ Authors, for copyright and licensing purposes. * James Yu * John Bowler * Kevin Bracey + * Lucas Chollet * Magnus Holmgren * Mandar Sahastrabuddhe * Mans Rullgard diff --git a/CMakeLists.txt b/CMakeLists.txt index d624854121..5c6866f42e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -814,6 +814,10 @@ if(PNG_TESTS AND PNG_SHARED) COMMAND pngtest FILES "${PNGTEST_PNG}") + png_add_test(NAME pngtest-cicp + COMMAND pngtest + FILES "${CMAKE_CURRENT_SOURCE_DIR}/cicp-display-p3_reencoded.png") + add_executable(pngvalid ${pngvalid_sources}) target_link_libraries(pngvalid PRIVATE png_shared) diff --git a/cicp-display-p3_reencoded.png b/cicp-display-p3_reencoded.png new file mode 100644 index 0000000000000000000000000000000000000000..47830bd6b358903bcb42d251a7efa8d727d30001 GIT binary patch literal 142 zcmeAS@N?(olHy`uVBq!ia0vp^DL`z*!3-qlzV7P*Qak}ZA+A9B|NsBSX)}T3oQ)he zfqa%^Pv-z0UIxZI=Ev`Wd|gi$$B>BDw`UD`ftr{XEc@pget2GNLcf~95Vo7yD_DZ$=K#dHZu6{1-oD!Mvalid & PNG_INFO_cICP) != 0 && + colour_primaries != NULL && transfer_function != NULL && + matrix_coefficients != NULL && video_full_range_flag != NULL) + { + *colour_primaries = info_ptr->cicp_colour_primaries; + *transfer_function = info_ptr->cicp_transfer_function; + *matrix_coefficients = info_ptr->cicp_matrix_coefficients; + *video_full_range_flag = info_ptr->cicp_video_full_range_flag; + return (PNG_INFO_cICP); + } + + return (0); +} +#endif + #ifdef PNG_eXIf_SUPPORTED png_uint_32 PNGAPI png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, diff --git a/pnginfo.h b/pnginfo.h index ea4f115003..e85420c1ad 100644 --- a/pnginfo.h +++ b/pnginfo.h @@ -100,6 +100,14 @@ struct png_info_def png_colorspace colorspace; #endif +#ifdef PNG_cICP_SUPPORTED + /* cICP chunk data */ + png_byte cicp_colour_primaries; + png_byte cicp_transfer_function; + png_byte cicp_matrix_coefficients; + png_byte cicp_video_full_range_flag; +#endif + #ifdef PNG_iCCP_SUPPORTED /* iCCP chunk data. */ png_charp iccp_name; /* profile name */ diff --git a/pngpread.c b/pngpread.c index 322b0cf9f1..efa03f978f 100644 --- a/pngpread.c +++ b/pngpread.c @@ -308,6 +308,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); } +#endif +#ifdef PNG_READ_cICP_SUPPORTED + else if (png_ptr->chunk_name == png_cICP) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_cICP(png_ptr, info_ptr, png_ptr->push_length); + } + #endif #ifdef PNG_READ_eXIf_SUPPORTED else if (png_ptr->chunk_name == png_eXIf) diff --git a/pngpriv.h b/pngpriv.h index 62615bee88..84f77c3508 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -834,6 +834,7 @@ #define png_PLTE PNG_U32( 80, 76, 84, 69) #define png_bKGD PNG_U32( 98, 75, 71, 68) #define png_cHRM PNG_U32( 99, 72, 82, 77) +#define png_cICP PNG_U32( 99, 73, 67, 80) #define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */ #define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */ #define png_gAMA PNG_U32(103, 65, 77, 65) @@ -1130,6 +1131,12 @@ PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, /* The xy value must have been previously validated */ #endif +#ifdef PNG_WRITE_cICP_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_cICP,(png_structrp png_ptr, + png_byte colour_primaries, png_byte transfer_function, + png_byte matrix_coefficients, png_byte video_full_range_flag), PNG_EMPTY); +#endif + #ifdef PNG_WRITE_sRGB_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, int intent),PNG_EMPTY); @@ -1473,6 +1480,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); #endif +#ifdef PNG_READ_cICP_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_cICP,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + #ifdef PNG_READ_eXIf_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); diff --git a/pngread.c b/pngread.c index b10b426519..317951f3d2 100644 --- a/pngread.c +++ b/pngread.c @@ -173,6 +173,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) else if (chunk_name == png_cHRM) png_handle_cHRM(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_cICP_SUPPORTED + else if (chunk_name == png_cICP) + png_handle_cICP(png_ptr, info_ptr, length); +#endif #ifdef PNG_READ_eXIf_SUPPORTED else if (chunk_name == png_eXIf) diff --git a/pngrutil.c b/pngrutil.c index 44b3a68693..282d976c89 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -2046,6 +2046,43 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif +#ifdef PNG_READ_cICP_SUPPORTED +void /* PRIVATE */ +png_handle_cICP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[4]; + + png_debug(1, "in png_handle_cICP"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cICP) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + png_ptr->mode |= PNG_AFTER_IDAT; + + if (length != 4) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 4); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + png_set_cICP(png_ptr, info_ptr, buf[0], buf[1], buf[2], buf[3]); +} +#endif + #ifdef PNG_READ_eXIf_SUPPORTED void /* PRIVATE */ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) diff --git a/pngset.c b/pngset.c index b530f65d1e..c4f2867336 100644 --- a/pngset.c +++ b/pngset.c @@ -133,6 +133,26 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, #endif /* cHRM */ +#ifdef PNG_cICP_SUPPORTED +void PNGAPI +png_set_cICP(png_const_structrp png_ptr, + png_inforp info_ptr, png_byte colour_primaries, + png_byte transfer_function, png_byte matrix_coefficients, + png_byte video_full_range_flag) +{ + png_debug1(1, "in %s storage function", "cICP"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->cicp_colour_primaries = colour_primaries; + info_ptr->cicp_transfer_function = transfer_function; + info_ptr->cicp_matrix_coefficients = matrix_coefficients; + info_ptr->cicp_video_full_range_flag = video_full_range_flag; + info_ptr->valid |= PNG_INFO_cICP; +} +#endif /* cICP */ + #ifdef PNG_eXIf_SUPPORTED void PNGAPI png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, diff --git a/pngtest.c b/pngtest.c index bcf0f30b5b..60da60825c 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1205,6 +1205,23 @@ test_one_file(const char *inname, const char *outname) png_set_bKGD(write_ptr, write_info_ptr, background); } #endif +#ifdef PNG_cICP_SUPPORTED + { + png_byte colour_primaries; + png_byte transfer_function; + png_byte matrix_coefficients; + png_byte video_full_range_flag; + + if (png_get_cICP(read_ptr, read_info_ptr, &colour_primaries, + &transfer_function, &matrix_coefficients, + &video_full_range_flag) != 0) +#ifdef PNG_WRITE_cICP_SUPPORTED + png_set_cICP(write_ptr, write_info_ptr, colour_primaries, + transfer_function, matrix_coefficients, + video_full_range_flag); +#endif + } +#endif #ifdef PNG_READ_eXIf_SUPPORTED { png_bytep exif = NULL; diff --git a/pngwrite.c b/pngwrite.c index 0ed6a551a4..8b72304f4e 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -236,6 +236,16 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); #endif +#ifdef PNG_WRITE_cICP_SUPPORTED + if ((info_ptr->valid & PNG_INFO_cICP) != 0) + { + png_write_cICP(png_ptr, info_ptr->cicp_colour_primaries, + info_ptr->cicp_transfer_function, + info_ptr->cicp_matrix_coefficients, + info_ptr->cicp_video_full_range_flag); + } +#endif + #ifdef PNG_WRITE_eXIf_SUPPORTED if ((info_ptr->valid & PNG_INFO_eXIf) != 0) { diff --git a/pngwutil.c b/pngwutil.c index abe7b07f96..11f343daa5 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1488,6 +1488,26 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) } #endif +#ifdef PNG_WRITE_cICP_SUPPORTED +/* Write the cICP data */ +void /* PRIVATE */ +png_write_cICP(png_structrp png_ptr, + png_byte colour_primaries, png_byte transfer_function, + png_byte matrix_coefficients, png_byte video_full_range_flag) +{ + png_debug(1, "in png_write_cICP"); + + png_write_chunk_header(png_ptr, png_cICP, 4); + + png_write_chunk_data(png_ptr, &colour_primaries, 1); + png_write_chunk_data(png_ptr, &transfer_function, 1); + png_write_chunk_data(png_ptr, &matrix_coefficients, 1); + png_write_chunk_data(png_ptr, &video_full_range_flag, 1); + + png_write_chunk_end(png_ptr); +} +#endif + #ifdef PNG_WRITE_eXIf_SUPPORTED /* Write the Exif data */ void /* PRIVATE */ diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index 0648f07217..0a2345447b 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -846,6 +846,7 @@ setting IDAT_READ_SIZE default PNG_ZBUF_SIZE # Ancillary chunks chunk bKGD chunk cHRM enables COLORSPACE +chunk cICP chunk eXIf chunk gAMA enables GAMMA chunk hIST diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 6c3e43ecd5..613d7e91f5 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -88,6 +88,7 @@ #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED +#define PNG_READ_cICP_SUPPORTED #define PNG_READ_eXIf_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED @@ -158,6 +159,7 @@ #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED +#define PNG_WRITE_cICP_SUPPORTED #define PNG_WRITE_eXIf_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED @@ -176,6 +178,7 @@ #define PNG_WRITE_zTXt_SUPPORTED #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED +#define PNG_cICP_SUPPORTED #define PNG_eXIf_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED diff --git a/scripts/symbols.def b/scripts/symbols.def index 82494bbf94..305bd1a28e 100644 --- a/scripts/symbols.def +++ b/scripts/symbols.def @@ -253,3 +253,5 @@ EXPORTS png_set_eXIf @247 png_get_eXIf_1 @248 png_set_eXIf_1 @249 + png_get_cICP @250 + png_set_cICP @251 From 823c2d80dcea0d29cc3922c8599d250515a44f33 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Tue, 31 Dec 2024 22:05:03 +0200 Subject: [PATCH 078/112] [libpng16] fix: Update the cICP support for better compliance with PNG-3 Apply the following corrections and improvements: * Add a validity check in `png_set_cICP`. * Fix the ordering check in `png_handle_cICP`. * Add a multiplicity check in `png_handle_cICP`. * Optimize the implementation of `png_write_cICP`. * Remove an unnecessary preprocessor guard from pngtest.c. * Update the dependency declaration in pnglibconf.dfa. * Fix the indentation where necessary. This is a cherry-pick of commit c2a02691df1ecf51b7c97142752a7034350cb1f6 from branch 'libpng18'. --- pngpread.c | 4 ++-- pngread.c | 2 +- pngrutil.c | 48 +++++++++++++++++++++++------------------- pngset.c | 30 +++++++++++++++----------- pngtest.c | 28 ++++++++++++------------ pngwrite.c | 15 +++++++------ pngwutil.c | 17 +++++++++------ scripts/pnglibconf.dfa | 2 +- 8 files changed, 79 insertions(+), 67 deletions(-) diff --git a/pngpread.c b/pngpread.c index efa03f978f..1bf880eabb 100644 --- a/pngpread.c +++ b/pngpread.c @@ -312,8 +312,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_cICP_SUPPORTED else if (png_ptr->chunk_name == png_cICP) { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_cICP(png_ptr, info_ptr, png_ptr->push_length); + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_cICP(png_ptr, info_ptr, png_ptr->push_length); } #endif diff --git a/pngread.c b/pngread.c index 317951f3d2..175d60144f 100644 --- a/pngread.c +++ b/pngread.c @@ -175,7 +175,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) #endif #ifdef PNG_READ_cICP_SUPPORTED else if (chunk_name == png_cICP) - png_handle_cICP(png_ptr, info_ptr, length); + png_handle_cICP(png_ptr, info_ptr, length); #endif #ifdef PNG_READ_eXIf_SUPPORTED diff --git a/pngrutil.c b/pngrutil.c index 282d976c89..7c609b4b48 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -2050,36 +2050,40 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) void /* PRIVATE */ png_handle_cICP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { - png_byte buf[4]; + png_byte buf[4]; - png_debug(1, "in png_handle_cICP"); + png_debug(1, "in png_handle_cICP"); - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cICP) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } - if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - png_ptr->mode |= PNG_AFTER_IDAT; + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cICP) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } - if (length != 4) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } + else if (length != 4) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } - png_crc_read(png_ptr, buf, 4); + png_crc_read(png_ptr, buf, 4); - if (png_crc_finish(png_ptr, 0) != 0) - return; + if (png_crc_finish(png_ptr, 0) != 0) + return; - png_set_cICP(png_ptr, info_ptr, buf[0], buf[1], buf[2], buf[3]); + png_set_cICP(png_ptr, info_ptr, buf[0], buf[1], buf[2], buf[3]); } #endif diff --git a/pngset.c b/pngset.c index c4f2867336..383a256c11 100644 --- a/pngset.c +++ b/pngset.c @@ -135,21 +135,27 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, #ifdef PNG_cICP_SUPPORTED void PNGAPI -png_set_cICP(png_const_structrp png_ptr, - png_inforp info_ptr, png_byte colour_primaries, - png_byte transfer_function, png_byte matrix_coefficients, - png_byte video_full_range_flag) +png_set_cICP(png_const_structrp png_ptr, png_inforp info_ptr, + png_byte colour_primaries, png_byte transfer_function, + png_byte matrix_coefficients, png_byte video_full_range_flag) { - png_debug1(1, "in %s storage function", "cICP"); + png_debug1(1, "in %s storage function", "cICP"); - if (png_ptr == NULL || info_ptr == NULL) - return; + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->cicp_colour_primaries = colour_primaries; + info_ptr->cicp_transfer_function = transfer_function; + info_ptr->cicp_matrix_coefficients = matrix_coefficients; + info_ptr->cicp_video_full_range_flag = video_full_range_flag; + + if (info_ptr->cicp_matrix_coefficients != 0) + { + png_warning(png_ptr, "Invalid cICP matrix coefficients"); + return; + } - info_ptr->cicp_colour_primaries = colour_primaries; - info_ptr->cicp_transfer_function = transfer_function; - info_ptr->cicp_matrix_coefficients = matrix_coefficients; - info_ptr->cicp_video_full_range_flag = video_full_range_flag; - info_ptr->valid |= PNG_INFO_cICP; + info_ptr->valid |= PNG_INFO_cICP; } #endif /* cICP */ diff --git a/pngtest.c b/pngtest.c index 60da60825c..dbbcf1e2c1 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1206,21 +1206,19 @@ test_one_file(const char *inname, const char *outname) } #endif #ifdef PNG_cICP_SUPPORTED - { - png_byte colour_primaries; - png_byte transfer_function; - png_byte matrix_coefficients; - png_byte video_full_range_flag; - - if (png_get_cICP(read_ptr, read_info_ptr, &colour_primaries, - &transfer_function, &matrix_coefficients, - &video_full_range_flag) != 0) -#ifdef PNG_WRITE_cICP_SUPPORTED - png_set_cICP(write_ptr, write_info_ptr, colour_primaries, - transfer_function, matrix_coefficients, - video_full_range_flag); -#endif - } + { + png_byte colour_primaries; + png_byte transfer_function; + png_byte matrix_coefficients; + png_byte video_full_range_flag; + + if (png_get_cICP(read_ptr, read_info_ptr, + &colour_primaries, &transfer_function, + &matrix_coefficients, &video_full_range_flag) != 0) + png_set_cICP(write_ptr, write_info_ptr, + colour_primaries, transfer_function, + matrix_coefficients, video_full_range_flag); + } #endif #ifdef PNG_READ_eXIf_SUPPORTED { diff --git a/pngwrite.c b/pngwrite.c index 8b72304f4e..6e939cc0b3 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -237,13 +237,14 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) #endif #ifdef PNG_WRITE_cICP_SUPPORTED - if ((info_ptr->valid & PNG_INFO_cICP) != 0) - { - png_write_cICP(png_ptr, info_ptr->cicp_colour_primaries, - info_ptr->cicp_transfer_function, - info_ptr->cicp_matrix_coefficients, - info_ptr->cicp_video_full_range_flag); - } + if ((info_ptr->valid & PNG_INFO_cICP) != 0) + { + png_write_cICP(png_ptr, + info_ptr->cicp_colour_primaries, + info_ptr->cicp_transfer_function, + info_ptr->cicp_matrix_coefficients, + info_ptr->cicp_video_full_range_flag); + } #endif #ifdef PNG_WRITE_eXIf_SUPPORTED diff --git a/pngwutil.c b/pngwutil.c index 11f343daa5..8b2bf4e6d6 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1495,16 +1495,19 @@ png_write_cICP(png_structrp png_ptr, png_byte colour_primaries, png_byte transfer_function, png_byte matrix_coefficients, png_byte video_full_range_flag) { - png_debug(1, "in png_write_cICP"); + png_byte buf[4]; + + png_debug(1, "in png_write_cICP"); - png_write_chunk_header(png_ptr, png_cICP, 4); + png_write_chunk_header(png_ptr, png_cICP, 4); - png_write_chunk_data(png_ptr, &colour_primaries, 1); - png_write_chunk_data(png_ptr, &transfer_function, 1); - png_write_chunk_data(png_ptr, &matrix_coefficients, 1); - png_write_chunk_data(png_ptr, &video_full_range_flag, 1); + buf[0] = colour_primaries; + buf[1] = transfer_function; + buf[2] = matrix_coefficients; + buf[3] = video_full_range_flag; + png_write_chunk_data(png_ptr, buf, 4); - png_write_chunk_end(png_ptr); + png_write_chunk_end(png_ptr); } #endif diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa index 0a2345447b..83000d618c 100644 --- a/scripts/pnglibconf.dfa +++ b/scripts/pnglibconf.dfa @@ -846,7 +846,7 @@ setting IDAT_READ_SIZE default PNG_ZBUF_SIZE # Ancillary chunks chunk bKGD chunk cHRM enables COLORSPACE -chunk cICP +chunk cICP enables COLORSPACE, GAMMA chunk eXIf chunk gAMA enables GAMMA chunk hIST From 4599354be8ea72cc1a9b0120a5d1447eabb415c5 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 6 Oct 2024 19:11:22 +0300 Subject: [PATCH 079/112] [libpng16] test: Move cicp-display-p3_reencoded.png to contrib/testpngs/png-3/ Update the main CMake file and the auxiliary test scripts accordingly. This is a cherry-pick of commit fe277b7752990be35523832a546aec478437968a from branch 'libpng18'. --- CMakeLists.txt | 6 ++++-- .../testpngs/png-3/cicp-display-p3_reencoded.png | Bin tests/pngtest-all | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) rename cicp-display-p3_reencoded.png => contrib/testpngs/png-3/cicp-display-p3_reencoded.png (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c6866f42e..603d917a18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -804,6 +804,8 @@ if(PNG_TESTS AND PNG_SHARED) list(SORT PNGSUITE_PNGS) file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png") list(SORT TEST_PNGS) + file(GLOB TEST_PNG3_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/png-3/*.png") + list(SORT TEST_PNG3_PNGS) set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") @@ -814,9 +816,9 @@ if(PNG_TESTS AND PNG_SHARED) COMMAND pngtest FILES "${PNGTEST_PNG}") - png_add_test(NAME pngtest-cicp + png_add_test(NAME pngtest-png-3 COMMAND pngtest - FILES "${CMAKE_CURRENT_SOURCE_DIR}/cicp-display-p3_reencoded.png") + FILES "${TEST_PNG3_PNGS}") add_executable(pngvalid ${pngvalid_sources}) target_link_libraries(pngvalid PRIVATE png_shared) diff --git a/cicp-display-p3_reencoded.png b/contrib/testpngs/png-3/cicp-display-p3_reencoded.png similarity index 100% rename from cicp-display-p3_reencoded.png rename to contrib/testpngs/png-3/cicp-display-p3_reencoded.png diff --git a/tests/pngtest-all b/tests/pngtest-all index 668d92e9c3..0998425a81 100755 --- a/tests/pngtest-all +++ b/tests/pngtest-all @@ -24,6 +24,9 @@ TEST(){ # The "standard" test TEST --strict "${srcdir}"/pngtest.png +# PNG-3 tests +TEST --strict "${srcdir}"/contrib/testpngs/png-3/*.png + # Various crashers # Use --relaxed because some come from fuzzers that don't maintain CRCs TEST --relaxed "${srcdir}"/contrib/testpngs/crashers/badcrc.png From 3042f74de0e8a24797e755bd6dba06091ec75170 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Thu, 2 Jan 2025 20:16:25 +0200 Subject: [PATCH 080/112] [libpng16] fix: Update the cICP implementation yet more For the sake of completeness: * Add the cICP entry to the list of known chunks to ignore inside `png_set_keep_unknown_chunks`. * Handle cICP in `png_read_end`, alongside cHRM, gAMA, iCCP, sRGB. * In pngtest.c, move the cICP test code near cHRM, gaMA, iCCP, sRGB. This is a cherry-pick of commit 27c2ac722fd99b8622cead655034208ce96346ac from branch 'libpng18'. Reviewed-by: John Bowler Signed-off-by: Cosmin Truta --- pngread.c | 8 +++++++- pngset.c | 3 ++- pngtest.c | 32 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/pngread.c b/pngread.c index 175d60144f..49e19a4960 100644 --- a/pngread.c +++ b/pngread.c @@ -1,6 +1,6 @@ /* pngread.c - read a PNG file * - * Copyright (c) 2018-2024 Cosmin Truta + * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -173,6 +173,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) else if (chunk_name == png_cHRM) png_handle_cHRM(png_ptr, info_ptr, length); #endif + #ifdef PNG_READ_cICP_SUPPORTED else if (chunk_name == png_cICP) png_handle_cICP(png_ptr, info_ptr, length); @@ -855,6 +856,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) png_handle_cHRM(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_cICP_SUPPORTED + else if (chunk_name == png_cICP) + png_handle_cICP(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_eXIf_SUPPORTED else if (chunk_name == png_eXIf) png_handle_eXIf(png_ptr, info_ptr, length); diff --git a/pngset.c b/pngset.c index 383a256c11..462b50cf2a 100644 --- a/pngset.c +++ b/pngset.c @@ -1,6 +1,6 @@ /* pngset.c - storage of image information into info struct * - * Copyright (c) 2018-2024 Cosmin Truta + * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -1420,6 +1420,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, static const png_byte chunks_to_ignore[] = { 98, 75, 71, 68, '\0', /* bKGD */ 99, 72, 82, 77, '\0', /* cHRM */ + 99, 73, 67, 80, '\0', /* cICP */ 101, 88, 73, 102, '\0', /* eXIf */ 103, 65, 77, 65, '\0', /* gAMA */ 104, 73, 83, 84, '\0', /* hIST */ diff --git a/pngtest.c b/pngtest.c index dbbcf1e2c1..c02926693e 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,6 +1,6 @@ /* pngtest.c - a test program for libpng * - * Copyright (c) 2018-2024 Cosmin Truta + * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -1167,6 +1167,21 @@ test_one_file(const char *inname, const char *outname) #endif #endif /* Floating point */ #endif /* Fixed point */ +#ifdef PNG_cICP_SUPPORTED + { + png_byte colour_primaries; + png_byte transfer_function; + png_byte matrix_coefficients; + png_byte video_full_range_flag; + + if (png_get_cICP(read_ptr, read_info_ptr, + &colour_primaries, &transfer_function, + &matrix_coefficients, &video_full_range_flag) != 0) + png_set_cICP(write_ptr, write_info_ptr, + colour_primaries, transfer_function, + matrix_coefficients, video_full_range_flag); + } +#endif #ifdef PNG_iCCP_SUPPORTED { png_charp name; @@ -1205,21 +1220,6 @@ test_one_file(const char *inname, const char *outname) png_set_bKGD(write_ptr, write_info_ptr, background); } #endif -#ifdef PNG_cICP_SUPPORTED - { - png_byte colour_primaries; - png_byte transfer_function; - png_byte matrix_coefficients; - png_byte video_full_range_flag; - - if (png_get_cICP(read_ptr, read_info_ptr, - &colour_primaries, &transfer_function, - &matrix_coefficients, &video_full_range_flag) != 0) - png_set_cICP(write_ptr, write_info_ptr, - colour_primaries, transfer_function, - matrix_coefficients, video_full_range_flag); - } -#endif #ifdef PNG_READ_eXIf_SUPPORTED { png_bytep exif = NULL; From 0cc367aaeaac3f888f255cee5d394968996f736e Mon Sep 17 00:00:00 2001 From: John Bowler Date: Fri, 3 Jan 2025 10:35:19 -0800 Subject: [PATCH 081/112] [libpng16] fix: Write order of colourspace chunks should conform to PNG v3 cICP was written after PLTE, not before. The other chunks were output in an order which does not match the new PNG-v3 "priority" order. This change outputs all chunks in the "priority" order; highest precedence first. This means that the PNGs so written conform to PNG v3 (cICP), and allow a streaming app to handle chunks in order, without buffering data which may later be overridden. Note that PNG-v3 establishes the idea of dropping ancillary chunks which are inconveniently ordered in the definition of how APNG chunks are handled. This is a cherry-pick of commit 945f2602a0ea05a7938b2f52df9ef16cf3440291 from branch 'libpng18'. Reviewed-by: Cosmin Truta Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- .../png-3/cicp-display-p3_reencoded.png | Bin 142 -> 142 bytes pngtest.png | Bin 8759 -> 8759 bytes pngwrite.c | 95 +++++++++++------- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/contrib/testpngs/png-3/cicp-display-p3_reencoded.png b/contrib/testpngs/png-3/cicp-display-p3_reencoded.png index 47830bd6b358903bcb42d251a7efa8d727d30001..91d8e6bc4819b50bdc57025b8ee826620c3facba 100644 GIT binary patch delta 26 hcmeBU>|>mu!poBE=^Vhr%fOh&{P_JuMd^t?P5@iM2W$WU delta 15 WcmeBU>|>muGSNh0qKd#oA144Mkpz?g diff --git a/pngtest.png b/pngtest.png index 66df0c4e6f6d13981148bf2fbb85df2b797028a7..cf620eb32637a6e8b36fc60e83cd54c96c765ee1 100644 GIT binary patch delta 39 tcmdn)vfX8Zs${W~X9z10_%7A`#=yY9SRCZ;#CY?hPW?nh;f;aM6an*B466VD delta 39 vcmdn)vfX8Zs${yOuOkD)#(wTUiL49^42;D=?oNz1PwLc9R21GA_)HN1080%M diff --git a/pngwrite.c b/pngwrite.c index 6e939cc0b3..8b1b06c20c 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,6 +1,6 @@ /* pngwrite.c - general routines to write a PNG file * - * Copyright (c) 2018-2024 Cosmin Truta + * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -127,29 +127,61 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) * the application continues writing the PNG. So check the 'invalid' * flag here too. */ -#ifdef PNG_GAMMA_SUPPORTED -# ifdef PNG_WRITE_gAMA_SUPPORTED - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && - (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 && - (info_ptr->valid & PNG_INFO_gAMA) != 0) - png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma); -# endif +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + /* Write unknown chunks first; PNG v3 establishes a precedence order + * for colourspace chunks. It is certain therefore that new + * colourspace chunks will have a precedence and very likely it will be + * higher than all known so far. Writing the unknown chunks here is + * most likely to present the chunks in the most convenient order. + * + * FUTURE: maybe write chunks in the order the app calls png_set_chnk + * to give the app control. + */ + write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); +#endif + +#ifdef PNG_WRITE_sBIT_SUPPORTED + /* PNG v3: a streaming app will need to see this before cICP because + * the information is helpful in handling HLG encoding (which is + * natively 10 bits but gets expanded to 16 in PNG.) + * + * The app shouldn't care about the order ideally, but it might have + * no choice. In PNG v3, apps are allowed to reject PNGs where the + * APNG chunks are out of order so it behooves libpng to be nice here. + */ + if ((info_ptr->valid & PNG_INFO_sBIT) != 0) + png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); #endif + /* PNG v3: the July 2004 version of the TR introduced the concept of colour + * space priority. As above it therefore behooves libpng to write the colour + * space chunks in the priority order so that a streaming app need not buffer + * them. + */ #ifdef PNG_COLORSPACE_SUPPORTED - /* Write only one of sRGB or an ICC profile. If a profile was supplied - * and it matches one of the known sRGB ones issue a warning. +# ifdef PNG_WRITE_cICP_SUPPORTED /* Priority 4 */ + if ((info_ptr->valid & PNG_INFO_cICP) != 0) + { + png_write_cICP(png_ptr, + info_ptr->cicp_colour_primaries, + info_ptr->cicp_transfer_function, + info_ptr->cicp_matrix_coefficients, + info_ptr->cicp_video_full_range_flag); + } +# endif + + /* PNG v3 change: it is now permitted to write both sRGB and ICC profiles, + * however because the libpng code auto-generates an sRGB for the + * corresponding ICC profiles and because PNG v2 disallowed this we need + * to only write one. + * + * Remove the PNG v2 warning about writing an sRGB ICC profile as well + * because it's invalid with PNG v3. */ -# ifdef PNG_WRITE_iCCP_SUPPORTED +# ifdef PNG_WRITE_iCCP_SUPPORTED /* Priority 3 */ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && (info_ptr->valid & PNG_INFO_iCCP) != 0) { -# ifdef PNG_WRITE_sRGB_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sRGB) != 0) - png_app_warning(png_ptr, - "profile matches sRGB but writing iCCP instead"); -# endif - png_write_iCCP(png_ptr, info_ptr->iccp_name, info_ptr->iccp_profile); } @@ -158,20 +190,24 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) # endif # endif -# ifdef PNG_WRITE_sRGB_SUPPORTED +# ifdef PNG_WRITE_sRGB_SUPPORTED /* Priority 2 */ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && (info_ptr->valid & PNG_INFO_sRGB) != 0) png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent); # endif /* WRITE_sRGB */ #endif /* COLORSPACE */ -#ifdef PNG_WRITE_sBIT_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sBIT) != 0) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); +#ifdef PNG_GAMMA_SUPPORTED +# ifdef PNG_WRITE_gAMA_SUPPORTED /* Priority 1 */ + if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && + (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 && + (info_ptr->valid & PNG_INFO_gAMA) != 0) + png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma); +# endif #endif #ifdef PNG_COLORSPACE_SUPPORTED -# ifdef PNG_WRITE_cHRM_SUPPORTED +# ifdef PNG_WRITE_cHRM_SUPPORTED /* Also priority 1 */ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 && (info_ptr->valid & PNG_INFO_cHRM) != 0) @@ -179,10 +215,6 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) # endif #endif -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); -#endif - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; } } @@ -236,17 +268,6 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); #endif -#ifdef PNG_WRITE_cICP_SUPPORTED - if ((info_ptr->valid & PNG_INFO_cICP) != 0) - { - png_write_cICP(png_ptr, - info_ptr->cicp_colour_primaries, - info_ptr->cicp_transfer_function, - info_ptr->cicp_matrix_coefficients, - info_ptr->cicp_video_full_range_flag); - } -#endif - #ifdef PNG_WRITE_eXIf_SUPPORTED if ((info_ptr->valid & PNG_INFO_eXIf) != 0) { From 2a845ff819215e4f99a75136bd691ad0ffa9ae05 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 6 Jan 2025 17:09:10 +0200 Subject: [PATCH 082/112] build: Move portions from the main CMake file to separate modules In preparation for the upcoming changes in the build system, any parts of the CMake file that are unlikely to be affected should be moved out of the way. This should facilitate an easier resync between the branch 'libpng16' and its successor(s). Specifically: * Move the functions `generate_chk`, `generate_out`, `generate_source` and `generate_copy` to scripts/cmake/PNGGenConfig.cmake. * Move the function `png_add_test` to scripts/cmake/PNGTest.cmake. * Leave the function `create_symlink` in place, but add a TODO note. As we raised the minimum required CMake version to 3.14, we should now be able to use CMake's built-in function instead. --- CMakeLists.txt | 128 +++---------------------------- scripts/cmake/PNGGenConfig.cmake | 104 +++++++++++++++++++++++++ scripts/cmake/PNGTest.cmake | 42 ++++++++++ 3 files changed, 158 insertions(+), 116 deletions(-) create mode 100644 scripts/cmake/PNGGenConfig.cmake create mode 100644 scripts/cmake/PNGTest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 603d917a18..75d25ec5b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ # CMakeLists.txt - CMake lists for libpng # -# Copyright (c) 2018-2024 Cosmin Truta. -# Copyright (c) 2007-2018 Glenn Randers-Pehrson. -# Originally written by Christian Ehrlicher, 2007. +# Copyright (c) 2018-2025 Cosmin Truta +# Copyright (c) 2007-2018 Glenn Randers-Pehrson +# Originally written by Christian Ehrlicher, 2007 # # Use, modification and distribution are subject to # the same licensing terms and conditions as libpng. @@ -364,6 +364,9 @@ if(NOT AWK OR (ANDROID OR IOS)) ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) add_custom_target(png_genfiles) else() + # Include the internal module PNGGenConfig.cmake + include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGGenConfig.cmake) + # Copy the awk scripts, converting their line endings to Unix (LF) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk ${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk @@ -378,93 +381,6 @@ else() @ONLY NEWLINE_STYLE LF) - # Generate .chk from .out with awk: - # generate_chk(INPUT OUTPUT [DEPENDS ...]) - function(generate_chk) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GC_INPUT) - message(FATAL_ERROR "generate_chk: Missing INPUT argument") - endif() - if(NOT _GC_OUTPUT) - message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GC_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DINPUT=${_GC_INPUT}" - "-DOUTPUT=${_GC_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake" - DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Generate .out from .c with awk: - # generate_out(INPUT OUTPUT [DEPENDS ...]) - function(generate_out) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GO_INPUT) - message(FATAL_ERROR "generate_out: Missing INPUT argument") - endif() - if(NOT _GO_OUTPUT) - message(FATAL_ERROR "generate_out: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DINPUT=${_GO_INPUT}" - "-DOUTPUT=${_GO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake" - DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Generate specific source file with awk: - # generate_source(OUTPUT [DEPENDS ...]) - function(generate_source) - set(options) - set(oneValueArgs OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GSO_OUTPUT) - message(FATAL_ERROR "generate_source: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DOUTPUT=${_GSO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake" - DEPENDS ${_GSO_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Copy file: - # generate_copy(INPUT OUTPUT [DEPENDS ...]) - function(generate_copy) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GCO_INPUT) - message(FATAL_ERROR "generate_copy: Missing INPUT argument") - endif() - if(NOT _GCO_OUTPUT) - message(FATAL_ERROR "generate_copy: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GCO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - -E remove "${_GCO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - -E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}" - DEPENDS "${source}" ${_GCO_DEPENDS}) - endfunction() - # Generate scripts/pnglibconf.h generate_source(OUTPUT "scripts/pnglibconf.c" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" @@ -771,32 +687,8 @@ endif() if(PNG_TESTS AND PNG_SHARED) enable_testing() - # Add a custom target to run a test: - # png_add_test(NAME COMMAND [OPTIONS ...] [FILES ...]) - function(png_add_test) - set(options) - set(oneValueArgs NAME COMMAND) - set(multiValueArgs OPTIONS FILES) - cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _PAT_NAME) - message(FATAL_ERROR "png_add_test: Missing NAME argument") - endif() - if(NOT _PAT_COMMAND) - message(FATAL_ERROR "png_add_test: Missing COMMAND argument") - endif() - - set(TEST_OPTIONS "${_PAT_OPTIONS}") - set(TEST_FILES "${_PAT_FILES}") - - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" - @ONLY) - add_test(NAME "${_PAT_NAME}" - COMMAND "${CMAKE_COMMAND}" - "-DLIBPNG=$" - "-DTEST_COMMAND=$" - -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") - endfunction() + # Include the internal module PNGTest.cmake + include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGTest.cmake) # Find test PNG files by globbing, but sort lists to ensure # consistency between different filesystems. @@ -980,6 +872,10 @@ endif() # or make a copy of the target file (if symlinking is not possible): # create_symlink( [FILE | TARGET ]) function(create_symlink DEST_FILE) + # TODO: + # Replace this implementation with CMake's built-in create_symlink function, + # which has been fully functional on all platforms, including Windows, since + # CMake version 3.13. cmake_parse_arguments(_SYM "" "FILE;TARGET" "" ${ARGN}) if(NOT _SYM_FILE AND NOT _SYM_TARGET) message(FATAL_ERROR "create_symlink: Missing FILE or TARGET argument") diff --git a/scripts/cmake/PNGGenConfig.cmake b/scripts/cmake/PNGGenConfig.cmake new file mode 100644 index 0000000000..4a0030edde --- /dev/null +++ b/scripts/cmake/PNGGenConfig.cmake @@ -0,0 +1,104 @@ +# PNGGenConfig.cmake +# Utility functions for configuring and building libpng + +# Copyright (c) 2018-2025 Cosmin Truta +# Copyright (c) 2016-2018 Glenn Randers-Pehrson +# Written by Roger Leigh, 2016 +# +# Use, modification and distribution are subject to +# the same licensing terms and conditions as libpng. +# Please see the copyright notice in png.h or visit +# http://libpng.org/pub/png/src/libpng-LICENSE.txt +# +# SPDX-License-Identifier: libpng-2.0 + +# Generate .chk from .out with awk, based upon the automake logic: +# generate_chk(INPUT OUTPUT [DEPENDS ...]) +function(generate_chk) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GC_INPUT) + message(FATAL_ERROR "generate_chk: Missing INPUT argument") + endif() + if(NOT _GC_OUTPUT) + message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") + endif() + + # Run genchk.cmake to generate the .chk file. + add_custom_command(OUTPUT "${_GC_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GC_INPUT}" + "-DOUTPUT=${_GC_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake" + DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +endfunction() + +# Generate .out from C source file with awk: +# generate_out(INPUT OUTPUT [DEPENDS ...]) +function(generate_out) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GO_INPUT) + message(FATAL_ERROR "generate_out: Missing INPUT argument") + endif() + if(NOT _GO_OUTPUT) + message(FATAL_ERROR "generate_out: Missing OUTPUT argument") + endif() + + # Run genout.cmake to generate the .out file. + add_custom_command(OUTPUT "${_GO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GO_INPUT}" + "-DOUTPUT=${_GO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake" + DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +endfunction() + +# Generate a source file with awk: +# generate_source(OUTPUT [DEPENDS ...]) +function(generate_source) + set(options) + set(oneValueArgs OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GSO_OUTPUT) + message(FATAL_ERROR "generate_source: Missing OUTPUT argument") + endif() + + # Run gensrc.cmake to generate the source file. + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=${_GSO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake" + DEPENDS ${_GSO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +endfunction() + +# Generate an identical file copy: +# generate_copy(INPUT OUTPUT [DEPENDS ...]) +function(generate_copy) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GCO_INPUT) + message(FATAL_ERROR "generate_copy: Missing INPUT argument") + endif() + if(NOT _GCO_OUTPUT) + message(FATAL_ERROR "generate_copy: Missing OUTPUT argument") + endif() + + # Make a forced file copy, overwriting any pre-existing output file. + add_custom_command(OUTPUT "${_GCO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + -E remove "${_GCO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + -E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}" + DEPENDS "${source}" ${_GCO_DEPENDS}) +endfunction() diff --git a/scripts/cmake/PNGTest.cmake b/scripts/cmake/PNGTest.cmake new file mode 100644 index 0000000000..184773bc0d --- /dev/null +++ b/scripts/cmake/PNGTest.cmake @@ -0,0 +1,42 @@ +# PNGTest.cmake +# Utility functions for testing libpng + +# Copyright (c) 2018-2025 Cosmin Truta +# Copyright (c) 2016-2018 Glenn Randers-Pehrson +# Written by Roger Leigh, 2016 +# +# Use, modification and distribution are subject to +# the same licensing terms and conditions as libpng. +# Please see the copyright notice in png.h or visit +# http://libpng.org/pub/png/src/libpng-LICENSE.txt +# +# SPDX-License-Identifier: libpng-2.0 + +# Add a custom target to run a test: +# png_add_test(NAME COMMAND [OPTIONS ...] [FILES ...]) +function(png_add_test) + set(options) + set(oneValueArgs NAME COMMAND) + set(multiValueArgs OPTIONS FILES) + cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _PAT_NAME) + message(FATAL_ERROR "png_add_test: Missing NAME argument") + endif() + if(NOT _PAT_COMMAND) + message(FATAL_ERROR "png_add_test: Missing COMMAND argument") + endif() + + # Initialize the global variables used by the "${_PAT_NAME}.cmake" script. + set(TEST_OPTIONS "${_PAT_OPTIONS}") + set(TEST_FILES "${_PAT_FILES}") + + # Generate and run the "${_PAT_NAME}.cmake" script. + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" + @ONLY) + add_test(NAME "${_PAT_NAME}" + COMMAND "${CMAKE_COMMAND}" + "-DLIBPNG=$" + "-DTEST_COMMAND=$" + -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") +endfunction() From 3714c584b181cda92f4b3227971c723701f6a080 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Mon, 6 Jan 2025 19:48:56 +0200 Subject: [PATCH 083/112] chore: Rerun `./autogen.sh --maintainer` --- configure | 1261 +++++++++++++++++++++++-------- ltmain.sh | 736 ++++++++++-------- scripts/autoconf/libtool.m4 | 462 ++++++----- scripts/autoconf/ltoptions.m4 | 106 ++- scripts/autoconf/ltsugar.m4 | 2 +- scripts/autoconf/ltversion.m4 | 12 +- scripts/autoconf/lt~obsolete.m4 | 2 +- 7 files changed, 1706 insertions(+), 875 deletions(-) diff --git a/configure b/configure index a7b74490d4..9dc8961856 100755 --- a/configure +++ b/configure @@ -834,8 +834,10 @@ enable_dependency_tracking with_gnu_ld enable_shared enable_static +enable_pic with_pic enable_fast_install +enable_aix_soname with_aix_soname with_sysroot enable_libtool_lock @@ -1509,8 +1511,13 @@ Optional Features: speeds up one-time build --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] + --enable-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + both] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] + --enable-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. --disable-libtool-lock avoid locking (might break parallel builds) --disable-tests do not build the test programs (default is to build) --disable-tools do not build the auxiliary tools (default is to @@ -1588,11 +1595,6 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use - both] - --with-aix-soname=aix|svr4|both - shared library versioning (aka "SONAME") variant to - provide on AIX, [default=aix]. --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-zlib-prefix prefix that may have been used in installed zlib @@ -5436,7 +5438,7 @@ if test yes = "$GCC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 printf %s "checking for ld used by $CC... " >&6; } case $host in - *-*-mingw*) + *-*-mingw* | *-*-windows*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) @@ -5778,8 +5780,8 @@ esac -macro_version='2.4.7' -macro_revision='2.4.7' +macro_version='2.5.4' +macro_revision='2.5.4' @@ -5840,7 +5842,7 @@ else # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in - mingw*) lt_bad_file=conftest.nm/nofile ;; + mingw* | windows*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in @@ -6055,14 +6057,14 @@ else case e in #( lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. + gnu* | ironclad*) + # Under GNU Hurd and Ironclad, this test is not required because there + # is no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, @@ -6084,7 +6086,7 @@ else case e in #( lt_cv_sys_max_cmd_len=8192; ;; - bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) + darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -6227,7 +6229,7 @@ else case e in #( e) case $host in *-*-mingw* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) @@ -6240,7 +6242,7 @@ else case e in #( ;; *-*-cygwin* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) @@ -6276,9 +6278,9 @@ else case e in #( e) #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in - *-*-mingw* ) + *-*-mingw* | *-*-windows* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac @@ -6314,7 +6316,7 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi @@ -6336,9 +6338,8 @@ esac -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args. -set dummy ${ac_tool_prefix}file; ac_word=$2 +# Extract the first word of "file", so it can be a program name with args. +set dummy file; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_FILECMD+y} @@ -6359,7 +6360,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_FILECMD="${ac_tool_prefix}file" + ac_cv_prog_FILECMD="file" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6367,6 +6368,7 @@ done done IFS=$as_save_IFS + test -z "$ac_cv_prog_FILECMD" && ac_cv_prog_FILECMD=":" fi ;; esac fi @@ -6380,66 +6382,6 @@ printf "%s\n" "no" >&6; } fi -fi -if test -z "$ac_cv_prog_FILECMD"; then - ac_ct_FILECMD=$FILECMD - # Extract the first word of "file", so it can be a program name with args. -set dummy file; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_FILECMD+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if test -n "$ac_ct_FILECMD"; then - ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_FILECMD="file" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi ;; -esac -fi -ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD -if test -n "$ac_ct_FILECMD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5 -printf "%s\n" "$ac_ct_FILECMD" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_FILECMD" = x; then - FILECMD=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - FILECMD=$ac_ct_FILECMD - fi -else - FILECMD="$ac_cv_prog_FILECMD" -fi - @@ -6571,7 +6513,6 @@ lt_cv_deplibs_check_method='unknown' # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure @@ -6598,7 +6539,7 @@ cygwin*) lt_cv_file_magic_cmd='func_win32_libid' ;; -mingw* | pw32*) +mingw* | windows* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. @@ -6607,7 +6548,7 @@ mingw* | pw32*) lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; @@ -6680,7 +6621,11 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; -netbsd*) +*-mlibc) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else @@ -6698,7 +6643,7 @@ newos6*) lt_cv_deplibs_check_method=pass_all ;; -openbsd* | bitrig*) +openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else @@ -6714,6 +6659,10 @@ rdos*) lt_cv_deplibs_check_method=pass_all ;; +serenity*) + lt_cv_deplibs_check_method=pass_all + ;; + solaris*) lt_cv_deplibs_check_method=pass_all ;; @@ -6766,7 +6715,7 @@ file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in - mingw* | pw32*) + mingw* | windows* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else @@ -6922,7 +6871,7 @@ else case e in #( e) lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in @@ -6954,6 +6903,110 @@ test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_RANLIB+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +printf "%s\n" "$RANLIB" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_RANLIB+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +printf "%s\n" "$ac_ct_RANLIB" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + if test -n "$ac_tool_prefix"; then for ac_prog in ar do @@ -7075,7 +7128,7 @@ fi # Use ARFLAGS variable as AR's operation code to sync the variable naming with # Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have -# higher priority because thats what people were doing historically (setting +# higher priority because that's what people were doing historically (setting # ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS # variable obsoleted/removed. @@ -7267,139 +7320,29 @@ test -z "$STRIP" && STRIP=: -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_RANLIB+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi ;; -esac -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -printf "%s\n" "$RANLIB" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi +test -z "$RANLIB" && RANLIB=: + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_RANLIB+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi ;; -esac -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -printf "%s\n" "$ac_ct_RANLIB" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -test -z "$RANLIB" && RANLIB=: - - - - - - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - bitrig* | openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; esac @@ -7472,7 +7415,7 @@ case $host_os in aix*) symcode='[BCDT]' ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) @@ -7487,7 +7430,7 @@ osf*) symcode='[BCDEGQRST]' ;; solaris*) - symcode='[BDRT]' + symcode='[BCDRT]' ;; sco3.2v5*) symcode='[DT]' @@ -7551,7 +7494,7 @@ $lt_c_name_lib_hook\ # Handle CRLF in mingw tool chain opt_cr= case $build_os in -mingw*) +mingw* | windows*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac @@ -7602,7 +7545,7 @@ void nm_test_func(void){} #ifdef __cplusplus } #endif -int main(){nm_test_var='a';nm_test_func();return(0);} +int main(void){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 @@ -7612,11 +7555,8 @@ _LT_EOF test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -7787,7 +7727,9 @@ lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` + # Trim trailing / since we'll always append absolute paths and we want + # to avoid //, if only for less confusing output for the user. + lt_sysroot=`$CC --print-sysroot 2>/dev/null | $SED 's:/\+$::'` fi ;; #( /*) @@ -8004,7 +7946,7 @@ mips64*-*linux*) ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) +s390*-*linux*|s390*-*tpf*|sparc*-*linux*|x86_64-gnu*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when @@ -8023,7 +7965,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) case `$FILECMD conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" @@ -8052,7 +7994,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) @@ -8273,23 +8215,23 @@ fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if test ${lt_cv_path_mainfest_tool+y} +if test ${lt_cv_path_manifest_tool+y} then : printf %s "(cached) " >&6 else case e in #( - e) lt_cv_path_mainfest_tool=no + e) lt_cv_path_manifest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes + lt_cv_path_manifest_tool=yes fi rm -f conftest* ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } -if test yes != "$lt_cv_path_mainfest_tool"; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_manifest_tool" >&5 +printf "%s\n" "$lt_cv_path_manifest_tool" >&6; } +if test yes != "$lt_cv_path_manifest_tool"; then MANIFEST_TOOL=: fi @@ -8884,6 +8826,45 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } + # Feature test to disable chained fixups since it is not + # compatible with '-undefined dynamic_lookup' + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -no_fixup_chains linker flag" >&5 +printf %s "checking for -no_fixup_chains linker flag... " >&6; } +if test ${lt_cv_support_no_fixup_chains+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-no_fixup_chains" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + lt_cv_support_no_fixup_chains=yes +else case e in #( + e) lt_cv_support_no_fixup_chains=no + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_support_no_fixup_chains" >&5 +printf "%s\n" "$lt_cv_support_no_fixup_chains" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 printf %s "checking for -exported_symbols_list linker flag... " >&6; } if test ${lt_cv_ld_exported_symbols_list+y} @@ -8938,7 +8919,7 @@ _LT_EOF echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF -int main() { return 0;} +int main(void) { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err @@ -8967,13 +8948,32 @@ printf "%s\n" "$lt_cv_ld_force_load" >&6; } 10.[012],*|,*powerpc*-darwin[5-8]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; *) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' + if test yes = "$lt_cv_support_no_fixup_chains"; then + as_fn_append _lt_dar_allow_undefined ' $wl-no_fixup_chains' + fi + ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi + _lt_dar_needs_single_mod=no + case $host_os in + rhapsody* | darwin1.*) + _lt_dar_needs_single_mod=yes ;; + darwin*) + # When targeting Mac OS X 10.4 (darwin 8) or later, + # -single_module is the default and -multi_module is unsupported. + # The toolchain on macOS 10.14 (darwin 18) and later cannot + # target any OS version that needs -single_module. + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*-darwin[567].*|10.[0-3],*-darwin[5-9].*|10.[0-3],*-darwin1[0-7].*) + _lt_dar_needs_single_mod=yes ;; + esac + ;; + esac if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else @@ -9067,7 +9067,7 @@ fi enable_win32_dll=yes case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) +*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 @@ -9473,31 +9473,54 @@ fi - -# Check whether --with-pic was given. + # Check whether --enable-pic was given. +if test ${enable_pic+y} +then : + enableval=$enable_pic; lt_p=${PACKAGE-default} + case $enableval in + yes|no) pic_mode=$enableval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac +else case e in #( + e) # Check whether --with-pic was given. if test ${with_pic+y} then : withval=$with_pic; lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, - for lt_pkg in $withval; do - IFS=$lt_save_ifs - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS=$lt_save_ifs - ;; - esac + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac else case e in #( e) pic_mode=default ;; esac fi + ;; +esac +fi + @@ -9542,18 +9565,29 @@ case $host,$enable_shared in power*-*-aix[5-9]*,yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 printf %s "checking which variant of shared library versioning to provide... " >&6; } - -# Check whether --with-aix-soname was given. + # Check whether --enable-aix-soname was given. +if test ${enable_aix_soname+y} +then : + enableval=$enable_aix_soname; case $enableval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --enable-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$enable_aix_soname +else case e in #( + e) # Check whether --with-aix-soname was given. if test ${with_aix_soname+y} then : withval=$with_aix_soname; case $withval in - aix|svr4|both) - ;; - *) - as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 - ;; - esac - lt_cv_with_aix_soname=$with_aix_soname + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname else case e in #( e) if test ${lt_cv_with_aix_soname+y} then : @@ -9561,12 +9595,16 @@ then : else case e in #( e) lt_cv_with_aix_soname=aix ;; esac +fi + ;; +esac fi - with_aix_soname=$lt_cv_with_aix_soname ;; + enable_aix_soname=$lt_cv_with_aix_soname ;; esac fi + with_aix_soname=$enable_aix_soname { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 printf "%s\n" "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then @@ -9882,7 +9920,7 @@ objext=$objext lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' +lt_simple_link_test_code='int main(void){return(0);}' @@ -10024,7 +10062,7 @@ lt_prog_compiler_static= # PIC is the default for these OSes. ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -10127,7 +10165,7 @@ lt_prog_compiler_static= esac ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' @@ -10168,6 +10206,12 @@ lt_prog_compiler_static= lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; + *flang* | ftn | f18* | f95*) + # Flang compiler. + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -10250,6 +10294,12 @@ lt_prog_compiler_static= lt_prog_compiler_static='-Bstatic' ;; + *-mlibc) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. @@ -10266,6 +10316,9 @@ lt_prog_compiler_static= lt_prog_compiler_static='-non_shared' ;; + serenity*) + ;; + solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' @@ -10639,7 +10692,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries extract_expsyms_cmds= case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. @@ -10651,9 +10704,6 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; - openbsd* | bitrig*) - with_gnu_ld=no - ;; esac ld_shlibs=yes @@ -10754,7 +10804,7 @@ _LT_EOF fi ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -10764,6 +10814,7 @@ _LT_EOF enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + file_list_spec='@' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' @@ -10783,7 +10834,7 @@ _LT_EOF haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - link_all_deplibs=yes + link_all_deplibs=no ;; os2*) @@ -10810,7 +10861,7 @@ _LT_EOF cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' - old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes file_list_spec='@' ;; @@ -10889,6 +10940,7 @@ _LT_EOF case $cc_basename in tcc*) + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) @@ -10909,7 +10961,12 @@ _LT_EOF fi ;; - netbsd*) + *-mlibc) + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= @@ -11301,7 +11358,7 @@ fi export_dynamic_flag_spec=-rdynamic ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -11318,14 +11375,14 @@ fi # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_cmds='$CC -Fe$output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + $CC -Fe$tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' @@ -11608,11 +11665,15 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' ;; esac ;; - netbsd*) + *-mlibc) + ;; + + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else @@ -11634,7 +11695,7 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } *nto* | *qnx*) ;; - openbsd* | bitrig*) + openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no @@ -11677,7 +11738,7 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' - old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes file_list_spec='@' ;; @@ -11713,6 +11774,9 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } hardcode_libdir_separator=: ;; + serenity*) + ;; + solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then @@ -12119,7 +12183,7 @@ if test yes = "$GCC"; then *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in - mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + mingw* | windows* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` @@ -12177,7 +12241,7 @@ BEGIN {RS = " "; FS = "/|\n";} { # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + mingw* | windows* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` @@ -12251,7 +12315,7 @@ aix[4-9]*) # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl - # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # linker flag in LDFLAGS as well, or --enable-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the @@ -12345,7 +12409,7 @@ bsdi[45]*) # libtool to hard-code these into programs ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no @@ -12356,15 +12420,29 @@ cygwin* | mingw* | pw32* | cegcc*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \$file`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' + # If user builds GCC with multilib enabled, + # it should just install on $(libdir) + # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones. + if test xyes = x"$multilib"; then + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + $install_prog $dir/$dlname $destdir/$dlname~ + chmod a+x $destdir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib $destdir/$dlname'\'' || exit \$?; + fi' + else + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + fi postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' @@ -12377,7 +12455,7 @@ cygwin* | mingw* | pw32* | cegcc*) sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; - mingw* | cegcc*) + mingw* | windows* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; @@ -12396,7 +12474,7 @@ cygwin* | mingw* | pw32* | cegcc*) library_names_spec='$libname.dll.lib' case $build_os in - mingw*) + mingw* | windows*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' @@ -12503,7 +12581,28 @@ freebsd* | dragonfly* | midnightbsd*) need_version=yes ;; esac + case $host_cpu in + powerpc64) + # On FreeBSD bi-arch platforms, a different variable is used for 32-bit + # binaries. See . + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int test_pointer_size[sizeof (void *) - 5]; + +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : shlibpath_var=LD_LIBRARY_PATH +else case e in #( + e) shlibpath_var=LD_32_LIBRARY_PATH ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; + *) + shlibpath_var=LD_LIBRARY_PATH + ;; + esac case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes @@ -12533,8 +12632,9 @@ haiku*) soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes + sys_lib_search_path_spec='/boot/system/non-packaged/develop/lib /boot/system/develop/lib' + sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib' + hardcode_into_libs=no ;; hpux9* | hpux10* | hpux11*) @@ -12644,7 +12744,7 @@ linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no - library_names_spec='$libname$release$shared_ext' + library_names_spec='$libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH @@ -12656,8 +12756,9 @@ linux*android*) hardcode_into_libs=yes dynamic_linker='Android linker' - # Don't embed -rpath directories since the linker doesn't support them. - hardcode_libdir_flag_spec='-L$libdir' + # -rpath works at least for libraries that are not overridden by + # libraries installed in system locations. + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' ;; # This must be glibc/ELF. @@ -12714,7 +12815,7 @@ fi # before this can be enabled. hardcode_into_libs=yes - # Ideally, we could use ldconfig to report *all* directores which are + # Ideally, we could use ldconfig to report *all* directories which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, @@ -12734,6 +12835,18 @@ fi dynamic_linker='GNU/Linux ld.so' ;; +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + netbsd*) version_type=sunos need_lib_prefix=no @@ -12752,6 +12865,18 @@ netbsd*) hardcode_into_libs=yes ;; +*-mlibc) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='mlibc ld.so' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' @@ -12771,7 +12896,7 @@ newsos6) dynamic_linker='ldqnx.so' ;; -openbsd* | bitrig*) +openbsd*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no @@ -12831,6 +12956,17 @@ rdos*) dynamic_linker=no ;; +serenity*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + dynamic_linker='SerenityOS LibELF' + ;; + solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no @@ -12928,6 +13064,496 @@ uts4*) shlibpath_var=LD_LIBRARY_PATH ;; +emscripten*) + version_type=none + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + dynamic_linker="Emscripten linker" + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + + + if test yes = "$GCC"; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + lt_prog_compiler_pic='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + *flang* | ftn | f18* | f95*) + # Flang compiler. + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | $SED 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *-mlibc) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + serenity*) + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +printf %s "checking for $compiler option to produce PIC... " >&6; } +if test ${lt_cv_prog_compiler_pic+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) lt_cv_prog_compiler_pic=$lt_prog_compiler_pic ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test ${lt_cv_prog_compiler_pic_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_pic_works"; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test ${lt_cv_prog_compiler_static_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) lt_cv_prog_compiler_static_works=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } + +if test yes = "$lt_cv_prog_compiler_static_works"; then + : +else + lt_prog_compiler_static= +fi + + + +='-fPIC' + archive_cmds='$CC -sSIDE_MODULE=2 -shared $libobjs $deplibs $compiler_flags -o $lib' + archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -sSIDE_MODULE=2 -shared $libobjs $deplibs $compiler_flags -o $lib -s EXPORTED_FUNCTIONS=@$output_objdir/$soname.expsym' + archive_cmds_need_lc=no + no_undefined_flag= + ;; + *) dynamic_linker=no ;; @@ -13112,7 +13738,7 @@ else lt_cv_dlopen_self=yes ;; - mingw* | pw32* | cegcc*) + mingw* | windows* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; @@ -13485,11 +14111,11 @@ else /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); +int fnord (void) __attribute__((visibility("default"))); #endif -int fnord () { return 42; } -int main () +int fnord (void) { return 42; } +int main (void) { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; @@ -13593,11 +14219,11 @@ else /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); +int fnord (void) __attribute__((visibility("default"))); #endif -int fnord () { return 42; } -int main () +int fnord (void) { return 42; } +int main (void) { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; @@ -16735,19 +17361,18 @@ See 'config.log' for more details" "$LINENO" 5; } cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 -# Copyright (C) 2014 Free Software Foundation, Inc. +# Copyright (C) 2024 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of of the License, or +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you @@ -17131,7 +17756,7 @@ hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \$shlibpath_var if the +# "absolute",i.e. impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute diff --git a/ltmain.sh b/ltmain.sh index 2a50d7f6f7..3e6a3db3a5 100755 --- a/ltmain.sh +++ b/ltmain.sh @@ -2,11 +2,11 @@ ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in ## by inline-source v2019-02-19.15 -# libtool (GNU libtool) 2.4.7 +# libtool (GNU libtool) 2.5.4 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 -# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. +# Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -31,8 +31,8 @@ PROGRAM=libtool PACKAGE=libtool -VERSION=2.4.7 -package_revision=2.4.7 +VERSION=2.5.4 +package_revision=2.5.4 ## ------ ## @@ -72,11 +72,11 @@ scriptversion=2019-02-19.15; # UTC # This is free software. There is NO warranty; not even for # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# Copyright (C) 2004-2019, 2021 Bootstrap Authors +# Copyright (C) 2004-2019, 2021, 2023-2024 Bootstrap Authors # # This file is dual licensed under the terms of the MIT license -# , and GPL version 2 or later -# . You must apply one of +# , and GPL version 2 or later +# . You must apply one of # these licenses when using or redistributing this software or any of # the files within it. See the URLs above, or the file `LICENSE` # included in the Bootstrap distribution for the full license texts. @@ -143,7 +143,7 @@ nl=' ' IFS="$sp $nl" -# There are apparently some retarded systems that use ';' as a PATH separator! +# There are apparently some systems that use ';' as a PATH separator! if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { @@ -589,7 +589,7 @@ func_require_term_colors () # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is - # useable or anything else if it does not work. + # usable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes @@ -739,7 +739,7 @@ eval 'func_dirname () # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. -# value retuned in "$func_basename_result" +# value returned in "$func_basename_result" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () @@ -897,7 +897,7 @@ func_mkdir_p () # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. + # list in case some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done @@ -1536,11 +1536,11 @@ func_lt_ver () # This is free software. There is NO warranty; not even for # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# Copyright (C) 2010-2019, 2021 Bootstrap Authors +# Copyright (C) 2010-2019, 2021, 2023-2024 Bootstrap Authors # # This file is dual licensed under the terms of the MIT license -# , and GPL version 2 or later -# . You must apply one of +# , and GPL version 2 or later +# . You must apply one of # these licenses when using or redistributing this software or any of # the files within it. See the URLs above, or the file `LICENSE` # included in the Bootstrap distribution for the full license texts. @@ -2215,7 +2215,30 @@ func_version () # End: # Set a version string. -scriptversion='(GNU libtool) 2.4.7' +scriptversion='(GNU libtool) 2.5.4' + +# func_version +# ------------ +# Echo version message to standard output and exit. +func_version () +{ + $debug_cmd + + year=`date +%Y` + + cat < +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. + +Originally written by Gordon Matzigkeit, 1996 +(See AUTHORS for complete contributor listing) +EOF + + exit $? +} # func_echo ARG... @@ -2238,18 +2261,6 @@ func_echo () } -# func_warning ARG... -# ------------------- -# Libtool warnings are not categorized, so override funclib.sh -# func_warning with this simpler definition. -func_warning () -{ - $debug_cmd - - $warning_func ${1+"$@"} -} - - ## ---------------- ## ## Options parsing. ## ## ---------------- ## @@ -2261,19 +2272,23 @@ usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: - --config show all configuration variables - --debug enable verbose shell tracing - -n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --mode=MODE use operation mode MODE - --no-warnings equivalent to '-Wnone' - --preserve-dup-deps don't remove duplicate dependency libraries - --quiet, --silent don't print informational messages - --tag=TAG use configuration variables from tag TAG - -v, --verbose print more informational messages than default - --version print version information - -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] - -h, --help, --help-all print short, long, or detailed help message + --config show all configuration variables + --debug enable verbose shell tracing + -n, --dry-run display commands without modifying any files + --features display basic configuration information + --finish use operation '--mode=finish' + --mode=MODE use operation mode MODE + --no-finish don't update shared library cache + --no-quiet, --no-silent print default informational messages + --no-warnings equivalent to '-Wnone' + --preserve-dup-deps don't remove duplicate dependency libraries + --quiet, --silent don't print informational messages + --reorder-cache=DIRS reorder shared library cache for preferred DIRS + --tag=TAG use configuration variables from tag TAG + -v, --verbose print more informational messages than default + --version print version information + -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] + -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. @@ -2306,13 +2321,13 @@ include the following information: compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) - version: $progname (GNU libtool) 2.4.7 + version: $progname $scriptversion automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . -GNU libtool home page: . -General help using GNU software: ." +GNU libtool home page: . +General help using GNU software: ." exit 0 } @@ -2502,8 +2517,11 @@ libtool_options_prep () opt_dry_run=false opt_help=false opt_mode= + opt_reorder_cache=false opt_preserve_dup_deps=false opt_quiet=false + opt_finishing=true + opt_warning= nonopt= preserve_args= @@ -2593,14 +2611,18 @@ libtool_parse_options () clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error - *) func_error "invalid argument for $_G_opt" + *) func_error "invalid argument '$1' for $_G_opt" exit_cmd=exit - break ;; esac shift ;; + --no-finish) + opt_finishing=false + func_append preserve_args " $_G_opt" + ;; + --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" @@ -2616,6 +2638,24 @@ libtool_parse_options () func_append preserve_args " $_G_opt" ;; + --reorder-cache) + opt_reorder_cache=true + shared_lib_dirs=$1 + if test -n "$shared_lib_dirs"; then + case $1 in + # Must begin with /: + /*) ;; + + # Catch anything else as an error (relative paths) + *) func_error "invalid argument '$1' for $_G_opt" + func_error "absolute paths are required for $_G_opt" + exit_cmd=exit + ;; + esac + fi + shift + ;; + --silent|--quiet) opt_quiet=: opt_verbose=false @@ -2652,6 +2692,18 @@ libtool_parse_options () func_add_hook func_parse_options libtool_parse_options +# func_warning ARG... +# ------------------- +# Libtool warnings are not categorized, so override funclib.sh +# func_warning with this simpler definition. +func_warning () +{ + if $opt_warning; then + $debug_cmd + $warning_func ${1+"$@"} + fi +} + # libtool_validate_options [ARG]... # --------------------------------- @@ -2668,10 +2720,10 @@ libtool_validate_options () # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" - case $host in + case $host_os in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 - *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; @@ -3003,7 +3055,7 @@ EOF # func_convert_core_file_wine_to_w32 ARG # Helper function used by file name conversion functions when $build is *nix, -# and $host is mingw, cygwin, or some other w32 environment. Relies on a +# and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a # correctly configured wine environment available, with the winepath program # in $build's $PATH. # @@ -3035,9 +3087,10 @@ func_convert_core_file_wine_to_w32 () # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. +# $host is mingw, windows, cygwin, or some other w32 environment. Relies on a +# correctly configured wine environment available, with the winepath program +# in $build's $PATH. Assumes ARG has no leading or trailing path separator +# characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. @@ -3180,6 +3233,15 @@ func_convert_path_front_back_pathsep () # end func_convert_path_front_back_pathsep +# func_convert_delimited_path PATH ORIG_DELIMITER NEW_DELIMITER +# Replaces a delimiter for a given path. +func_convert_delimited_path () +{ + converted_path=`$ECHO "$1" | $SED "s#$2#$3#g"` +} +# end func_convert_delimited_path + + ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## @@ -3514,6 +3576,65 @@ func_dll_def_p () } +# func_reorder_shared_lib_cache DIRS +# Reorder the shared library cache by unconfiguring previous shared library cache +# and configuring preferred search directories before previous search directories. +# Previous shared library cache: /usr/lib /usr/local/lib +# Preferred search directories: /tmp/testing +# Reordered shared library cache: /tmp/testing /usr/lib /usr/local/lib +func_reorder_shared_lib_cache () +{ + $debug_cmd + + case $host_os in + openbsd*) + get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"` + func_convert_delimited_path "$get_search_directories" ':' '\ ' + save_search_directories=$converted_path + func_convert_delimited_path "$1" ':' '\ ' + + # Ensure directories exist + for dir in $converted_path; do + # Ensure each directory is an absolute path + case $dir in + /*) ;; + *) func_error "Directory '$dir' is not an absolute path" + exit $EXIT_FAILURE ;; + esac + # Ensure no trailing slashes + func_stripname '' '/' "$dir" + dir=$func_stripname_result + if test -d "$dir"; then + if test -n "$preferred_search_directories"; then + preferred_search_directories="$preferred_search_directories $dir" + else + preferred_search_directories=$dir + fi + else + func_error "Directory '$dir' does not exist" + exit $EXIT_FAILURE + fi + done + + PATH="$PATH:/sbin" ldconfig -U $save_search_directories + PATH="$PATH:/sbin" ldconfig -m $preferred_search_directories $save_search_directories + get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"` + func_convert_delimited_path "$get_search_directories" ':' '\ ' + reordered_search_directories=$converted_path + + $ECHO "Original: $save_search_directories" + $ECHO "Reordered: $reordered_search_directories" + exit $EXIT_SUCCESS + ;; + *) + func_error "--reorder-cache is not supported for host_os=$host_os." + exit $EXIT_FAILURE + ;; + esac +} +# end func_reorder_shared_lib_cache + + # func_mode_compile arg... func_mode_compile () { @@ -3692,7 +3813,7 @@ func_mode_compile () # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) + cygwin* | mingw* | windows* | pw32* | os2* | cegcc*) pic_mode=default ;; esac @@ -4086,6 +4207,12 @@ if $opt_help; then fi +# If option '--reorder-cache', reorder the shared library cache and exit. +if $opt_reorder_cache; then + func_reorder_shared_lib_cache $shared_lib_dirs +fi + + # func_mode_execute arg... func_mode_execute () { @@ -4270,7 +4397,7 @@ func_mode_finish () fi fi - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs" && $opt_finishing; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. @@ -4295,6 +4422,12 @@ func_mode_finish () for libdir in $libdirs; do $ECHO " $libdir" done + if test "false" = "$opt_finishing"; then + echo + echo "NOTE: finish_cmds were not executed during testing, so you must" + echo "manually run ldconfig to add a given test directory, LIBDIR, to" + echo "the search path for generated executables." + fi echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" @@ -4531,8 +4664,15 @@ func_mode_install () func_append dir "$objdir" if test -n "$relink_command"; then + # Strip any trailing slash from the destination. + func_stripname '' '/' "$libdir" + destlibdir=$func_stripname_result + + func_stripname '' '/' "$destdir" + s_destdir=$func_stripname_result + # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that @@ -4569,7 +4709,7 @@ func_mode_install () 'exit $?' tstripme=$stripme case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= @@ -4682,7 +4822,7 @@ func_mode_install () # Do a test to see if this is really a libtool program. case $host in - *cygwin* | *mingw*) + *cygwin* | *mingw* | *windows*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result @@ -4910,7 +5050,7 @@ extern \"C\" { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; @@ -4922,7 +5062,7 @@ extern \"C\" { eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; @@ -4936,7 +5076,7 @@ extern \"C\" { func_basename "$dlprefile" name=$func_basename_result case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" @@ -4962,8 +5102,16 @@ extern \"C\" { eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + case $host in + i[3456]86-*-mingw32*) + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + ;; + *) + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/__nm_//' >> '$nlist'" + ;; + esac } else # not an import lib $opt_dry_run || { @@ -5111,7 +5259,7 @@ static const void *lt_preloaded_setup() { # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` @@ -5187,7 +5335,7 @@ func_win32_libid () *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || @@ -5454,7 +5602,7 @@ func_extract_archives () # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw +# incorporate the script contents within a cygwin/mingw/windows # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. @@ -5462,7 +5610,7 @@ func_extract_archives () # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is -# the $objdir directory. This is a cygwin/mingw-specific +# the $objdir directory. This is a cygwin/mingw/windows-specific # behavior. func_emit_wrapper () { @@ -5587,7 +5735,7 @@ func_exec_program_core () " case $host in # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) + *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 @@ -5655,7 +5803,7 @@ func_exec_program () file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done - # Usually 'no', except on cygwin/mingw when embedded into + # Usually 'no', except on cygwin/mingw/windows when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then @@ -5787,7 +5935,7 @@ EOF #endif #include #include -#ifdef _MSC_VER +#if defined _WIN32 && !defined __GNUC__ # include # include # include @@ -5812,7 +5960,7 @@ EOF /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ -int _putenv (const char *); +_CRTIMP int __cdecl _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ @@ -6010,7 +6158,7 @@ main (int argc, char *argv[]) { EOF case $host in - *mingw* | *cygwin* ) + *mingw* | *windows* | *cygwin* ) # make stdout use "unix" line endings echo " setmode(1,_O_BINARY);" ;; @@ -6029,7 +6177,7 @@ EOF { /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX namespace, but it is not one of the ones we know about and - have already dealt with, above (inluding dump-script), then + have already dealt with, above (including dump-script), then report an error. Otherwise, targets might begin to believe they are allowed to use options in the LTWRAPPER_OPTION_PREFIX namespace. The first time any user complains about this, we'll @@ -6113,7 +6261,7 @@ EOF EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" { char* p; @@ -6155,7 +6303,7 @@ EOF EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ newargz = prepare_spawn (newargz); @@ -6574,7 +6722,7 @@ lt_update_lib_path (const char *name, const char *value) EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). @@ -6749,7 +6897,7 @@ func_mode_link () $debug_cmd case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra @@ -6773,6 +6921,7 @@ func_mode_link () finalize_command=$nonopt compile_rpath= + compile_rpath_tail= finalize_rpath= compile_shlibpath= finalize_shlibpath= @@ -6813,10 +6962,12 @@ func_mode_link () xrpath= perm_rpath= temp_rpath= + temp_rpath_tail= thread_safe=no vinfo= vinfo_number=no weak_libs= + rpath_arg= single_module=$wl-single_module func_infer_tag $base_compile @@ -7079,7 +7230,7 @@ func_mode_link () case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) - func_fatal_error "only absolute run-paths are allowed" + func_fatal_error "argument to -rpath is not absolute: $arg" ;; esac if test rpath = "$prev"; then @@ -7255,7 +7406,7 @@ func_mode_link () ;; esac case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; @@ -7275,7 +7426,7 @@ func_mode_link () -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; @@ -7283,7 +7434,7 @@ func_mode_link () # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; @@ -7303,7 +7454,7 @@ func_mode_link () esac elif test X-lc_r = "X$arg"; then case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -7326,7 +7477,8 @@ func_mode_link () # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot|--sysroot) + # -q