Skip to content

Initial clang-format target invocation causes many files to be rebuilt #8934

Closed

Description

@bneradt

The initial invocation of clang-format causes make to rebuild many files, despite clang-format not reformatting any files. Future invocations do not cause this, however.

To reproduce:

docker pull ci.trafficserver.apache.org/ats/rockylinux:8
docker run -it  ci.trafficserver.apache.org/ats/rockylinux:8 /bin/bash

# From inside the docker container.
cd /var/tmp
git clone https://github.com/apache/trafficserver.git
cd trafficserver
autoreconf -fi
./configure
make -j8

# Wait for the build to complete.

# Run make again. Nothing should need to be rebuilt:
make -j8

make clang-format

# Verify no files got modified by clang-format.
git status

make -j8
# Many files are rebuilt. This is not expected.

# Re-run clang-format again, even removing the local repo installation.
rm -rf .git/fmt
make clang-format

make -j8
# No files are rebuilt.

It would be good to figure out why the initial invocation of clang-format causes many files to be rebuilt and to investigate whether this can be avoided. Across the many developers who build Traffic Server this wastes a lot of time.

Activity

  1. added
    Build
    on Jun 30, 2022
  2. bneradt commented on Jun 30, 2022

    @bneradt
    ContributorAuthor

    @bryancall thought of using -mmin from find to detect what files are changing:

    # Clone, autoreconf, make.
    # Wait more than 5 minutes.
    
    # Now, find all the files modified in the last 5 minutes in the repo:
    find . -mmin -5
    # Should show nothing.
    
    # Now run the clang-format target, followed by the above find command:
    make -j5 clang-format && echo -------------------- && find . -mmin -5
    # ...
    ./plugins/certifier/certifier.cc
    make[1]: Leaving directory '/home/bneradt/src/ts_asf_master_fix_clang_format_make_target'
    --------------------
    ./.git
    ./.git/fmt
    ./.git/fmt/20200514
    ./.git/fmt/20200514/clang-format-20200514.tar.bz2
    ./.git/fmt/20200514/sha1
    ./include
    ./include/ink_autoconf.h.in
    ./include/ink_autoconf.h
    

    The .git/fmt directory changes are simply the changes to install clang-format. That's not interesting. But the fact that clang-format is modifying ink_autoconf.h.in and ink_autoconf.h is interesting. I'm not sure why that file is being modified despite making no changes.

  3. self-assigned this
    on Jun 30, 2022
  4. bneradt commented on Jun 30, 2022

    @bneradt
    ContributorAuthor

    These are autoconf generated files, thus they don't show up in my git diff command. We should simply skip running clang-format on these files. I'll create a PR.

  5. added 2 commits that reference this issue on Jun 30, 2022
    2b377ac
    abf87e8
  6. added a commit that references this issue on Jun 30, 2022
    c54fbc9
  7. added a commit that references this issue on Jul 6, 2022
    6c01b6a
  8. added a commit that references this issue on Feb 21, 2023
    b7f1e77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Build

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions