This is an archive of the discontinued LLVM Phabricator instance.

Add predefined macro __gnu_linux__ for proper aux-triple
ClosedPublic

Authored by yaxunl on Aug 29 2018, 10:06 AM.

Details

Summary

Clang predefine macro __linx__ for aux-triple with Linux OS
but does not predefine macro __gnu_linux__. This causes
some compilation error for certain applications, e.g. Eigen.

This patch fixes that.

Diff Detail

Repository
rC Clang

Event Timeline

yaxunl created this revision.Aug 29 2018, 10:06 AM
tra added inline comments.Aug 29 2018, 10:51 AM
lib/Frontend/InitPreprocessor.cpp
1126

AFAICT, we always define __gnu_linix__ on Linux:
https://github.com/llvm-mirror/clang/blob/master/lib/Basic/Targets/OSTargets.h#L306

I think it should be the case here, too.

yaxunl updated this revision to Diff 163145.Aug 29 2018, 11:11 AM

Revised by Artem's comments.

tra accepted this revision.Aug 29 2018, 11:40 AM

While we're here, perhaps Builder.defineMacro("__linux__") should be changed to DefineStd("linux") which defines linux/__linux/__linux__?

This revision is now accepted and ready to land.Aug 29 2018, 11:40 AM
In D51441#1218010, @tra wrote:

While we're here, perhaps Builder.defineMacro("__linux__") should be changed to DefineStd("linux") which defines linux/__linux/__linux__?

Will do when committing. Thanks.

In D51441#1218010, @tra wrote:

While we're here, perhaps Builder.defineMacro("__linux__") should be changed to DefineStd("linux") which defines linux/__linux/__linux__?

Will do when committing. Thanks.

Sorry DefineStd is a function not available in InitPreprocessor.cpp. To reuse that function refactoring is required, which is out of scope for this patch.

This revision was automatically updated to reflect the committed changes.
tra added a comment.Aug 30 2018, 1:55 PM

Tests reverted in rL341118.