[PATCH] clang on ppc doesn't define __linux__

Bug #922452 reported by Jeremy Sequoia
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
clang (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

clang miscompiles some code because it doesn't declare the __linux__ macro:

$ echo "" | /usr/bin/clang -E -dM - | grep linux

The fix is here:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20111010/047625.html

~/src/llvm/tools/clang $ svn diff -r141771:141772
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp (revision 141771)
+++ lib/Basic/Targets.cpp (revision 141772)
@@ -3582,6 +3582,8 @@
     if (Triple.isOSDarwin())
       return new DarwinPPC32TargetInfo(T);
     switch (os) {
+ case llvm::Triple::Linux:
+ return new LinuxTargetInfo<PPC32TargetInfo>(T);
     case llvm::Triple::FreeBSD:
       return new FreeBSDTargetInfo<PPC32TargetInfo>(T);
     case llvm::Triple::NetBSD:
@@ -3596,6 +3598,8 @@
     if (Triple.isOSDarwin())
       return new DarwinPPC64TargetInfo(T);
     switch (os) {
+ case llvm::Triple::Linux:
+ return new LinuxTargetInfo<PPC64TargetInfo>(T);
     case llvm::Triple::Lv2:
       return new PS3PPUTargetInfo<PPC64TargetInfo>(T);
     case llvm::Triple::FreeBSD:
@@ -3616,6 +3620,8 @@

   case llvm::Triple::sparc:
     switch (os) {
+ case llvm::Triple::Linux:
+ return new LinuxTargetInfo<SparcV8TargetInfo>(T);
     case llvm::Triple::AuroraUX:
       return new AuroraUXSparcV8TargetInfo(T);
     case llvm::Triple::Solaris:

Revision history for this message
Jeremy Sequoia (jeremyhu) wrote :

You should also bring in the changes from here:
http://llvm.org/bugs/show_bug.cgi?id=11867

Revision history for this message
Jeremy Sequoia (jeremyhu) wrote :
Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

clang version 3.0
$ echo "" | /usr/bin/clang -E -dM - | grep linux
#define __gnu_linux__ 1
#define __linux 1
#define __linux__ 1
#define linux 1

Changed in clang (Ubuntu):
status: New → Fix Released
Revision history for this message
Jeremy Sequoia (jeremyhu) wrote :

Also, I've linked you to the two patches you'll need to cherry pick, so this should be trivial to address.

Changed in clang (Ubuntu):
status: Fix Released → Confirmed
Revision history for this message
Anders Kaseorg (andersk) wrote :

Is this fixed by http://bugs.debian.org/652096 ? The patch in bug 903509 also merges that fix from Debian.

Revision history for this message
Jeremy Sequoia (jeremyhu) wrote :

No, I don't believe it does. I merged these changes into clang after that bug's closure date, and the issue is still present in what is currently shipped.

Revision history for this message
Jeremy Sequoia (jeremyhu) wrote :

Also the patch in debian's #652096 has nothing to do with this bug.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.