Skip to content

bpo-33351: (WIP) Patches to build on clang-cl #7680

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Include/pytime.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ functions and constants
extern "C" {
#endif

#if defined(_MSC_VER)
/* Forward declare struct timeval so that clang-cl doesn't complain about it
being a local declaration later on in _PyTime_AsTimeval.*/
struct timeval;
#endif /* _MSC_VER */

/* _PyTime_t: Python timestamp with subsecond precision. It can be used to
store a duration, and so indirectly a date (related to another date, like
UNIX epoch). */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Port CPython to build with clang-cl on Windows.

Patch by Ethan Smith
15 changes: 11 additions & 4 deletions Modules/_tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ static PyThread_type_lock tables_lock;

#define DEFAULT_DOMAIN 0

/* Pack the frame_t structure to reduce the memory footprint. */
/* Pack the pointer_t structure to reduce the memory footprint. */
#if defined(_MSC_VER)
#pragma pack(push, 4)
#endif
typedef struct
#ifdef __GNUC__
__attribute__((packed))
Expand All @@ -76,14 +79,18 @@ __attribute__((packed))
uintptr_t ptr;
unsigned int domain;
} pointer_t;
#ifdef _MSC_VER
#pragma pack(pop)
#endif

/* Pack the frame_t structure to reduce the memory footprint on 64-bit
architectures: 12 bytes instead of 16. */
architectures: 12 bytes instead of 16. */
#if defined(_MSC_VER)
#pragma pack(push, 4)
#endif
typedef struct
#ifdef __GNUC__
__attribute__((packed))
#elif defined(_MSC_VER)
#pragma pack(push, 4)
#endif
{
/* filename cannot be NULL: "<unknown>" is used if the Python frame
Expand Down
14 changes: 6 additions & 8 deletions PC/pyconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,9 @@ WIN32 is still required for the locale module.
/* e.g., this produces, after compile-time string catenation,
* ("[MSC v.1200 32 bit (Intel)]")
*
* _Py_STRINGIZE(_MSC_VER) expands to
* _Py_STRINGIZE1((_MSC_VER)) expands to
* _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting
* it's scanned again for macros and so further expands to (under MSVC 6)
* _Py_STRINGIZE2(1200) which then expands to
* "1200"
* The double-stringize hack, a method to get the string version of _MSC_VER
*/
#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X))
#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
#define _Py_STRINGIZE(X) _Py_STRINGIZE2(X)
#define _Py_STRINGIZE2(X) #X

/* MSVC defines _WINxx to differentiate the windows platform types
Expand All @@ -122,6 +116,8 @@ WIN32 is still required for the locale module.
#if defined(_M_X64) || defined(_M_AMD64)
#if defined(__INTEL_COMPILER)
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
#elif defined(__clang__)
#define COMPILER ("[clang v." _Py_STRINGIZE(__clang_version__) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
#else
#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
#endif /* __INTEL_COMPILER */
Expand Down Expand Up @@ -172,6 +168,8 @@ typedef _W64 int ssize_t;
#if defined(_M_IX86)
#if defined(__INTEL_COMPILER)
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
#elif defined(__clang__)
#define COMPILER ("[clang v." _Py_STRINGIZE(__clang_version__) "32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
#else
#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
#endif /* __INTEL_COMPILER */
Expand Down