[cfe-dev] Line endings, tests and python scripts

Richard via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 10 10:13:20 PST 2022


Hi Team,

Currently the "getting started" documentation recommends that Windows
users check out the repository from github with unix line endings in
order that tests don't spuriously fail.  As a Windows developer, this
doesn't cause me any problems.

See <https://llvm.org/docs/GettingStarted.html>, "Getting the Source
Code and Building LLVM": "Or, on windows, git clone --config
core.autocrlf=false https://github.com/llvm/llvm-project.git"

See <https://clang.llvm.org/get_started.html>, "Using Visual Studio":
"If you're using git on Windows, make sure your core.autocrlf setting
is false."

However, python likes to always write out text files with native line
endings by default.  This does cause me problems :).  In particular,
there are some scripts like clang-tools-extra/clang-tidy/add_new_check.py
that modify files.  When you run these scripts, they cause the entire
contents of the file to be marked as changed because it flips all the
line endings from LF to CRLF.  I worked around this in my local tree
to avoid the spurious diffs when I run add_new_check.py and I opened a
bug on it <https://github.com/llvm/llvm-project/issues/52968>.

However, it occurs to me that this is worth some wider discussion than
just comments on that particular bug as I was reviewing
<https://reviews.llvm.org/D97625> "fix check-clang-tools tests that
fail due to Windows CRLF ine endings" which is essentially another
side-effect of the same issue.

Should scripts and tests be written to assume LF line endings
everywhere since this is the guidance on the "getting started" pages?

Thanks,

-- Richard

-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
             The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>


More information about the cfe-dev mailing list