Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit d640139

Browse files
omajidMike McLaughlinfranksinankayatmds
authored
Fix build with clang 10 (#28045)
This contains a grab bag of fixes to fix the build with clang 10. - #23075 Fix missing includes in coreclr/src/debug/createdump/ - dotnet/runtime#33096 SList::Init: add missing constructor - A subset of #22129 Just the parts that introduce the THROW_DECL macro in pal.h - dotnet/runtime#32837 This fixes THROW_DECL introduce in the previous PR to work with clang, which is required in clang 10. - One new change: In a significant divergance, this commits adds more THROW_DECL macros to all the math functions to address a ton of errors pointed out when building SOS: In file included from /home/omajid/devel/dotnet/coreclr/src/ToolBox/SOS/Strike/strike.cpp:116: In file included from /home/omajid/devel/dotnet/coreclr/src/vm/hillclimbing.h:19: In file included from /home/omajid/devel/dotnet/coreclr/src/inc/complex.h:16: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/math.h:36: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/cmath:45: In file included from /usr/include/math.h:290: /usr/include/bits/mathcalls.h:53:13: error: exception specification in declaration does not match previous declaration __MATHCALL (acos,, (_Mdouble_ __x)); ^ /home/omajid/devel/dotnet/coreclr/src/pal/inc/pal.h:4395:26: note: previous declaration is here PALIMPORT double __cdecl acos(double); ^ Then, to make sure the declarations and implementations match, it adds THROW_DECL to the definitions in src/pal/src/cruntime/math.cpp Co-authored-by: Mike McLaughlin <[email protected]> Co-authored-by: Sinan Kaya <[email protected]> Co-authored-by: Tom Deseyn <[email protected]> Co-authored-by: Mike McLaughlin <[email protected]> Co-authored-by: Sinan Kaya <[email protected]> Co-authored-by: Tom Deseyn <[email protected]>
1 parent e4e60f9 commit d640139

File tree

6 files changed

+87
-74
lines changed

6 files changed

+87
-74
lines changed

src/debug/createdump/createdump.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ typedef int T_CONTEXT;
5454
#include <map>
5555
#include <set>
5656
#include <vector>
57+
#include <string>
58+
#include <array>
5759
#include "datatarget.h"
5860
#include "threadinfo.h"
5961
#include "memoryregion.h"

src/inc/slist.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ class SList
160160
void Init()
161161
{
162162
LIMITED_METHOD_CONTRACT;
163-
m_pHead = &m_link;
163+
m_pHead = PTR_SLink(&m_link);
164164
// NOTE :: fHead variable is template argument
165165
// the following code is a compiled in, only if the fHead flag
166166
// is set to false,
167167
if (!fHead)
168168
{
169-
m_pTail = &m_link;
169+
m_pTail = PTR_SLink(&m_link);
170170
}
171171
}
172172

@@ -274,7 +274,7 @@ class SList
274274
SLink *ret = SLink::FindAndRemove(m_pHead, GetLink(pObj), &prior);
275275

276276
if (ret == m_pTail)
277-
m_pTail = prior;
277+
m_pTail = PTR_SLink(prior);
278278

279279
return GetObject(ret);
280280
}

src/pal/inc/mbusafecrt.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ typedef int errno_t;
3131
// define the return value for success
3232
#define SAFECRT_SUCCESS 0
3333

34+
#if defined(_MSC_VER)
35+
#define THROW_DECL
36+
#else
37+
#define THROW_DECL throw()
38+
#endif
39+
3440
#ifdef __cplusplus
3541
extern "C" {
3642
#endif
@@ -98,7 +104,7 @@ extern int swscanf_s( const WCHAR *string, const WCHAR *format, ... );
98104
extern int _snscanf_s( const char *string, size_t count, const char *format, ... );
99105
extern int _snwscanf_s( const WCHAR *string, size_t count, const WCHAR *format, ... );
100106

101-
extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
107+
extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count ) THROW_DECL;
102108
extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
103109

104110
#ifdef __cplusplus

