Skip to content

Commit b513a5a

Browse files
author
Austin Seipp
committed
Make valgrind usage more consistent and less error prone.
I was still having issues with the build system somehow getting confused as to which set of valgrind headers to use when compiling rt. This commit moves all the valgrind headers into their own directory under rt and makes the usage more consistent. The compiler is now passed the -DNVALGRIND flag when valgrind is not installed, as opposed to passing -DHAVE_VALGRIND. We also pass -I src/rt to the compiler when building rt so you can more easily import what you want. I also cleaned up some erroneous #includes along the way. It should be safe to always just import the local valgrind headers and use them without question. NVALGRIND turns the operations to no-ops when it is active, and the build and tests run cleanly with or without.
1 parent 8d8148f commit b513a5a

File tree

8 files changed

+8
-14
lines changed

8 files changed

+8
-14
lines changed

mk/platform.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ CFG_GCCISH_LINK_FLAGS :=
1717
# embedded into the executable, so use a no-op command.
1818
CFG_DSYMUTIL := true
1919

20-
ifneq ($(CFG_VALGRIND),)
21-
CFG_GCCISH_CFLAGS += -DHAVE_VALGRIND
20+
ifeq ($(CFG_VALGRIND),)
21+
CFG_GCCISH_CFLAGS += -DNVALGRIND
2222
endif
2323

2424
ifneq ($(findstring freebsd,$(CFG_OSTYPE)),)

mk/rt.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ else
125125
endif
126126

127127
RUNTIME_DEF_$(1) := rt/rustrt$$(CFG_DEF_SUFFIX)
128-
RUNTIME_INCS_$(1) := -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
128+
RUNTIME_INCS_$(1) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
129129
-I $$(S)src/rt/arch/$$(HOST_$(1)) \
130130
-I $$(S)src/libuv/include
131131
RUNTIME_OBJS_$(1) := $$(RUNTIME_CS_$(1):rt/%.cpp=rt/$(1)/%.o) \

src/rt/arch/i386/context.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <inttypes.h>
88
#include <stdint.h>
99

10-
#include "../../memcheck.h"
10+
#include "vg/memcheck.h"
1111

1212
template<typename T>
1313
T align_down(T sp)
@@ -51,9 +51,7 @@ class context {
5151
uint32_t bot = regs.esp;
5252
uint32_t top = align_down(bot - nbytes);
5353

54-
#ifdef HAVE_VALGRIND
5554
(void)VALGRIND_MAKE_MEM_UNDEFINED(top - 4, bot - top + 4);
56-
#endif
5755

5856
return reinterpret_cast<void *>(top);
5957
}

src/rt/arch/x86_64/context.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include <stdint.h>
99
#include <xmmintrin.h>
1010

11-
#ifdef HAVE_VALGRIND
12-
#include <valgrind/memcheck.h>
13-
#endif
11+
#include "vg/memcheck.h"
1412

1513
template<typename T>
1614
T align_down(T sp)
@@ -51,9 +49,7 @@ class context {
5149
uint64_t bot = regs.data[RUSTRT_RSP];
5250
uint64_t top = align_down(bot - nbytes);
5351

54-
#ifdef HAVE_VALGRIND
5552
(void)VALGRIND_MAKE_MEM_UNDEFINED(top - 4, bot - top + 4);
56-
#endif
5753

5854
return reinterpret_cast<void *>(top);
5955
}

src/rt/rust_task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "rust_internal.h"
33
#include "rust_cc.h"
44

5-
#include "valgrind.h"
6-
#include "memcheck.h"
5+
#include "vg/valgrind.h"
6+
#include "vg/memcheck.h"
77

88
#ifndef __WIN32__
99
#include <execinfo.h>

src/rt/rust_timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "rust_internal.h"
2-
#include "valgrind.h"
2+
#include "vg/valgrind.h"
33

44
// The mechanism in this file is very crude; every domain (thread) spawns its
55
// own secondary timer thread, and that timer thread *never idles*. It
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)