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 and improve building with clang-cl #251

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 3 additions & 3 deletions include/graphene-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ typedef int bool;
# include <stdbool.h>
#endif

#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
#if defined (__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define _GRAPHENE_DEPRECATED __attribute__((__deprecated__))
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
#define _GRAPHENE_DEPRECATED __declspec(deprecated)
#else
#define _GRAPHENE_DEPRECATED
#endif

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
#define _GRAPHENE_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
#define _GRAPHENE_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
#else
#define _GRAPHENE_DEPRECATED_FOR(f) _GRAPHENE_DEPRECATED
#endif

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
#define _GRAPHENE_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min)))
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
#define _GRAPHENE_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min))
Expand Down
12 changes: 6 additions & 6 deletions include/graphene-simd4f.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ typedef union {
} graphene_simd4f_union_t;

/* On GCC, we use __extension__ macros to avoid a static inline */
# if defined(__GNUC__)
#if defined (__GNUC__) || defined (__clang__)

/* Use GCC statement __extension__ to inline all these functions */

Expand Down Expand Up @@ -773,11 +773,11 @@ _simd4f_neg (const graphene_simd4f_t s)

#else /* SSE intrinsics-not GCC or Visual Studio */

# error "Need GCC-compatible or Visual Studio compiler for SSE extensions."
# error "Need GCC/clang-compatible or Visual Studio compiler for SSE extensions."

/* Use static inline to inline all these functions */

# endif /* !__GNUC__ && !_MSC_VER */
# endif /* !__GNUC__ && !__clang__ && !_MSC_VER */

#elif !defined(__GI_SCANNER__) && defined(GRAPHENE_USE_INTRINSICS)

Expand Down Expand Up @@ -1089,7 +1089,7 @@ typedef union {
/* NEON has optimised 2-lanes vectors we can use */
typedef float32x2_t graphene_simd2f_t;

#ifdef __GNUC__
#if defined (__GNUC__) || defined (__clang__)
# define graphene_simd4f_init(x,y,z,w) \
(__extension__ ({ \
const float32_t __v[4] = { (x), (y), (z), (w) }; \
Expand Down Expand Up @@ -1719,11 +1719,11 @@ _simd4f_neg (const graphene_simd4f_t s)

#else /* ARM NEON intrinsics-not GCC or Visual Studio */

# error "Need GCC-compatible or Visual Studio compiler for ARM NEON extensions."
# error "Need GCC/clang-compatible or Visual Studio compiler for ARM NEON extensions."

/* Use static inline to inline all these functions */

# endif /* !__GNUC__ && !_MSC_VER */
# endif /* !__GNUC__ && !__clang__ && !_MSC_VER */

/* macros that are not compiler-dependent */
# define graphene_simd4f_get_x(s) graphene_simd4f_get (s, 0)
Expand Down
4 changes: 2 additions & 2 deletions include/graphene-simd4x4f.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void graphene_simd4x4f_transpose_in_place (graphene_simd4x4f_t *s);

#if defined(GRAPHENE_USE_SSE)

#ifdef __GNUC__
#if defined (__GNUC__) || defined (__clang__)
#define graphene_simd4x4f_transpose_in_place(s) \
(__extension__ ({ \
_MM_TRANSPOSE4_PS ((s)->x, (s)->y, (s)->z, (s)->w); \
Expand All @@ -173,7 +173,7 @@ void graphene_simd4x4f_transpose_in_place (graphene_simd4x4f_t *s);

#elif defined(GRAPHENE_USE_ARM_NEON)

# ifdef __GNUC__
#if defined (__GNUC__) || defined (__clang__)

#define graphene_simd4x4f_transpose_in_place(s) \
(__extension__ ({ \
Expand Down
18 changes: 14 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ else
'-Wunused',
'-Wmissing-noreturn',
'-Wmissing-format-attribute',
'-Wlogical-op',
'-Wcast-align',
'-Wno-unused-local-typedefs',
'-Werror=float-conversion',
Expand All @@ -113,6 +112,13 @@ else
'-Werror=write-strings',
'-Werror=undef',
]
if cc.get_id() == 'clang-cl'
# We don't want the CRT deprecation warnings from the Visual Studio headers
test_cflags += ['-D_CRT_SECURE_NO_WARNINGS', '-D_CRT_NONSTDC_NO_WARNINGS']
else
# This returns a false positive on clang-cl
test_cflags += '-Wlogical-op'
endif
endif

common_cflags = cc.get_supported_arguments(test_cflags)
Expand Down Expand Up @@ -203,7 +209,7 @@ if get_option('default_library') != 'static'
if host_system == 'windows'
conf.set('DLL_EXPORT', true)
conf.set('_GRAPHENE_PUBLIC', '__declspec(dllexport) extern')
if cc.get_id() != 'msvc'
if cc.get_argument_syntax() != 'msvc'
extra_args += ['-fvisibility=hidden']
endif
else
Expand Down Expand Up @@ -312,10 +318,14 @@ int main () {
c = _mm_xor_si128 (a, b);
return 0;
}'''
test_sse2_cflags = []
if cc.get_id() != 'msvc'
test_sse2_cflags = ['-mfpmath=sse', '-msse', '-msse2']
else
test_sse2_cflags = []
if cc.get_id() == 'clang-cl'
# clang-cl uses the Visual Studio headers, so we always get SSE 4.1, and it is required
test_sse2_cflags += ['-msse4.1']
endif
test_sse2_cflags = cc.get_supported_arguments(test_sse2_cflags)
endif

if cc.compiles(sse_prog, args: test_sse2_cflags, name: 'SSE intrinsics')
Expand Down