summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSinan Kaya <41809318+franksinankaya@users.noreply.github.com>2019-02-22 14:11:19 -0500
committerJan Vorlicek <janvorli@microsoft.com>2019-02-22 20:11:19 +0100
commit0495f7377fca88999d335757e9680052cfedc51d (patch)
tree3dc0a76c3ece4783d1884fcdf9e087ff663a7535
parent1376e5fc5fa4b01a175e26be467a416f1c8765fc (diff)
downloadcoreclr-0495f7377fca88999d335757e9680052cfedc51d.tar.gz
coreclr-0495f7377fca88999d335757e9680052cfedc51d.tar.bz2
coreclr-0495f7377fca88999d335757e9680052cfedc51d.zip
More GNUC Fixes (#22687)
* Replace __sync_swap with __atomic_exchange_n __sync_swap() is a clang specific function. * Remove multiline comment * Add paranthesis around sum src/md/hotdata/../inc/streamutil.h:73:34: warning: suggest parentheses around ‘+’ in operand of ‘&’ [-Wparentheses] UINT32 aligned = *totalBytes + 3 & ~3; * Define __int64 * Define windows types for tests * Remove undefined has_builtin defines and define alloca and inline for GNUC * Remove __clang__ where possible * Add implicit casting to help compiler find WCHAR* variant src/binder/assembly.cpp:294:73: error: no matching function for call to ‘SString::SString(SString)’ return (pAsmName == nullptr ? nullptr : pAsmName->GetSimpleName()); ^ In file included from src/inc/sstring.h:1082:0, from src/inc/ex.h:19, from src/inc/stgpool.h:28, from src/inc/../md/inc/metamodel.h:18, from src/inc/../md/inc/metamodelro.h:19, from src/inc/metadata.h:17, from src/binder/../vm/util.hpp:19, from src/binder/../vm/common.h:110, from src/binder/assembly.cpp:14: src/inc/sstring.inl:73:8: note: candidate: SString::SString(void*, COUNT_T) inline SString::SString(void *buffer, COUNT_T size) ^ src/inc/sstring.inl:73:8: note: candidate expects 2 arguments, 1 provided src/inc/sstring.inl:436:8: note: candidate: SString::SString(SString::tagLiteral, const WCHAR*, COUNT_T) inline SString::SString(tagLiteral dummytag, const WCHAR *literal, COUNT_T count) ^ src/inc/sstring.inl:436:8: note: candidate expects 3 arguments, 1 provided src/inc/sstring.inl:418:8: note: candidate: SString::SString(SString::tagLiteral, const WCHAR*) inline SString::SString(tagLiteral dummytag, const WCHAR *literal) ^ src/inc/sstring.inl:418:8: note: candidate expects 2 arguments, 1 provided src/inc/sstring.inl:401:8: note: candidate: SString::SString(SString::tagUTF8Literal, const UTF8*) inline SString::SString(tagUTF8Literal dummytag, const UTF8 *literal) ^ src/inc/sstring.inl:401:8: note: candidate expects 2 arguments, 1 provided src/inc/sstring.inl:382:8: note: candidate: SString::SString(SString::tagLiteral, const CHAR*) inline SString::SString(tagLiteral dummytag, const ASCII *literal) * Reorder DLLEXPORT and STDAPI GNUC wants extern "C" <attribute> format. * Abstract __FUNCSIG__ * Abstract __debugbreak() * Move common compiler options out of clang and add Wno-unused-value * Add paranthesis around || and && src/gc/gc.cpp:9084:38: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] (!chosen_power2) && (i < free_space_count)); * Set Wno-delete-non-virtual-dtor for CXX files only * Don't warn on unterminated endif labels * Suppress unused functions * Use 0x syntax rather than h syntax on GNU asm files * Correct constructor call directly src/ToolBox/superpmi/superpmi-shared/logging.cpp:301:27: required from here src/inc/clr_std/string:58:9: error: cannot call constructor ‘std::basic_string<char>::basic_string’ directly this->basic_string::basic_string(_Ptr, c_len(_Ptr)); * Suppress NULL used in arithmetic warnings
-rw-r--r--configurecompiler.cmake11
-rw-r--r--src/ToolBox/SOS/Strike/CMakeLists.txt7
-rw-r--r--src/ToolBox/SOS/lldbplugin/CMakeLists.txt2
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/standardpch.h8
-rw-r--r--src/binder/assembly.cpp2
-rw-r--r--src/debug/daccess/daccess.cpp3
-rw-r--r--src/debug/daccess/nidump.cpp2
-rw-r--r--src/debug/ee/amd64/dbghelpers.S18
-rw-r--r--src/dlls/mscordbi/mscordbi.cpp3
-rw-r--r--src/dlls/mscoree/mscoree.cpp14
-rw-r--r--src/dlls/mscorpe/CMakeLists.txt2
-rw-r--r--src/gc/env/gcenv.base.h28
-rw-r--r--src/gc/env/gcenv.interlocked.inl6
-rw-r--r--src/gc/gc.cpp4
-rw-r--r--src/gc/gcpriv.h5
-rw-r--r--src/ilasm/CMakeLists.txt2
-rw-r--r--src/inc/CMakeLists.txt5
-rw-r--r--src/inc/clr_std/string3
-rw-r--r--src/jit/compiler.cpp4
-rw-r--r--src/jit/jit.h2
-rw-r--r--src/md/inc/streamutil.h2
-rw-r--r--src/unwinder/arm64/unwinder_arm64.cpp6
-rw-r--r--src/vm/rejit.inl2
-rw-r--r--tests/src/Common/Platform/platformdefines.h7
-rw-r--r--tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp12
-rw-r--r--tests/src/Interop/PInvoke/Array/MarshalArray.h10
-rw-r--r--tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp13
-rw-r--r--tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp8
-rw-r--r--tests/src/JIT/Directed/StructABI/StructABI.c10
-rw-r--r--tests/src/JIT/Directed/arglist/varargnative.c12
-rw-r--r--tests/src/JIT/Directed/pinning/object-pin/mirror.cpp11
-rw-r--r--tests/src/JIT/Methodical/structs/systemvbringup/structinregs.cpp12
-rwxr-xr-xtests/src/JIT/SIMD/Vector3TestNative.cpp8
-rw-r--r--tests/src/JIT/jit64/hfa/main/dll/hfa_native.cpp11
-rw-r--r--tests/src/JIT/jit64/hfa/main/dll/hfa_native.h11
-rw-r--r--tests/src/JIT/jit64/mcc/interop/native.h10
-rw-r--r--tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp2
37 files changed, 211 insertions, 67 deletions
diff --git a/configurecompiler.cmake b/configurecompiler.cmake
index f5eb063453..d9b2a66e63 100644
--- a/configurecompiler.cmake
+++ b/configurecompiler.cmake
@@ -446,6 +446,14 @@ if (CLR_CMAKE_PLATFORM_UNIX)
add_compile_options(-Werror)
endif(CLR_CMAKE_WARNINGS_ARE_ERRORS)
+ # Disabled common warnings
+ add_compile_options(-Wno-unused-variable)
+ add_compile_options(-Wno-unused-value)
+ add_compile_options(-Wno-unused-function)
+
+ #These seem to indicate real issues
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
# after hitting just about 20 errors.
@@ -453,7 +461,6 @@ if (CLR_CMAKE_PLATFORM_UNIX)
# Disabled warnings
add_compile_options(-Wno-unused-private-field)
- add_compile_options(-Wno-unused-variable)
# Explicit constructor calls are not supported by clang (this->ClassName::ClassName())
add_compile_options(-Wno-microsoft)
# This warning is caused by comparing 'this' to NULL
@@ -468,8 +475,6 @@ if (CLR_CMAKE_PLATFORM_UNIX)
add_compile_options(-Wno-unknown-warning-option)
- #These seem to indicate real issues
- add_compile_options(-Wno-invalid-offsetof)
# The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
# to a struct or a class that has virtual members or a base class. In that case, clang
# may not generate the same object layout as MSVC.
diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt
index e1673bcb0e..a4fe91cba3 100644
--- a/src/ToolBox/SOS/Strike/CMakeLists.txt
+++ b/src/ToolBox/SOS/Strike/CMakeLists.txt
@@ -106,7 +106,12 @@ if(WIN32)
)
else(WIN32)
add_definitions(-DPAL_STDCPP_COMPAT=1)
- add_compile_options(-Wno-null-arithmetic)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ add_compile_options(-Wno-null-arithmetic)
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null")
+ add_compile_options(-Wno-pointer-arith)
+ endif()
add_compile_options(-Wno-format)
include_directories(BEFORE xplat)
diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
index 1aeab14780..0e4d40a706 100644
--- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
+++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt
@@ -124,7 +124,7 @@ endif()
message(STATUS "LLDB_H: ${LLDB_H}")
-add_compile_options(-Wno-delete-non-virtual-dtor)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
include_directories(inc)
include_directories("${LLDB_H}")
diff --git a/src/ToolBox/superpmi/superpmi-shared/standardpch.h b/src/ToolBox/superpmi/superpmi-shared/standardpch.h
index 08eb603e50..65a4f321f9 100644
--- a/src/ToolBox/superpmi/superpmi-shared/standardpch.h
+++ b/src/ToolBox/superpmi/superpmi-shared/standardpch.h
@@ -109,3 +109,11 @@
#define DEFAULT_REAL_JIT_NAME_A MAKEDLLNAME_A("clrjit2")
#define DEFAULT_REAL_JIT_NAME_W MAKEDLLNAME_W("clrjit2")
+
+#if !defined(_MSC_VER) && !defined(__llvm__)
+static inline void __debugbreak()
+{
+ DebugBreak();
+}
+#endif
+
diff --git a/src/binder/assembly.cpp b/src/binder/assembly.cpp
index 7f7ab2623e..9649233c69 100644
--- a/src/binder/assembly.cpp
+++ b/src/binder/assembly.cpp
@@ -291,7 +291,7 @@ Exit:
LPCWSTR Assembly::GetSimpleName()
{
AssemblyName *pAsmName = GetAssemblyName();
- return (pAsmName == nullptr ? nullptr : pAsmName->GetSimpleName());
+ return (pAsmName == nullptr ? nullptr : (LPCWSTR)pAsmName->GetSimpleName());
}
HRESULT Assembly::BindAssemblyByName(IAssemblyName * pIAssemblyName, ICLRPrivAssembly ** ppAssembly)
diff --git a/src/debug/daccess/daccess.cpp b/src/debug/daccess/daccess.cpp
index 9b2b3adbab..5ebbe31a54 100644
--- a/src/debug/daccess/daccess.cpp
+++ b/src/debug/daccess/daccess.cpp
@@ -40,10 +40,11 @@ HINSTANCE g_thisModule;
extern VOID STDMETHODCALLTYPE TLS_FreeMasterSlotIndex();
+EXTERN_C
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
-EXTERN_C BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
+BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
{
static bool g_procInitialized = false;
diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp
index e61c61d7a7..37de104563 100644
--- a/src/debug/daccess/nidump.cpp
+++ b/src/debug/daccess/nidump.cpp
@@ -447,7 +447,7 @@ static OptionDependencies g_dependencies[] =
//
// This function gets the Dispenser interface given the CLSID and REFIID.
-DLLEXPORT STDAPI MetaDataGetDispenser(
+STDAPI DLLEXPORT MetaDataGetDispenser(
REFCLSID rclsid, // The class to desired.
REFIID riid, // Interface wanted on class factory.
LPVOID FAR * ppv) // Return interface pointer here.
diff --git a/src/debug/ee/amd64/dbghelpers.S b/src/debug/ee/amd64/dbghelpers.S
index 85ec80c701..864c4dc943 100644
--- a/src/debug/ee/amd64/dbghelpers.S
+++ b/src/debug/ee/amd64/dbghelpers.S
@@ -29,7 +29,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, UnhandledExceptionHandlerUnix
//
// epilogue
//
- add rsp, 20h
+ add rsp, 0x20
TAILJMP_RAX
NESTED_END FuncEvalHijack, _TEXT
@@ -65,14 +65,14 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
// its arguments on the stack. In x64, it gets its arguments in
// registers (set up for us by DacDbiInterfaceImpl::Hijack),
// and this stack space may be reused.
- mov rax, [rsp + 20h]
+ mov rax, [rsp + 0x20]
mov [rsp], rax
- mov rax, [rsp + 28h]
- mov [rsp + 8h], rax
- mov rax, [rsp + 30h]
- mov [rsp + 10h], rax
- mov rax, [rsp + 38h]
- mov [rsp + 18h], rax
+ mov rax, [rsp + 0x28]
+ mov [rsp + 0x8], rax
+ mov rax, [rsp + 0x30]
+ mov [rsp + 0x10], rax
+ mov rax, [rsp + 0x38]
+ mov [rsp + 0x18], rax
// DD Hijack primitive already set the stack. So just make the call now.
call C_FUNC(ExceptionHijackWorker)
@@ -93,7 +93,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
//
// epilogue
//
- add rsp, 20h
+ add rsp, 0x20
TAILJMP_RAX
// Put a label here to tell the debugger where the end of this function is.
diff --git a/src/dlls/mscordbi/mscordbi.cpp b/src/dlls/mscordbi/mscordbi.cpp
index 7173e7343f..a44679b47d 100644
--- a/src/dlls/mscordbi/mscordbi.cpp
+++ b/src/dlls/mscordbi/mscordbi.cpp
@@ -18,10 +18,11 @@ extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
// The main dll entry point for this module. This routine is called by the
// OS when the dll gets loaded. Control is simply deferred to the main code.
//*****************************************************************************
+extern "C"
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
-extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Defer to the main debugging code.
return DbgDllMain(hInstance, dwReason, lpReserved);
diff --git a/src/dlls/mscoree/mscoree.cpp b/src/dlls/mscoree/mscoree.cpp
index 45298c5294..d1c8a7620e 100644
--- a/src/dlls/mscoree/mscoree.cpp
+++ b/src/dlls/mscoree/mscoree.cpp
@@ -62,10 +62,11 @@ extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserv
// we need to capture coreclr's hInstance before the C runtime initializes. This function
// will capture hInstance, let the C runtime initialize and then invoke the "classic"
// DllMain that initializes everything else.
+extern "C"
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
-extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
STATIC_CONTRACT_NOTHROW;
@@ -118,10 +119,11 @@ extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpRe
return result;
}
+extern "C"
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
-extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
STATIC_CONTRACT_NOTHROW;
@@ -226,7 +228,7 @@ HINSTANCE GetModuleInst()
// %%Function: MetaDataGetDispenser
// This function gets the Dispenser interface given the CLSID and REFIID.
// ---------------------------------------------------------------------------
-DLLEXPORT STDAPI MetaDataGetDispenser( // Return HRESULT
+STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT
REFCLSID rclsid, // The class to desired.
REFIID riid, // Interface wanted on class factory.
LPVOID FAR *ppv) // Return interface pointer here.
@@ -256,7 +258,7 @@ ErrExit:
// %%Function: GetMetaDataInternalInterface
// This function gets the IMDInternalImport given the metadata on memory.
// ---------------------------------------------------------------------------
-DLLEXPORT STDAPI GetMetaDataInternalInterface(
+STDAPI DLLEXPORT GetMetaDataInternalInterface(
LPVOID pData, // [IN] in memory metadata section
ULONG cbData, // [IN] size of the metadata section
DWORD flags, // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC
@@ -285,7 +287,7 @@ DLLEXPORT STDAPI GetMetaDataInternalInterface(
// This function gets the internal scopeless interface given the public
// scopeless interface.
// ---------------------------------------------------------------------------
-DLLEXPORT STDAPI GetMetaDataInternalInterfaceFromPublic(
+STDAPI DLLEXPORT GetMetaDataInternalInterfaceFromPublic(
IUnknown *pv, // [IN] Given interface.
REFIID riid, // [IN] desired interface
void **ppv) // [OUT] returned interface
@@ -312,7 +314,7 @@ DLLEXPORT STDAPI GetMetaDataInternalInterfaceFromPublic(
// This function gets the public scopeless interface given the internal
// scopeless interface.
// ---------------------------------------------------------------------------
-DLLEXPORT STDAPI GetMetaDataPublicInterfaceFromInternal(
+STDAPI DLLEXPORT GetMetaDataPublicInterfaceFromInternal(
void *pv, // [IN] Given interface.
REFIID riid, // [IN] desired interface.
void **ppv) // [OUT] returned interface
diff --git a/src/dlls/mscorpe/CMakeLists.txt b/src/dlls/mscorpe/CMakeLists.txt
index fd884b1c46..2e91a02f51 100644
--- a/src/dlls/mscorpe/CMakeLists.txt
+++ b/src/dlls/mscorpe/CMakeLists.txt
@@ -11,7 +11,7 @@ set(MSCORPE_SOURCES
if(WIN32)
else()
- add_compile_options(-Wno-delete-non-virtual-dtor)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
endif(WIN32)
add_library_clr(mscorpe STATIC
diff --git a/src/gc/env/gcenv.base.h b/src/gc/env/gcenv.base.h
index 351f4f300a..e99149eb6f 100644
--- a/src/gc/env/gcenv.base.h
+++ b/src/gc/env/gcenv.base.h
@@ -14,13 +14,17 @@
#define REDHAWK_PALIMPORT extern "C"
#define REDHAWK_PALAPI __stdcall
+#if !defined(_MSC_VER)
+#define _alloca alloca
+#endif //_MSC_VER
+
#ifndef _MSC_VER
#define __stdcall
-#ifdef __clang__
+#ifdef __GNUC__
#define __forceinline __attribute__((always_inline)) inline
-#else // __clang__
+#else // __GNUC__
#define __forceinline inline
-#endif // __clang__
+#endif // __GNUC__
// [LOCALGC TODO] is there a better place for this?
#define NOINLINE __attribute__((noinline))
#else // !_MSC_VER
@@ -178,18 +182,26 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
#endif
#else // _MSC_VER
+#ifdef __llvm__
+#define HAS_IA32_PAUSE __has_builtin(__builtin_ia32_pause)
+#define HAS_IA32_MFENCE __has_builtin(__builtin_ia32_mfence)
+#else
+#define HAS_IA32_PAUSE 0
+#define HAS_IA32_MFENCE 0
+#endif
+
// Only clang defines __has_builtin, so we first test for a GCC define
// before using __has_builtin.
#if defined(__i386__) || defined(__x86_64__)
-#if (__GNUC__ > 4 && __GNUC_MINOR > 7) || __has_builtin(__builtin_ia32_pause)
+#if (__GNUC__ > 4 && __GNUC_MINOR > 7) || HAS_IA32_PAUSE
// clang added this intrinsic in 3.8
// gcc added this intrinsic by 4.7.1
#define YieldProcessor __builtin_ia32_pause
#endif // __has_builtin(__builtin_ia32_pause)
-#if defined(__GNUC__) || __has_builtin(__builtin_ia32_mfence)
+#if defined(__GNUC__) || HAS_IA32_MFENCE
// clang has had this intrinsic since at least 3.0
// gcc has had this intrinsic since forever
#define MemoryBarrier __builtin_ia32_mfence
@@ -455,7 +467,13 @@ typedef DPTR(uint8_t) PTR_uint8_t;
#define DATA_ALIGNMENT sizeof(uintptr_t)
#define RAW_KEYWORD(x) x
+
+#ifdef _MSC_VER
#define DECLSPEC_ALIGN(x) __declspec(align(x))
+#else
+#define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
+#endif
+
#ifndef _ASSERTE
#define _ASSERTE(_expr) ASSERT(_expr)
#endif
diff --git a/src/gc/env/gcenv.interlocked.inl b/src/gc/env/gcenv.interlocked.inl
index 3eaaa3ae59..1df2700d7f 100644
--- a/src/gc/env/gcenv.interlocked.inl
+++ b/src/gc/env/gcenv.interlocked.inl
@@ -70,7 +70,7 @@ __forceinline T Interlocked::Exchange(T volatile *destination, T value)
static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
return _InterlockedExchange((long*)destination, value);
#else
- T result = __sync_swap(destination, value);
+ T result = __atomic_exchange_n(destination, value, __ATOMIC_ACQ_REL);
ArmInterlockedOperationBarrier();
return result;
#endif
@@ -164,7 +164,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, T value)
return (T)(TADDR)_InterlockedExchange((long volatile *)(void* volatile *)destination, (long)(void*)value);
#endif
#else
- T result = (T)(TADDR)__sync_swap((void* volatile *)destination, value);
+ T result = (T)(TADDR)__atomic_exchange_n((void* volatile *)destination, value, __ATOMIC_ACQ_REL);
ArmInterlockedOperationBarrier();
return result;
#endif
@@ -180,7 +180,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, std::null
return (T)(TADDR)_InterlockedExchange((long volatile *)(void* volatile *)destination, (long)(void*)value);
#endif
#else
- T result = (T)(TADDR)__sync_swap((void* volatile *)destination, value);
+ T result = (T)(TADDR)__atomic_exchange_n((void* volatile *)destination, value, __ATOMIC_ACQ_REL);
ArmInterlockedOperationBarrier();
return result;
#endif
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 01f51c275c..d7f8d6dfe5 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -5020,7 +5020,7 @@ extern "C" uint64_t __rdtsc();
{
return (ptrdiff_t)__rdtsc();
}
-#elif defined(__clang__)
+#elif defined(__GNUC__)
static ptrdiff_t get_cycle_count()
{
ptrdiff_t cycles;
@@ -9081,7 +9081,7 @@ retry:
new_address += pad;
}
assert ((chosen_power2 && (i == 0)) ||
- (!chosen_power2) && (i < free_space_count));
+ ((!chosen_power2) && (i < free_space_count)));
}
int new_bucket_power2 = index_of_highest_set_bit (new_free_space_size);
diff --git a/src/gc/gcpriv.h b/src/gc/gcpriv.h
index 18785d5185..8a7dfdf6b8 100644
--- a/src/gc/gcpriv.h
+++ b/src/gc/gcpriv.h
@@ -13,7 +13,12 @@
#pragma optimize( "t", on )
#endif
#endif
+
+#ifdef __GNUC__
+#define inline __attribute__((always_inline)) inline
+#else
#define inline __forceinline
+#endif // __GNUC__
#include "gc.h"
diff --git a/src/ilasm/CMakeLists.txt b/src/ilasm/CMakeLists.txt
index e67267a42a..f6852e63e8 100644
--- a/src/ilasm/CMakeLists.txt
+++ b/src/ilasm/CMakeLists.txt
@@ -51,7 +51,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
# Need generate a right form of asmparse.cpp to avoid the following options.
# Clang also produces a bad-codegen on this prebuilt file with optimization.
# https://github.com/dotnet/coreclr/issues/2305
- add_compile_options(-Wno-delete-non-virtual-dtor)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
add_compile_options(-Wno-deprecated-register)
add_compile_options(-Wno-array-bounds)
add_compile_options(-Wno-unused-label)
diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt
index c109c2f3a7..c54b4f0ec9 100644
--- a/src/inc/CMakeLists.txt
+++ b/src/inc/CMakeLists.txt
@@ -50,7 +50,12 @@ else()
# The prebuilt files contain extra '!_MIDL_USE_GUIDDEF_' after the #endif, but not in the comment.
# In order to not to have to modify these prebuilt files, we disable the extra tokens warning.
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-extra-tokens)
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+add_compile_options(-Wno-endif-labels)
+endif()
+
add_compile_options(-D_MIDL_USE_GUIDDEF_)
foreach(IDL_SOURCE IN LISTS CORGUIDS_IDL_SOURCES)
get_filename_component(IDLNAME ${IDL_SOURCE} NAME_WE)
diff --git a/src/inc/clr_std/string b/src/inc/clr_std/string
index 78a3d1bb60..66f219c8a8 100644
--- a/src/inc/clr_std/string
+++ b/src/inc/clr_std/string
@@ -53,9 +53,8 @@ public:
copy(_Ptr, _Count);
}
- basic_string(const value_type* _Ptr)
+ basic_string(const value_type* _Ptr) : basic_string(_Ptr, c_len(_Ptr))
{
- this->basic_string::basic_string(_Ptr, c_len(_Ptr));
}
void reserve(size_t newcapacity)
diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp
index 691f35b800..cef3083c47 100644
--- a/src/jit/compiler.cpp
+++ b/src/jit/compiler.cpp
@@ -76,7 +76,7 @@ inline bool _our_GetThreadCycles(unsigned __int64* cycleOut)
return true;
}
-#elif defined(__clang__)
+#elif defined(__GNUC__)
inline bool _our_GetThreadCycles(unsigned __int64* cycleOut)
{
@@ -86,7 +86,7 @@ inline bool _our_GetThreadCycles(unsigned __int64* cycleOut)
return true;
}
-#else // neither _MSC_VER nor __clang__
+#else // neither _MSC_VER nor __GNUC__
// The following *might* work - might as well try.
#define _our_GetThreadCycles(cp) GetThreadCycles(cp)
diff --git a/src/jit/jit.h b/src/jit/jit.h
index f5f96b4716..5cdb1fdcb9 100644
--- a/src/jit/jit.h
+++ b/src/jit/jit.h
@@ -503,7 +503,7 @@ typedef ptrdiff_t ssize_t;
#if !defined(_HOST_X86_) && !defined(_HOST_AMD64_)
#define MEASURE_CLRAPI_CALLS 0 // Cycle counters only hooked up on x86/x64.
#endif
-#if !defined(_MSC_VER) && !defined(__clang__)
+#if !defined(_MSC_VER) && !defined(__GNUC__)
#define MEASURE_CLRAPI_CALLS 0 // Only know how to do this with VC and Clang.
#endif
diff --git a/src/md/inc/streamutil.h b/src/md/inc/streamutil.h
index 89c493476f..55ff6353d0 100644
--- a/src/md/inc/streamutil.h
+++ b/src/md/inc/streamutil.h
@@ -70,7 +70,7 @@ HRESULT AlignDWORD( IStream * strm, UINT32 * totalBytes )
{
HRESULT hr = S_OK;
- UINT32 aligned = *totalBytes + 3 & ~3;
+ UINT32 aligned = (*totalBytes + 3) & ~3;
if (aligned > *totalBytes)
{ // The *totalBytes were not aligned to DWORD, we need to add padding
DWORD data = 0;
diff --git a/src/unwinder/arm64/unwinder_arm64.cpp b/src/unwinder/arm64/unwinder_arm64.cpp
index 4c63815ccd..873ddf1f53 100644
--- a/src/unwinder/arm64/unwinder_arm64.cpp
+++ b/src/unwinder/arm64/unwinder_arm64.cpp
@@ -235,7 +235,7 @@ Return Value:
SourceAddress = StartingSp + FIELD_OFFSET(ARM64_KTRAP_FRAME, X);
for (RegIndex = 0; RegIndex < 18; RegIndex++) {
UPDATE_CONTEXT_POINTERS(UnwindParams, RegIndex, SourceAddress);
-#ifdef __clang__
+#ifdef __GNUC__
*(&ContextRecord->X0 + RegIndex) = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
#else
ContextRecord->X[RegIndex] = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
@@ -315,7 +315,7 @@ Return Value:
SourceAddress = StartingSp + FIELD_OFFSET(T_CONTEXT, X0);
for (RegIndex = 0; RegIndex < 29; RegIndex++) {
UPDATE_CONTEXT_POINTERS(UnwindParams, RegIndex, SourceAddress);
-#ifdef __clang__
+#ifdef __GNUC__
*(&ContextRecord->X0 + RegIndex) = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
#else
ContextRecord->X[RegIndex] = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
@@ -501,7 +501,7 @@ Return Value:
for (RegIndex = 0; RegIndex < RegisterCount; RegIndex++) {
UPDATE_CONTEXT_POINTERS(UnwindParams, FirstRegister + RegIndex, CurAddress);
-#ifdef __clang__
+#ifdef __GNUC__
*(&ContextRecord->X0 + FirstRegister + RegIndex) = MEMORY_READ_QWORD(UnwindParams, CurAddress);
#else
ContextRecord->X[FirstRegister + RegIndex] = MEMORY_READ_QWORD(UnwindParams, CurAddress);
diff --git a/src/vm/rejit.inl b/src/vm/rejit.inl
index 96cefc6fd3..d26d9e4f0f 100644
--- a/src/vm/rejit.inl
+++ b/src/vm/rejit.inl
@@ -6,7 +6,7 @@
//
//
-// Inline definitions of various items declared in REJIT.H\
+// Inline definitions of various items declared in REJIT.H
// ===========================================================================
#ifndef _REJIT_INL_
#define _REJIT_INL_
diff --git a/tests/src/Common/Platform/platformdefines.h b/tests/src/Common/Platform/platformdefines.h
index fe37ec1178..0c2008b9c2 100644
--- a/tests/src/Common/Platform/platformdefines.h
+++ b/tests/src/Common/Platform/platformdefines.h
@@ -78,6 +78,13 @@ typedef unsigned int ULONG, *PULONG;
#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc)
#endif // RC_INVOKED
#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)
+
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
#define UInt32x32To64(a, b) ((unsigned __int64)((ULONG)(a)) * (unsigned __int64)((ULONG)(b)))
#define ARRAYSIZE(x) (sizeof(x)/sizeof(*x))
diff --git a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
index 86d726e0e6..b80e4ca330 100644
--- a/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
+++ b/tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
@@ -34,6 +34,12 @@ macro definition
#define EQUALS(__actual, __cActual, __expected) Equals((__actual), (__cActual), (__expected), (int)sizeof(__expected) / sizeof(__expected[0]))
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
/*----------------------------------------------------------------------------
struct definition
----------------------------------------------------------------------------*/
@@ -99,7 +105,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
return TRUE;
else if ( cActual != cExpected )
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
return FALSE;
}
@@ -107,7 +113,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
{
if ( !IsObjectEquals(pActual[i], pExpected[i]) )
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
return FALSE;
}
}
@@ -168,7 +174,7 @@ bool TestStructEquals(TestStruct Actual[], TestStruct Expected[])
IsObjectEquals(Actual[i].l, Expected[i].l) &&
IsObjectEquals(Actual[i].str, Expected[i].str) ))
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
return false;
}
}
diff --git a/tests/src/Interop/PInvoke/Array/MarshalArray.h b/tests/src/Interop/PInvoke/Array/MarshalArray.h
index c3d027e9ec..00db79ee2b 100644
--- a/tests/src/Interop/PInvoke/Array/MarshalArray.h
+++ b/tests/src/Interop/PInvoke/Array/MarshalArray.h
@@ -37,14 +37,20 @@
return false; \
}
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
#define VERIFY_ERROR(__expect, __actual) \
- std::cout << '[' << __FUNCSIG__ << "] EXPECT: " << (__expect) << ", ACTUAL: " << (__actual) << std::endl
+ std::cout << '[' << FUNCTIONNAME << "] EXPECT: " << (__expect) << ", ACTUAL: " << (__actual) << std::endl
#define TRACE(__msg) \
std::cout << __msg << std::endl
#define VERIFY_ERROR_MSG(__msg, __expect, __actual) \
- printf("["##__FUNCSIG__##"] "##__msg, (__expect), (__actual))
+ printf("["##FUNCTIONNAME##"] "##__msg, (__expect), (__actual))
//////////////////////////////////////////////////////////////////////////////
// Verify helper methods
diff --git a/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp b/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp
index a0fcb5a8ec..c24b46567a 100644
--- a/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp
+++ b/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp
@@ -24,6 +24,13 @@ macro definition
#define EQUALS(__actual, __cActual, __expected) Equals((__actual), (__cActual), (__expected), (int)sizeof(__expected) / sizeof(__expected[0]))
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
+
/*----------------------------------------------------------------------------
struct definition
----------------------------------------------------------------------------*/
@@ -91,7 +98,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
return TRUE;
else if ( cActual != cExpected )
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
printf("Array Length: expected: %d, actual: %d\n", cExpected, cActual);
return FALSE;
}
@@ -100,7 +107,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
{
if ( !IsObjectEquals(pActual[i], pExpected[i]) )
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
printf("Array Element Not Equal: index: %d", static_cast<int>(i));
return FALSE;
}
@@ -125,7 +132,7 @@ bool TestStructEquals(TestStruct Actual[], TestStruct Expected[])
IsObjectEquals(Actual[i].l, Expected[i].l) &&
IsObjectEquals(Actual[i].str, Expected[i].str) ))
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
return false;
}
}
diff --git a/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp b/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp
index dc42224c2b..fea447c69b 100644
--- a/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp
+++ b/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp
@@ -5,6 +5,12 @@
#include <xplatform.h>
#include "MarshalArray.h"
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
template<typename T>
bool Equals(T *pActual, int cActual, T *pExpected, int cExpected)
{
@@ -21,7 +27,7 @@ bool Equals(T *pActual, int cActual, T *pExpected, int cExpected)
{
if (!IsObjectEquals(pActual[i], pExpected[i]))
{
- printf("WARNING: Test error - %s\n", __FUNCSIG__);
+ printf("WARNING: Test error - %s\n", FUNCTIONNAME);
return false;
}
}
diff --git a/tests/src/JIT/Directed/StructABI/StructABI.c b/tests/src/JIT/Directed/StructABI/StructABI.c
index 09cd14de97..f56eaf2a6a 100644
--- a/tests/src/JIT/Directed/StructABI/StructABI.c
+++ b/tests/src/JIT/Directed/StructABI/StructABI.c
@@ -7,6 +7,16 @@
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __attribute__((visibility("default")))
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+
#endif // _MSC_VER
struct SingleByte
diff --git a/tests/src/JIT/Directed/arglist/varargnative.c b/tests/src/JIT/Directed/arglist/varargnative.c
index b0e1941916..54a778f38b 100644
--- a/tests/src/JIT/Directed/arglist/varargnative.c
+++ b/tests/src/JIT/Directed/arglist/varargnative.c
@@ -18,7 +18,17 @@
#define _cdecl
#endif
-#endif // _MSC_VER
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#endif // !_MSC_VER
/* Structures */
diff --git a/tests/src/JIT/Directed/pinning/object-pin/mirror.cpp b/tests/src/JIT/Directed/pinning/object-pin/mirror.cpp
index f5c4c4b7d1..268fb26523 100644
--- a/tests/src/JIT/Directed/pinning/object-pin/mirror.cpp
+++ b/tests/src/JIT/Directed/pinning/object-pin/mirror.cpp
@@ -2,6 +2,17 @@
#define EXPORT_API extern "C" __declspec(dllexport)
#else
#define EXPORT_API extern "C" __attribute__((visibility("default")))
+
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+
#endif
#include <cstddef>
diff --git a/tests/src/JIT/Methodical/structs/systemvbringup/structinregs.cpp b/tests/src/JIT/Methodical/structs/systemvbringup/structinregs.cpp
index 6b634cbb66..65794f3f62 100644
--- a/tests/src/JIT/Methodical/structs/systemvbringup/structinregs.cpp
+++ b/tests/src/JIT/Methodical/structs/systemvbringup/structinregs.cpp
@@ -1,10 +1,10 @@
#include <stdio.h>
-#if defined(__clang__)
-#define EXPORT(type) __attribute__((visibility("default"))) extern "C" type
-#else // defined(__clang__)
+#if defined(__GNUC__)
+#define EXPORT(type) extern "C" __attribute__((visibility("default"))) type
+#else // defined(__GNUC__)
#define EXPORT(type) type
-#endif // !defined(__clang__)
+#endif // !defined(__GNUC__)
#if !defined(_MSC_VER)
#if __i386__
@@ -324,7 +324,7 @@ EXPORT(void) NATIVEAPI InvokeCallback19(PFNACTION19 callback, S19 s)
EXPORT(void) NATIVEAPI InvokeCallback20(PFNACTION20 callback, S20 s)
{
-#ifdef __clang__
+#ifdef __GNUC__
printf("Native S20: %lld, %lld, %lld, %lld\n", s.x, s.y, s.z, s.w);
#else
printf("Native S20: %I64d, %I64d, %I64d, %I64d\n", s.x, s.y, s.z, s.w);
@@ -468,7 +468,7 @@ EXPORT(S19) NATIVEAPI InvokeCallback19R(PFNACTION19 callback, S19 s)
EXPORT(S20) NATIVEAPI InvokeCallback20R(PFNACTION20 callback, S20 s)
{
-#ifdef __clang__
+#ifdef __GNUC__
printf("Native S20: %lld, %lld, %lld, %lld\n", s.x, s.y, s.z, s.w);
#else
printf("Native S20: %I64d, %I64d, %I64d, %I64d\n", s.x, s.y, s.z, s.w);
diff --git a/tests/src/JIT/SIMD/Vector3TestNative.cpp b/tests/src/JIT/SIMD/Vector3TestNative.cpp
index 66dbe84e5d..9e6f96cd9b 100755
--- a/tests/src/JIT/SIMD/Vector3TestNative.cpp
+++ b/tests/src/JIT/SIMD/Vector3TestNative.cpp
@@ -5,13 +5,13 @@
#include <stdio.h>
#include <string.h>
-#if defined(__clang__)
-#define EXPORT(type) __attribute__((visibility("default"))) extern "C" type
+#if defined(__GNUC__)
+#define EXPORT(type) extern "C" __attribute__((visibility("default"))) type
#elif defined(_MSC_VER)
#define EXPORT(type) extern "C" __declspec(dllexport) type
-#else // defined(__clang__)
+#else // defined(__GNUC__)
#define EXPORT(type) type
-#endif // !defined(__clang__)
+#endif // !defined(__GNUC__)
#if !defined(_MSC_VER)
#if __i386__
diff --git a/tests/src/JIT/jit64/hfa/main/dll/hfa_native.cpp b/tests/src/JIT/jit64/hfa/main/dll/hfa_native.cpp
index a5be99dd44..740790aa2e 100644
--- a/tests/src/JIT/jit64/hfa/main/dll/hfa_native.cpp
+++ b/tests/src/JIT/jit64/hfa/main/dll/hfa_native.cpp
@@ -3,6 +3,17 @@
#include "hfa_native.h"
+#ifndef _MSC_VER
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+#endif
// ---------------------------------------------------
// Init Methods
diff --git a/tests/src/JIT/jit64/hfa/main/dll/hfa_native.h b/tests/src/JIT/jit64/hfa/main/dll/hfa_native.h
index 7cfdb2820f..1298225b23 100644
--- a/tests/src/JIT/jit64/hfa/main/dll/hfa_native.h
+++ b/tests/src/JIT/jit64/hfa/main/dll/hfa_native.h
@@ -7,6 +7,17 @@
#else // __i386__
#define __stdcall
#endif // !__i386__
+
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+
#endif // !defined(_MSC_VER)
#if defined(_MSC_VER)
diff --git a/tests/src/JIT/jit64/mcc/interop/native.h b/tests/src/JIT/jit64/mcc/interop/native.h
index cd2da9678a..cd07950e9d 100644
--- a/tests/src/JIT/jit64/mcc/interop/native.h
+++ b/tests/src/JIT/jit64/mcc/interop/native.h
@@ -9,6 +9,16 @@
#else
#define MCC_API extern "C" __attribute__((visibility("default")))
#define WINAPI
+#ifdef BIT64
+#define __int64 long
+#else // BIT64
+#define __int64 long long
+#endif // BIT64
+
+#define __int32 int
+#define __int16 short int
+#define __int8 char // assumes char is signed
+
#endif
// ---------------------------------
diff --git a/tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp b/tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp
index f7eab2de6e..47ec5d2d87 100644
--- a/tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp
+++ b/tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#if defined(__clang__)
+#if defined(__GNUC__)
#define EXPORT_API extern "C" __attribute__((visibility("default")))
#elif defined(_MSC_VER)
#define EXPORT_API extern "C" __declspec(dllexport)