src/pal/inc/pal.h

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ extern "C" {
137137
#define LANG_THAI 0x1e
138138

139139
/******************* Compiler-specific glue *******************************/
140+
#if defined(_MSC_VER) || !defined(__cplusplus)
141+
#define THROW_DECL
142+
#else
143+
#define THROW_DECL throw()
144+
#endif
140145

141146
#ifndef _MSC_VER
142147
#if defined(CORECLR)
@@ -4207,7 +4212,7 @@ EXTERN_C
42074212
PALIMPORT
42084213
void *PAL_memcpy (void *dest, const void *src, size_t count);
42094214

4210-
PALIMPORT void * __cdecl memcpy(void *, const void *, size_t);
4215+
PALIMPORT void * __cdecl memcpy(void *, const void *, size_t) THROW_DECL;
42114216

42124217
#define memcpy PAL_memcpy
42134218
#define IS_PAL_memcpy 1
@@ -4220,7 +4225,7 @@ PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
42204225
PALIMPORT void * __cdecl memset(void *, int, size_t);
42214226
PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
42224227
PALIMPORT void * __cdecl memchr(const void *, int, size_t);
4223-
PALIMPORT long long int __cdecl atoll(const char *);
4228+
PALIMPORT long long int __cdecl atoll(const char *) THROW_DECL;
42244229
PALIMPORT size_t __cdecl strlen(const char *);
42254230
PALIMPORT int __cdecl strcmp(const char*, const char *);
42264231
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
@@ -4259,7 +4264,7 @@ PALIMPORT int __cdecl toupper(int);
42594264
#define _TRUNCATE ((size_t)-1)
42604265
#endif
42614266

4262-
PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
4267+
PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
42634268
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
42644269
PALIMPORT char * __cdecl _strlwr(char *);
42654270
PALIMPORT int __cdecl _stricmp(const char *, const char *);
@@ -4387,58 +4392,58 @@ PALIMPORT long long __cdecl llabs(long long);
43874392
PALIMPORT int __cdecl _finite(double);
43884393
PALIMPORT int __cdecl _isnan(double);
43894394
PALIMPORT double __cdecl _copysign(double, double);
4390-
PALIMPORT double __cdecl acos(double);
4391-
PALIMPORT double __cdecl acosh(double);
4392-
PALIMPORT double __cdecl asin(double);
4393-
PALIMPORT double __cdecl asinh(double);
4394-
PALIMPORT double __cdecl atan(double);
4395-
PALIMPORT double __cdecl atanh(double);
4396-
PALIMPORT double __cdecl atan2(double, double);
4397-
PALIMPORT double __cdecl cbrt(double);
4398-
PALIMPORT double __cdecl ceil(double);
4399-
PALIMPORT double __cdecl cos(double);
4400-
PALIMPORT double __cdecl cosh(double);
4401-
PALIMPORT double __cdecl exp(double);
4402-
PALIMPORT double __cdecl fabs(double);
4403-
PALIMPORT double __cdecl floor(double);
4404-
PALIMPORT double __cdecl fmod(double, double);
4405-
PALIMPORT double __cdecl log(double);
4406-
PALIMPORT double __cdecl log10(double);
4407-
PALIMPORT double __cdecl modf(double, double*);
4408-
PALIMPORT double __cdecl pow(double, double);
4409-
PALIMPORT double __cdecl sin(double);
4410-
PALIMPORT double __cdecl sinh(double);
4411-
PALIMPORT double __cdecl sqrt(double);
4412-
PALIMPORT double __cdecl tan(double);
4413-
PALIMPORT double __cdecl tanh(double);
4395+
PALIMPORT double __cdecl acos(double) THROW_DECL;
4396+
PALIMPORT double __cdecl acosh(double) THROW_DECL;
4397+
PALIMPORT double __cdecl asin(double) THROW_DECL;
4398+
PALIMPORT double __cdecl asinh(double) THROW_DECL;
4399+
PALIMPORT double __cdecl atan(double) THROW_DECL;
4400+
PALIMPORT double __cdecl atanh(double) THROW_DECL;
4401+
PALIMPORT double __cdecl atan2(double, double) THROW_DECL;
4402+
PALIMPORT double __cdecl cbrt(double) THROW_DECL;
4403+
PALIMPORT double __cdecl ceil(double) THROW_DECL;
4404+
PALIMPORT double __cdecl cos(double) THROW_DECL;
4405+
PALIMPORT double __cdecl cosh(double) THROW_DECL;
4406+
PALIMPORT double __cdecl exp(double) THROW_DECL;
4407+
PALIMPORT double __cdecl fabs(double) THROW_DECL;
4408+
PALIMPORT double __cdecl floor(double) THROW_DECL;
4409+
PALIMPORT double __cdecl fmod(double, double) THROW_DECL;
4410+
PALIMPORT double __cdecl log(double) THROW_DECL;
4411+
PALIMPORT double __cdecl log10(double) THROW_DECL;
4412+
PALIMPORT double __cdecl modf(double, double*) THROW_DECL;
4413+
PALIMPORT double __cdecl pow(double, double) THROW_DECL;
4414+
PALIMPORT double __cdecl sin(double) THROW_DECL;
4415+
PALIMPORT double __cdecl sinh(double) THROW_DECL;
4416+
PALIMPORT double __cdecl sqrt(double) THROW_DECL;
4417+
PALIMPORT double __cdecl tan(double) THROW_DECL;
4418+
PALIMPORT double __cdecl tanh(double) THROW_DECL;
44144419

44154420
PALIMPORT int __cdecl _finitef(float);
44164421
PALIMPORT int __cdecl _isnanf(float);
44174422
PALIMPORT float __cdecl _copysignf(float, float);
4418-
PALIMPORT float __cdecl acosf(float);
4419-
PALIMPORT float __cdecl acoshf(float);
4420-
PALIMPORT float __cdecl asinf(float);
4421-
PALIMPORT float __cdecl asinhf(float);
4422-
PALIMPORT float __cdecl atanf(float);
4423-
PALIMPORT float __cdecl atanhf(float);
4424-
PALIMPORT float __cdecl atan2f(float, float);
4425-
PALIMPORT float __cdecl cbrtf(float);
4426-
PALIMPORT float __cdecl ceilf(float);
4427-
PALIMPORT float __cdecl cosf(float);
4428-
PALIMPORT float __cdecl coshf(float);
4429-
PALIMPORT float __cdecl expf(float);
4430-
PALIMPORT float __cdecl fabsf(float);
4431-
PALIMPORT float __cdecl floorf(float);
4432-
PALIMPORT float __cdecl fmodf(float, float);
4433-
PALIMPORT float __cdecl logf(float);
4434-
PALIMPORT float __cdecl log10f(float);
4435-
PALIMPORT float __cdecl modff(float, float*);
4436-
PALIMPORT float __cdecl powf(float, float);
4437-
PALIMPORT float __cdecl sinf(float);
4438-
PALIMPORT float __cdecl sinhf(float);
4439-
PALIMPORT float __cdecl sqrtf(float);
4440-
PALIMPORT float __cdecl tanf(float);
4441-
PALIMPORT float __cdecl tanhf(float);
4423+
PALIMPORT float __cdecl acosf(float) THROW_DECL;
4424+
PALIMPORT float __cdecl acoshf(float) THROW_DECL;
4425+
PALIMPORT float __cdecl asinf(float) THROW_DECL;
4426+
PALIMPORT float __cdecl asinhf(float) THROW_DECL;
4427+
PALIMPORT float __cdecl atanf(float) THROW_DECL;
4428+
PALIMPORT float __cdecl atanhf(float) THROW_DECL;
4429+
PALIMPORT float __cdecl atan2f(float, float) THROW_DECL;
4430+
PALIMPORT float __cdecl cbrtf(float) THROW_DECL;
4431+
PALIMPORT float __cdecl ceilf(float) THROW_DECL;
4432+
PALIMPORT float __cdecl cosf(float) THROW_DECL;
4433+
PALIMPORT float __cdecl coshf(float) THROW_DECL;
4434+
PALIMPORT float __cdecl expf(float) THROW_DECL;
4435+
PALIMPORT float __cdecl fabsf(float) THROW_DECL;
4436+
PALIMPORT float __cdecl floorf(float) THROW_DECL;
4437+
PALIMPORT float __cdecl fmodf(float, float) THROW_DECL;
4438+
PALIMPORT float __cdecl logf(float) THROW_DECL;
4439+
PALIMPORT float __cdecl log10f(float) THROW_DECL;
4440+
PALIMPORT float __cdecl modff(float, float*) THROW_DECL;
4441+
PALIMPORT float __cdecl powf(float, float) THROW_DECL;
4442+
PALIMPORT float __cdecl sinf(float) THROW_DECL;
4443+
PALIMPORT float __cdecl sinhf(float) THROW_DECL;
4444+
PALIMPORT float __cdecl sqrtf(float) THROW_DECL;
4445+
PALIMPORT float __cdecl tanf(float) THROW_DECL;
4446+
PALIMPORT float __cdecl tanhf(float) THROW_DECL;
44424447

44434448
#ifndef PAL_STDCPP_COMPAT
44444449

src/pal/src/cruntime/math.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ double __cdecl _copysign(double x, double y)
117117
118118
See MSDN.
119119
--*/
120-
PALIMPORT double __cdecl PAL_acos(double x)
120+
PALIMPORT double __cdecl PAL_acos(double x) THROW_DECL
121121
{
122122
double ret;
123123
PERF_ENTRY(acos);
@@ -147,7 +147,7 @@ PALIMPORT double __cdecl PAL_acos(double x)
147147
148148
See MSDN.
149149
--*/
150-
PALIMPORT double __cdecl PAL_acosh(double x)
150+
PALIMPORT double __cdecl PAL_acosh(double x) THROW_DECL
151151
{
152152
double ret;
153153
PERF_ENTRY(acosh);
@@ -166,7 +166,7 @@ PALIMPORT double __cdecl PAL_acosh(double x)
166166
167167
See MSDN.
168168
--*/
169-
PALIMPORT double __cdecl PAL_asin(double x)
169+
PALIMPORT double __cdecl PAL_asin(double x) THROW_DECL
170170
{
171171
double ret;
172172
PERF_ENTRY(asin);
@@ -196,7 +196,7 @@ PALIMPORT double __cdecl PAL_asin(double x)
196196
197197
See MSDN.
198198
--*/
199-
PALIMPORT double __cdecl PAL_asinh(double x)
199+
PALIMPORT double __cdecl PAL_asinh(double x) THROW_DECL
200200
{
201201
double ret;
202202
PERF_ENTRY(asinh);
@@ -215,7 +215,7 @@ PALIMPORT double __cdecl PAL_asinh(double x)
215215
216216
See MSDN.
217217
--*/
218-
PALIMPORT double __cdecl PAL_atan2(double y, double x)
218+
PALIMPORT double __cdecl PAL_atan2(double y, double x) THROW_DECL
219219
{
220220
double ret;
221221
PERF_ENTRY(atan2);
@@ -255,7 +255,7 @@ PALIMPORT double __cdecl PAL_atan2(double y, double x)
255255
256256
See MSDN.
257257
--*/
258-
PALIMPORT double __cdecl PAL_exp(double x)
258+
PALIMPORT double __cdecl PAL_exp(double x) THROW_DECL
259259
{
260260
double ret;
261261
PERF_ENTRY(exp);
@@ -306,7 +306,7 @@ PALIMPORT LONG __cdecl PAL_labs(LONG l)
306306
307307
See MSDN.
308308
--*/
309-
PALIMPORT double __cdecl PAL_log(double x)
309+
PALIMPORT double __cdecl PAL_log(double x) THROW_DECL
310310
{
311311
double ret;
312312
PERF_ENTRY(log);
@@ -336,7 +336,7 @@ PALIMPORT double __cdecl PAL_log(double x)
336336
337337
See MSDN.
338338
--*/
339-
PALIMPORT double __cdecl PAL_log10(double x)
339+
PALIMPORT double __cdecl PAL_log10(double x) THROW_DECL
340340
{
341341
double ret;
342342
PERF_ENTRY(log10);
@@ -366,7 +366,7 @@ PALIMPORT double __cdecl PAL_log10(double x)
366366
367367
See MSDN.
368368
--*/
369-
PALIMPORT double __cdecl PAL_pow(double x, double y)
369+
PALIMPORT double __cdecl PAL_pow(double x, double y) THROW_DECL
370370
{
371371
double ret;
372372
PERF_ENTRY(pow);
@@ -527,7 +527,7 @@ float __cdecl _copysignf(float x, float y)
527527
528528
See MSDN.
529529
--*/
530-
PALIMPORT float __cdecl PAL_acosf(float x)
530+
PALIMPORT float __cdecl PAL_acosf(float x) THROW_DECL
531531
{
532532
float ret;
533533
PERF_ENTRY(acosf);
@@ -557,7 +557,7 @@ PALIMPORT float __cdecl PAL_acosf(float x)
557557
558558
See MSDN.
559559
--*/
560-
PALIMPORT float __cdecl PAL_acoshf(float x)
560+
PALIMPORT float __cdecl PAL_acoshf(float x) THROW_DECL
561561
{
562562
float ret;
563563
PERF_ENTRY(acoshf);
@@ -576,7 +576,7 @@ PALIMPORT float __cdecl PAL_acoshf(float x)
576576
577577
See MSDN.
578578
--*/
579-
PALIMPORT float __cdecl PAL_asinf(float x)
579+
PALIMPORT float __cdecl PAL_asinf(float x) THROW_DECL
580580
{
581581
float ret;
582582
PERF_ENTRY(asinf);
@@ -606,7 +606,7 @@ PALIMPORT float __cdecl PAL_asinf(float x)
606606
607607
See MSDN.
608608
--*/
609-
PALIMPORT float __cdecl PAL_asinhf(float x)
609+
PALIMPORT float __cdecl PAL_asinhf(float x) THROW_DECL
610610
{
611611
float ret;
612612
PERF_ENTRY(asinhf);
@@ -626,7 +626,7 @@ PALIMPORT float __cdecl PAL_asinhf(float x)
626626
627627
See MSDN.
628628
--*/
629-
PALIMPORT float __cdecl PAL_atan2f(float y, float x)
629+
PALIMPORT float __cdecl PAL_atan2f(float y, float x) THROW_DECL
630630
{
631631
float ret;
632632
PERF_ENTRY(atan2f);
@@ -666,7 +666,7 @@ PALIMPORT float __cdecl PAL_atan2f(float y, float x)
666666
667667
See MSDN.
668668
--*/
669-
PALIMPORT float __cdecl PAL_expf(float x)
669+
PALIMPORT float __cdecl PAL_expf(float x) THROW_DECL
670670
{
671671
float ret;
672672
PERF_ENTRY(expf);
@@ -698,7 +698,7 @@ PALIMPORT float __cdecl PAL_expf(float x)
698698
699699
See MSDN.
700700
--*/
701-
PALIMPORT float __cdecl PAL_logf(float x)
701+
PALIMPORT float __cdecl PAL_logf(float x) THROW_DECL
702702
{
703703
float ret;
704704
PERF_ENTRY(logf);
@@ -728,7 +728,7 @@ PALIMPORT float __cdecl PAL_logf(float x)
728728
729729
See MSDN.
730730
--*/
731-
PALIMPORT float __cdecl PAL_log10f(float x)
731+
PALIMPORT float __cdecl PAL_log10f(float x) THROW_DECL
732732
{
733733
float ret;
734734
PERF_ENTRY(log10f);
@@ -758,7 +758,7 @@ PALIMPORT float __cdecl PAL_log10f(float x)
758758
759759
See MSDN.
760760
--*/
761-
PALIMPORT float __cdecl PAL_powf(float x, float y)
761+
PALIMPORT float __cdecl PAL_powf(float x, float y) THROW_DECL
762762
{
763763
float ret;
764764
PERF_ENTRY(powf);

src/pal/src/safecrt/memcpy_s.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ errno_t __cdecl memcpy_s(
5454
size_t sizeInBytes,
5555
const void * src,
5656
size_t count
57-
)
57+
) THROW_DECL
5858
{
5959
if (count == 0)
6060
{

0 commit comments

Comments
 (0)