[PATCH] D41081: Fix clang Lexer Windows line-ending bug

Benoit Belley via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 11 12:24:38 PST 2017

belleyb added inline comments.

Comment at: test/lit.cfg.py:52-57
+if platform.system() in ['Windows']:
+    config.substitutions.append(('dos2unix', 'sed -b "s/\r$//"'))
+    config.substitutions.append(('unix2dos', 'sed -b "s/\r*$/\r/"'))
+    config.substitutions.append(('dos2unix', "sed $'s/\r$//'"))
+    config.substitutions.append(('unix2dos', "sed $'s/\r*$/\r/'"))
caoz wrote:
> zturner wrote:
> > Since the user has `sed` already, why wouldn't they have the actual tool `dos2unix` and `unix2dos`?
> Thanks Zachary. dos2unix and unix2dos aren't installed by default on Linux/Mac. However, if the user can be assumed to have them, I can remove these substitutions.
@zturner According to https://llvm.org/docs/GettingStarted.html#software, we shouldn't be relying on `dos2unix` nor `unix2dos` to be present on a build machine. 

Note that the `$'string'` syntax (ANSI-C quotes) is a `bash` extension. According to the page mentioned above, the LLVM builds should only be relying on having a Bourne shell (`sh`). But, are there still any *nix system out there where `/bin/sh` isn't a link for `\bin\bash` ? I.e. Is relying on `bash+sed` fine here ?

A fully portable solution would be to write python scripts for `dos2unix.py` and `unix2dos.py`. That way, one would not be relying on build tools that LLVM isn't already using.

Any advice on how to proceed ?


More information about the cfe-commits mailing list