Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detection of include dirs with gnu compiler and non US locale #2564

Merged

Conversation

jeandet
Copy link
Member

@jeandet jeandet commented Nov 1, 2017

Auto detection was based on parsing gcc's output so we have to
ensure that it is always 'C'.

@@ -923,11 +923,14 @@ def get_largefile_args(compiler):
def gnulike_default_include_dirs(compiler, lang):
if lang == 'cpp':
lang = 'c++'
env = os.environ.copy()
env["LC_ALL"]='C'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

missing whitespace around operator

Auto detection was based on parsing gcc's output so we have to
ensure that it is always 'C'.

Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
@jeandet jeandet force-pushed the fix_boost_detection_with_wrong_locale branch from 721dcec to f15a57f Compare November 1, 2017 14:09
p = subprocess.Popen(
compiler + ['-x{}'.format(lang), '-E', '-v', '-'],
stdin=subprocess.DEVNULL,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE
stdout=subprocess.PIPE,
env=env
)
stderr = p.stderr.read().decode('utf-8')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'C' and 'utf-8' is inconsistent, no? And C.utf8 is not necessarily widespread. Would setting LC_MESSAGES work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the compiler complain though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are paths that cannot be represented with ASCII, then maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuLogic
I'm not a locale/encoding expert.
I would say that setting LC_MESSAGES might be enough while setting LC_ALL isn't wrong.
Since UTF-8 can encode any char and is ASCII compatible I don't see anything better, do you have failing test cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is not on the Python side, but on the compiler side as 'C' implies ASCII. Now, I don't have any non-ASCII paths, so I don't really have a test case or any idea if the compiler would even output this correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a test on my laptop with this folder name 'test_£_♣_が' it works.
I'm kind of stuck. My PR mainly ensures that user local doesn't changes gcc output.
I really don't know what should I do about UTF-8.
For now, any user with a non english linux box may suffer this issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should set an english utf-8 locale?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be considered when a real world problem with C arrives. As it is now, this PR improves the situation for anyone with a non english locale A LOT.

@NickeZ
Copy link
Contributor

NickeZ commented Nov 2, 2017

I think the function should print a warning if no directories are found. That will make bug reports easier in the future.

@@ -946,6 +950,8 @@ def gnulike_default_include_dirs(compiler, lang):
break
else:
paths.append(line[1:])
if 0==len(paths):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Flake8]

missing whitespace around operator

@jeandet jeandet force-pushed the fix_boost_detection_with_wrong_locale branch from c2d24a3 to 10a6d50 Compare November 2, 2017 11:30
@@ -946,6 +950,8 @@ def gnulike_default_include_dirs(compiler, lang):
break
else:
paths.append(line[1:])
if 0 == len(paths):
Copy link
Contributor

@NickeZ NickeZ Nov 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isn't very pythonic to write your test in reverse order "yoda condition" because you are not allowed to assign in an if statement anyway. So there is no risk of writing if a = 0: instead of if a == 0:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right you are :)

Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
@jeandet jeandet force-pushed the fix_boost_detection_with_wrong_locale branch from 10a6d50 to dfab587 Compare November 2, 2017 18:28
@jpakkane jpakkane added this to the 0.43.1 milestone Nov 7, 2017
@jpakkane
Copy link
Member

jpakkane commented Nov 7, 2017

I tagged this for 0.43.1 but @nirbheek makes the final call on that.

@jpakkane jpakkane merged commit 9426033 into mesonbuild:master Nov 7, 2017
jon-turney pushed a commit to jon-turney/meson that referenced this pull request Dec 10, 2017
…ith_wrong_locale

Fix detection of include dirs with gnu compiler and non US locale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants