LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 20896 - Don't define __x86_64__ in microsoft mode?
Summary: Don't define __x86_64__ in microsoft mode?
Status: RESOLVED WONTFIX
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-10 11:47 PDT by Nico Weber
Modified: 2014-09-10 12:51 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Weber 2014-09-10 11:47:59 PDT
v8 uses this technique to check for x32:

#if defined(__x86_64__) && !defined(__LP64__)
...
#endif

With cl.exe, this works as cl.exe doesn't define __x86_64__. With clang-cl, this fails since clang-cl does define __x86_64__ but doesn't define __LP64__ (because Windows is LLP64).

clang-cl probably shouldn't define __x86_64__? It already defines the cl-equivalent _M_X64.

https://codereview.chromium.org/18014003/diff/161001/src/base/build_config.h
Comment 1 Nico Weber 2014-09-10 11:48:18 PDT
Opinions?
Comment 2 Nico Weber 2014-09-10 12:33:17 PDT
After talking to Hans, it seems better to change v8 to check __SIZEOF_POINTER__ instead. That works with gcc and clang, and is less brittle than what they currently do.
Comment 3 Reid Kleckner 2014-09-10 12:41:08 PDT
Sounds good, here's the comment I wrote before you closed it. :)

----

This came up in discussion for r212753:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140707/109607.html
http://reviews.llvm.org/D4419

Basically, I think things will be even *more* confusing if we stop defining the Unix / GCC / Clang style target macros. We can change Clang's *mmintrin.h headers to look for MSVC-style macros, but I expect there is other code out there that has similar checks. I'm open to being wrong, though.

Win64 is clearly a non-LP64 x86_64 target, so I don't think that is the correct way to test for x32. According to the x32 glibc wiki page, they should test for __ILP32__:
https://sourceware.org/glibc/wiki/x32
Comment 4 Nico Weber 2014-09-10 12:51:11 PDT
(v8 cl: https://codereview.chromium.org/560903002/)