1. 09 Jan, 2022 1 commit
  2. 29 Dec, 2021 1 commit
    • Disabling setting `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple platforms. · 3eb39819
      On macOS, since Big Sur, the libraries were moved to a cache. The SDK comes
      with stubs in the SDK (`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/`
      or whatever SDK version one has installed) where most have the `.tbd` suffix
      (although some still are `.a`). Forcing `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple
      platforms broke building, unless one has copies of the libraries installed
      elsewhere (like Brew), as many libraries (like `iconv` or `pcre`) are not
      found.
      
      This fix disables setting the `CMAKE_FIND_LIBRARY_SUFFIXES` to `.a` if
      the platform is `APPLE` when building static libs.
      Miguel Arroz committed
  3. 11 Nov, 2021 5 commits
  4. 18 Oct, 2021 5 commits
  5. 17 Oct, 2021 1 commit
  6. 22 Sep, 2021 1 commit
  7. 31 Aug, 2021 1 commit
  8. 25 Aug, 2021 2 commits
  9. 08 Aug, 2021 1 commit
  10. 30 Jul, 2021 1 commit
  11. 19 Jul, 2021 1 commit
    • alloc: add GIT_DEBUG_STRICT_ALLOC · 48e6b02b
      Add `GIT_DEBUG_STRICT_ALLOC` to help identify problematic callers of
      allocation code that pass a `0` size to the allocators and then expect a
      non-`NULL` return.
      
      When given a 0-size allocation, `malloc` _may_ return either a `NULL`
      _or_ a pointer that is not writeable.  Most systems return a non-`NULL`
      pointer; AIX is an outlier.  We should be able to cope with this AIXy
      behavior, so this adds an option to emulate it.
      Edward Thomson committed
  12. 04 Jan, 2021 1 commit
  13. 24 Dec, 2020 1 commit
    • zlib: Add support for building with Chromium's zlib implementation · 83265b3e
      This change builds libgit2 using Chromium's zlib implementation by
      invoking cmake with `-DUSE_BUNDLED_ZLIB=ON -DUSE_CHROMIUM_ZLIB=ON`,
      which is ~10% faster than the bundled zlib for the core::zstream suite.
      
      This version of zlib has some optimizations:
      
      a) Decompression (Intel+ARM): inflate_fast, adler32, crc32, etc.
      b) Compression (Intel): fill_window, longest_match, hash function, etc.
      
      Due to the introduction of SIMD optimizations, and to get the maximum
      performance out of this fork of zlib, this requires an x86_64 processor
      with SSE4.2 and CLMUL (anything Westmere or later, ~2010). The Chromium
      zlib implementation also supports ARM with NEON, but it has not been
      enabled in this patch.
      
      Performance
      ===========
      
      TL;DR: Running just `./libgit2_clar -score::zstream` 100 times in a loop
      took 0:56.30 before and 0:50.67 after (~10% reduction!).
      
      The bundled and system zlib implementations on an Ubuntu Focal system
      perform relatively similar (the bundled one is marginally better due to
      the compiler being able to inline some functions), so only the bundled
      and Chromium zlibs were compared.
      
      For a more balanced comparison (to ensure that nothing regressed
      overall), `libgit2_clar` under `perf` was also run, and the zlib-related
      functions were compared.
      
      Bundled
      -------
      
      ```shell
      cmake \
        -DUSE_BUNDLED_ZLIB=ON \
        -DUSE_CHROMIUM_ZLIB=OFF \
        -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
        -DCMAKE_C_FLAGS="-fPIC -fno-omit-frame-pointer" \
        -GNinja \
        ..
      ninja
      perf record --call-graph=dwarf ./libgit2_clar
      perf report --children
      ```
      
      ```
      Samples: 87K of event 'cycles', Event count (approx.): 75923450603
        Children      Self  Command       Shared Objec  Symbol
      +    4.14%     0.01%  libgit2_clar  libgit2_clar  [.] git_zstream_get_output_chunk
      +    2.91%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_get_output
      +    0.69%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_get_output (inlined)
           0.17%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_init
           0.02%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_reset
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_eos
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_done
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_free (inlined)
      
      Samples: 87K of event 'cycles', Event count (approx.): 75923450603
        Children      Self  Command       Shared Objec  Symbol
      +    3.12%     0.01%  libgit2_clar  libgit2_clar  [.] deflate
      +    2.65%     1.48%  libgit2_clar  libgit2_clar  [.] deflate_slow
      +    1.60%     0.55%  libgit2_clar  libgit2_clar  [.] inflate
      +    0.53%     0.00%  libgit2_clar  libgit2_clar  [.] write_deflate
           0.49%     0.36%  libgit2_clar  libgit2_clar  [.] inflate_fast
           0.46%     0.02%  libgit2_clar  libgit2_clar  [.] deflate_fast
           0.19%     0.19%  libgit2_clar  libgit2_clar  [.] inflate_table
           0.16%     0.01%  libgit2_clar  libgit2_clar  [.] inflateInit_
           0.15%     0.00%  libgit2_clar  libgit2_clar  [.] inflateInit2_ (inlined)
           0.10%     0.00%  libgit2_clar  libgit2_clar  [.] deflateInit_
           0.10%     0.00%  libgit2_clar  libgit2_clar  [.] deflateInit2_
           0.03%     0.00%  libgit2_clar  libgit2_clar  [.] deflateReset (inlined)
           0.02%     0.00%  libgit2_clar  libgit2_clar  [.] deflateReset
           0.02%     0.00%  libgit2_clar  libgit2_clar  [.] inflateEnd
           0.02%     0.00%  libgit2_clar  libgit2_clar  [.] deflateEnd
           0.01%     0.00%  libgit2_clar  libgit2_clar  [.] deflateResetKeep
           0.01%     0.01%  libgit2_clar  libgit2_clar  [.] inflateReset2
           0.01%     0.00%  libgit2_clar  libgit2_clar  [.] deflateReset (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateStateCheck (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateReset (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateStateCheck (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] deflateStateCheck (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateResetKeep (inlined)
      ```
      
      Chromium
      --------
      
      ```shell
      cmake \
        -DUSE_BUNDLED_ZLIB=ON \
        -DUSE_CHROMIUM_ZLIB=ON \
        -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
        -DCMAKE_C_FLAGS="-fPIC -fno-omit-frame-pointer" \
        -GNinja \
        ..
      ninja
      perf record --call-graph=dwarf ./libgit2_clar
      perf report --children
      ```
      
      ```
      Samples: 97K of event 'cycles', Event count (approx.): 80862210917
        Children      Self  Command       Shared Objec  Symbol
      +    3.31%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_get_output_chunk
      +    2.27%     0.01%  libgit2_clar  libgit2_clar  [.] git_zstream_get_output
      +    0.55%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_get_output (inlined)
           0.18%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_init
           0.02%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_reset
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_free (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_done
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] git_zstream_free
      
      Samples: 97K of event 'cycles', Event count (approx.): 80862210917
        Children      Self  Command       Shared Objec  Symbol
      +    2.55%     0.01%  libgit2_clar  libgit2_clar  [.] deflate
      +    2.25%     1.41%  libgit2_clar  libgit2_clar  [.] deflate_slow
      +    1.10%     0.52%  libgit2_clar  libgit2_clar  [.] inflate
           0.36%     0.00%  libgit2_clar  libgit2_clar  [.] write_deflate
           0.30%     0.03%  libgit2_clar  libgit2_clar  [.] deflate_fast
           0.28%     0.15%  libgit2_clar  libgit2_clar  [.] inflate_fast_chunk_
           0.19%     0.19%  libgit2_clar  libgit2_clar  [.] inflate_table
           0.17%     0.01%  libgit2_clar  libgit2_clar  [.] inflateInit_
           0.16%     0.00%  libgit2_clar  libgit2_clar  [.] inflateInit2_ (inlined)
           0.15%     0.00%  libgit2_clar  libgit2_clar  [.] deflateInit_
           0.15%     0.00%  libgit2_clar  libgit2_clar  [.] deflateInit2_
           0.11%     0.01%  libgit2_clar  libgit2_clar  [.] adler32_z
           0.09%     0.09%  libgit2_clar  libgit2_clar  [.] adler32_simd_
           0.05%     0.00%  libgit2_clar  libgit2_clar  [.] deflateReset (inlined)
           0.05%     0.00%  libgit2_clar  libgit2_clar  [.] deflate_read_buf
           0.03%     0.00%  libgit2_clar  libgit2_clar  [.] inflateEnd
           0.02%     0.00%  libgit2_clar  libgit2_clar  [.] deflateReset
           0.01%     0.00%  libgit2_clar  libgit2_clar  [.] deflateEnd
           0.01%     0.01%  libgit2_clar  libgit2_clar  [.] inflateReset2
           0.01%     0.00%  libgit2_clar  libgit2_clar  [.] inflateReset (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] adler32
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateResetKeep (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] deflateResetKeep
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateStateCheck (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateStateCheck (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] inflateStateCheck (inlined)
           0.00%     0.00%  libgit2_clar  libgit2_clar  [.] deflateStateCheck (inlined)
      ```
      lhchavez committed
  14. 21 Nov, 2020 1 commit
  15. 12 Oct, 2020 1 commit
  16. 12 Jul, 2020 1 commit
    • cmake: specify project version · 19eb1e4b
      We currently do not set up a project version within CMake, meaning that
      it can't be use by other projects including libgit2 as a sub-project and
      also not by other tools like IDEs.
      
      This commit changes this to always set up a project version, but instead
      of extracting it from the "version.h" header we now set it up directly.
      This is mostly to avoid mis-use of the previous `LIBGIT2_VERSION`
      variables, as we should now always use the `libgit2_VERSION` ones that
      are set up by CMake if one provides the "VERSION" keyword to the
      `project()` call. While this is one more moving target we need to adjust
      on releases, this commit also adjusts our release script to verify that
      the project version was incremented as expected.
      Patrick Steinhardt committed
  17. 01 Jun, 2020 5 commits
    • cmake: always disable deprecation-sync warnings · 511fb9e6
      We currently disable deprecation synchronization warnings in case we're
      building with Clang. We check for Clang by doing a string comparison on
      the compiler identification, but this seems to have been broken by an
      update in macOS' image as the compiler ID has changed to "AppleClang".
      Let's just unconditionally disable this warning on Unix platforms. We
      never add the deprecated attribute anyway, so the warning doesn't help
      us at all.
      Patrick Steinhardt committed
    • cmake: remove policies · 3956679c
      The `CMAKE_MINIUM_REQUIRE()` function not only sets up the minimum
      required CMake version of a project, but it will also at the same time
      set the CMake policy version. In effect this means that all policies
      that have been introduced before the minimum CMake version will be
      enabled automatically.
      
      When updating our minimum required version ebabb88f (cmake: update
      minimum CMake version to v3.5.1, 2019-10-10), we didn't remove any of
      the policies we've been manually enabling. The newest CMake policy we've
      been enabling is CMP0054, which was introduced back in CMake v3.1. As a
      result, we can now just remove all manual calls to `CMAKE_POLICY()`.
      Patrick Steinhardt committed
    • cmake: remove option to add profiling flags · 2e7d4579
      We currently have an option that adds options for profiling to both our
      CFLAGS and LDFLAGS. Having such flags behind various build options is
      not really sensible at all, since users should instead set up those
      flags via environment variables supported by CMake itself.
      
      Let's remove this option.
      Patrick Steinhardt committed
    • cmake: remove support for creating tags · 2551b1b0
      We currently have support for generating tags via ctags as part of our
      build system. We aren't really in the place of supporting any tooling
      that exists apart from the actual build environment, as doing so adds
      additional complexity and maintenance burden to our build instructions.
      This is in fact nicely demonstrated by this particular option, as it
      hasn't been working anymore since commit e5c9723d (cmake: move library
      build instructions into subdirectory, 2017-06-30).
      
      As a result, this commit removes support for building CTags
      Patrick Steinhardt committed
    • cmake: move modules into the "cmake/" top level dir · bc02bcd9
      Our custom CMake module currently live in "cmake/Modules". As the
      "cmake/" directory doesn't contain anything except the "Modules"
      directory, it doesn't really make sense to have the additional
      intermediate directory. So let's instead move the modules one level up
      into the "cmake/" top level directory.
      Patrick Steinhardt committed
  18. 25 Apr, 2020 1 commit
  19. 14 Mar, 2020 1 commit
    • cmake: use install directories provided via GNUInstallDirs · 87fc539f
      We currently hand-code logic to configure where to install our artifacts
      via the `LIB_INSTALL_DIR`, `INCLUDE_INSTALL_DIR` and `BIN_INSTALL_DIR`
      variables. This is reinventing the wheel, as CMake already provide a way
      to do that via `CMAKE_INSTALL_<DIR>` paths, e.g. `CMAKE_INSTALL_LIB`.
      This requires users of libgit2 to know about the discrepancy and will
      require special hacks for any build systems that handle these variables
      in an automated way. One such example is Gentoo Linux, which sets up
      these paths in both the cmake and cmake-utils eclass.
      
      So let's stop doing that: the GNUInstallDirs module handles it in a
      better way for us, especially so as the actual values are dependent on
      CMAKE_INSTALL_PREFIX. This commit removes our own set of variables and
      instead refers users to use the standard ones.
      
      As a second benefit, this commit also fixes our pkgconfig generation to
      use the GNUInstallDirs module. We had a bug there where we ignored the
      CMAKE_INSTALL_PREFIX when configuring the libdir and includedir keys, so
      if libdir was set to "lib64", then libdir would be an invalid path. With
      GNUInstallDirs, we can now use `CMAKE_INSTALL_FULL_LIBDIR`, which
      handles the prefix for us.
      Patrick Steinhardt committed
  20. 19 Feb, 2020 1 commit
  21. 11 Feb, 2020 1 commit
    • cmake: consolidate Valgrind option · 877054f3
      OpenSSL doesn't initialize bytes on purpose in order to generate
      additional entropy. Valgrind isn't too happy about that though, causing
      it to generate warninings about various issues regarding use of
      uninitialized bytes.
      
      We traditionally had some infrastructure to silence these errors in our
      OpenSSL stream implementation, where we invoke the Valgrind macro
      `VALGRIND_MAKE_MEMDEFINED` in various callbacks that we provide to
      OpenSSL. Naturally, we only include these instructions if a preprocessor
      define "VALGRIND" is set, and that in turn is only set if passing
      "-DVALGRIND" to CMake. We do that in our usual Azure pipelines, but we
      in fact forgot to do this in our nightly build. As a result, we get a
      slew of warnings for these nightly builds, but not for our normal
      builds.
      
      To fix this, we could just add "-DVALGRIND" to our nightly builds. But
      starting with commit d827b11b (tests: execute leak checker via CTest
      directly, 2019-06-28), we do have a secondary variable that directs
      whether we want to use memory sanitizers for our builds. As such, every
      user wishing to use Valgrind for our tests needs to pass both options
      "VALGRIND" and "USE_LEAK_CHECKER", which is cumbersome and error prone,
      as can be seen by our own builds.
      
      Instead, let's consolidate this into a single option, removing the old
      "-DVALGRIND" one. Instead, let's just add the preprocessor directive if
      USE_LEAK_CHECKER equals "valgrind" and remove "-DVALGRIND" from our own
      pipelines.
      Patrick Steinhardt committed
  22. 27 Nov, 2019 1 commit
    • trace: enable tracing by default · 625a3a49
      Tracing is meant to be extremely low-impact when not enabled.  We
      currently ship no tracing calls in libgit2, but if / when we do, the
      tracing infrastructure is created to skip tracing as quickly as
      possible.  It should compile to a simple test when tracing is off.
      
      Thus, there's on reason to not enable it by default.
      Edward Thomson committed
  23. 10 Oct, 2019 1 commit
    • cmake: update minimum CMake version to v3.5.1 · ebabb88f
      Back in commit cf9f3452 (cmake: bump minimum version to 2.8.11,
      2017-09-06), we have bumped the minimum CMake version to require at
      least v2.8.11. The main hold-backs back then were distributions like
      RHEL/CentOS as well as Ubuntu Trusty, which caused us to not target a
      more modern version. Nowadays, Ubuntu Trusty has been EOL'd and CentOS 6
      has CMake v3.6.1 available via the EPEL6 repository, and thus it seems
      fair to upgrade to a more recent version.
      
      Going through repology [1], one can see that all supported mainstream
      distributions do in fact have CMake 3 available. Going through the list,
      the minimum version that is supported by all mainstream distros is in
      fact v3.5.1:
      
      	- CentOS 6 via EPEL6: 3.6.1
      	- Debian Oldstable: 3.7.2
      	- Fedora 26: 3.8.2
      	- OpenMandriva 3.x: 3.5.1
      	- Slackware 14.2: 3.5.2
      	- Ubuntu 16.04: 3.5.1
      
      Consequentally, let's upgrade CMake to the minimum version of 3.5.1 and
      remove all the version CMake checks that aren't required anymore.
      
      [1]: https://repology.org/project/cmake/versions
      Patrick Steinhardt committed
  24. 17 Aug, 2019 1 commit
  25. 20 Jul, 2019 1 commit
    • tests: execute leak checker via CTest directly · d827b11b
      Right now, we have an awful hack in our test CI setup that extracts the
      test command from CTest's output and then prepends the leak checker.
      This is dependent on non-machine-parseable output from CMake and also
      breaks on various ocassions, like for example when we have spaces in the
      current path or when the path contains backslashes. Both conditions may
      easily be triggered on Win32 systems, and in fact they do break our
      Azure Pipelines builds.
      
      Remove the awful hack in favour of a new CMake build option
      "USE_LEAK_CHECKER". If specifying e.g. "-DUSE_LEAK_CHECKER=valgrind",
      then we will set up all tests to be run under valgrind. Like this, we
      can again simply execute ctest without needing to rely on evil sourcery.
      Patrick Steinhardt committed
  26. 24 Jun, 2019 2 commits
    • clang: disable documentation-deprecated-sync · e61b92e0
      Add the `-Wno-documentation-deprecated-sync` switch when compiling with
      clang, since our documentation adds `deprecated` markers, but we do not
      add the deprecation attribute in the code itself.  (ie, the code is out
      of sync with the docs).
      
      In fact, we do not _want_ to mark these items as deprecated in the code,
      at least not yet, as we are not quite ready to bother our end-users with
      this since they're not going away.
      Edward Thomson committed
    • mingw: disable format specification warnings · 54a60ced
      MinGW uses gcc, which expects POSIX formatting for printf, but uses the
      Windows C library, which uses its own format specifiers.  Therefore, it
      gets confused about format specifiers.  Disable warnings for format
      specifiers.
      Edward Thomson committed