From 0094610a6aaff4e39b51091ac4dc74510ed3903b Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Sun, 30 Mar 2014 18:51:53 +0100 Subject: [PATCH 1/5] Support the clang address sanitizer. Copied from Perforce Change: 185096 ServerID: perforce.ravenbrook.com --- mps/code/config.h | 21 +++++++++++++++------ mps/code/trace.c | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/mps/code/config.h b/mps/code/config.h index 6878d51b153..4ebed1a9d6d 100644 --- a/mps/code/config.h +++ b/mps/code/config.h @@ -203,19 +203,28 @@ /* Function attributes */ -/* These are also defined in testlib.h */ +/* Some of these are also defined in testlib.h */ -#if defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL) - -/* GCC: +/* Attribute for functions that take a printf-like format argument, so + * that the compiler can check the format specifiers against the types + * of the arguments. + * GCC: * Clang: */ +#if defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL) #define ATTRIBUTE_FORMAT(ARGLIST) __attribute__((__format__ ARGLIST)) - #else - #define ATTRIBUTE_FORMAT(ARGLIST) +#endif +/* Attribute for functions that should not be instrumented by Clang's + * address sanitizer. + * + */ +#if defined(MPS_BUILD_LL) && __has_feature(address_sanitizer) +#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((__no_sanitize_address__)) +#else +#define ATTRIBUTE_NO_SANITIZE_ADDRESS #endif diff --git a/mps/code/trace.c b/mps/code/trace.c index b394ed95e80..6fb666925b2 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c @@ -1462,6 +1462,7 @@ Res TraceScanAreaTagged(ScanState ss, Addr *base, Addr *limit) * This is as TraceScanArea except words are only fixed if they are zero * when masked with a mask. */ +ATTRIBUTE_NO_SANITIZE_ADDRESS Res TraceScanAreaMasked(ScanState ss, Addr *base, Addr *limit, Word mask) { Res res; From 01fbead5364160bcca3e54bea13f32446da68e5c Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 31 Mar 2014 11:37:46 +0100 Subject: [PATCH 2/5] Bring .p4ignore up to date so that p4 status is clean. Copied from Perforce Change: 185101 ServerID: perforce.ravenbrook.com --- mps/.p4ignore | 2 ++ mps/code/.p4ignore | 1 + mps/manual/.p4ignore | 1 + 3 files changed, 4 insertions(+) diff --git a/mps/.p4ignore b/mps/.p4ignore index ba720759d8c..fb2e5c024e5 100644 --- a/mps/.p4ignore +++ b/mps/.p4ignore @@ -16,3 +16,5 @@ TAGS *.dSYM code/*/*/*.d *.pyc +test/test/log +test/test/obj diff --git a/mps/code/.p4ignore b/mps/code/.p4ignore index 7a9dfb599a8..dcda2b9ad09 100644 --- a/mps/code/.p4ignore +++ b/mps/code/.p4ignore @@ -9,6 +9,7 @@ lii6ll w3i3mv w3i6mv xci3gc +xci6ll # Visual Studio junk Debug Release diff --git a/mps/manual/.p4ignore b/mps/manual/.p4ignore index 3902ee8b103..ef6464692c9 100644 --- a/mps/manual/.p4ignore +++ b/mps/manual/.p4ignore @@ -1,2 +1,3 @@ doctrees converted +html From 9c7e619ac0e5d7e84c5d301d441622b71563d4e5 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 31 Mar 2014 13:01:40 +0100 Subject: [PATCH 3/5] Fix compilation on lii6gc: * Don't test __has_feature unless we know we are on MPS_BUILD_LL. * Fix type-punned pointer aliasing in expt825.c. Copied from Perforce Change: 185104 ServerID: perforce.ravenbrook.com --- mps/code/config.h | 6 +++++- mps/code/expt825.c | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mps/code/config.h b/mps/code/config.h index 4ebed1a9d6d..f4cd43a54da 100644 --- a/mps/code/config.h +++ b/mps/code/config.h @@ -221,11 +221,15 @@ * address sanitizer. * */ -#if defined(MPS_BUILD_LL) && __has_feature(address_sanitizer) +#if defined(MPS_BUILD_LL) +#if __has_feature(address_sanitizer) #define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((__no_sanitize_address__)) #else #define ATTRIBUTE_NO_SANITIZE_ADDRESS #endif +#else +#define ATTRIBUTE_NO_SANITIZE_ADDRESS +#endif /* EPVMDefaultSubsequentSegSIZE is a default for the alignment of diff --git a/mps/code/expt825.c b/mps/code/expt825.c index 459452bc722..5947a0cff68 100644 --- a/mps/code/expt825.c +++ b/mps/code/expt825.c @@ -86,7 +86,8 @@ static void register_numbered_tree(mps_word_t tree, mps_arena_t arena) { /* don't finalize ints */ if ((tree & 1) == 0) { - die(mps_finalize(arena, (mps_addr_t *)&tree), "mps_finalize"); + mps_addr_t addr = (void *)tree; + die(mps_finalize(arena, &addr), "mps_finalize"); register_numbered_tree(DYLAN_VECTOR_SLOT(tree, 0), arena); register_numbered_tree(DYLAN_VECTOR_SLOT(tree, 1), arena); } @@ -124,8 +125,8 @@ static void register_indirect_tree(mps_word_t tree, mps_arena_t arena) { /* don't finalize ints */ if ((tree & 1) == 0) { - mps_word_t indirect = DYLAN_VECTOR_SLOT(tree,2); - die(mps_finalize(arena, (mps_addr_t *)&indirect), "mps_finalize"); + mps_addr_t indirect = (void *)DYLAN_VECTOR_SLOT(tree,2); + die(mps_finalize(arena, &indirect), "mps_finalize"); register_indirect_tree(DYLAN_VECTOR_SLOT(tree, 0), arena); register_indirect_tree(DYLAN_VECTOR_SLOT(tree, 1), arena); } From 5a035142d0cfec92f5a94903bed3ad72c3d7305c Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 31 Mar 2014 16:58:05 +0100 Subject: [PATCH 4/5] Fix typo: "if exists" should be "if exist". Copied from Perforce Change: 185108 ServerID: perforce.ravenbrook.com --- mps/tool/testrun.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mps/tool/testrun.bat b/mps/tool/testrun.bat index 255ecf23e51..e2b16a00260 100755 --- a/mps/tool/testrun.bat +++ b/mps/tool/testrun.bat @@ -61,7 +61,7 @@ set FAIL_COUNT=0 set SEPARATOR=---------------------------------------- set LOGDIR=%TMP%\mps-%PFM%-%VARIETY%-log echo Logging test output to %LOGDIR% -if exists %LOGDIR% rmdir /q /s %LOGDIR% +if exist %LOGDIR% rmdir /q /s %LOGDIR% mkdir %LOGDIR% if "%1"=="" call :run_tests %ALL_TEST_CASES% From 40ed06bf1708fc984e6a62d2bd873d628a7c4ddd Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 1 Apr 2014 22:07:48 +0100 Subject: [PATCH 5/5] Clang can compile eventsql.c with -pedantic but gcc cannot. Copied from Perforce Change: 185137 ServerID: perforce.ravenbrook.com --- mps/code/gc.gmk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mps/code/gc.gmk b/mps/code/gc.gmk index 3b7f0e664b9..608ced354b0 100644 --- a/mps/code/gc.gmk +++ b/mps/code/gc.gmk @@ -13,7 +13,6 @@ CC = gcc CFLAGSDEBUG = -O -g3 CFLAGSOPT = -O2 -g3 CFLAGSCOMPILER := \ - -pedantic \ -Waggregate-return \ -Wall \ -Wcast-qual \ @@ -27,7 +26,7 @@ CFLAGSCOMPILER := \ -Wstrict-aliasing=2 \ -Wstrict-prototypes \ -Wwrite-strings -CFLAGSCOMPILERSTRICT := -ansi +CFLAGSCOMPILERSTRICT := -ansi -pedantic # A different set of compiler flags for less strict compilation, for # instance when we need to #include a third-party header file that