]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Turn VALGRIND variable into a meson configuration switch
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 13 May 2018 20:28:24 +0000 (22:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 May 2018 16:54:36 +0000 (09:54 -0700)
Configuration through environment variable is inconvenient with meson, because
they cannot be convieniently changed and/or are not preserved during
reconfiguration (https://github.com/mesonbuild/meson/issues/1503).
This adds -Dvalgrind=true/false, which has the advantage that it can be set
at any time with meson configure -Dvalgrind=... and ninja will rebuild targets
as necessary. Additional minor advantages are better consistency with the
options for hashmap debugging, and typo avoidance with '#if' instead of '#ifdef'.

README
meson.build
meson_options.txt
src/basic/hashmap.c
src/basic/mempool.c
src/basic/mempool.h
src/journal/lookup3.c
src/libsystemd-network/test-dhcp-client.c

diff --git a/README b/README
index d18eb7dc1e36c90c626411fe40a53cfa021c58e8..2cde08c37e1c2ca7c56c7f985af329ec5bd24da6 100644 (file)
--- a/README
+++ b/README
@@ -303,13 +303,12 @@ WARNINGS:
         For more information on this issue consult
         https://www.freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
 
-        To run systemd under valgrind, compile with VALGRIND defined
-        (e.g. CPPFLAGS='... -DVALGRIND=1' meson <options>) and have valgrind
-        development headers installed (i.e. valgrind-devel or
-        equivalent). Otherwise, false positives will be triggered by code which
-        violates some rules but is actually safe. Note that valgrind generates
-        nice output only on exit(), hence on shutdown we don't execve()
-        systemd-shutdown.
+        To run systemd under valgrind, compile with meson option
+        -Dvalgrind=true and have valgrind development headers installed
+        (i.e. valgrind-devel or equivalent). Otherwise, false positives will be
+        triggered by code which violates some rules but is actually safe. Note
+        that valgrind generates nice output only on exit(), hence on shutdown
+        we don't execve() systemd-shutdown.
 
 STABLE BRANCHES AND BACKPORTS
 
index aa07ed8e9bfb62428030e0dad389a693040eb7a8..469737819d81dc63fc8b751041813d75e788d876 100644 (file)
@@ -774,6 +774,8 @@ endforeach
 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
 
+conf.set10('VALGRIND', get_option('valgrind'))
+
 #####################################################################
 
 threads = dependency('threads')
@@ -2925,6 +2927,7 @@ foreach tuple : [
         ['gshadow'],
         ['debug hashmap'],
         ['debug mmap cache'],
+        ['valgrind',         conf.get('VALGRIND') == 1],
 ]
 
         if tuple.length() >= 2
index 3b718311a3aa7c9f2692ed155a9ca9dba127694a..e3dea3ebc5413fa9c7e6130f182b1c10ceb13955 100644 (file)
@@ -50,6 +50,8 @@ option('debug', type : 'array', choices : ['hashmap', 'mmap-cache'], value : [],
        description : 'enable extra debugging')
 option('memory-accounting-default', type : 'boolean',
        description : 'enable MemoryAccounting= by default')
+option('valgrind', type : 'boolean', value : false,
+       description : 'do extra operations to avoid valgrind warnings')
 
 option('utmp', type : 'boolean',
        description : 'support for utmp/wtmp log handling')
index a53d78c417e6bc6d94d8235fa9ed49b4f6d5738c..cf51167c1aa9cea097585c0bd428ae5d4da77e50 100644 (file)
@@ -281,7 +281,7 @@ static const struct hashmap_type_info hashmap_type_info[_HASHMAP_TYPE_MAX] = {
         },
 };
 
-#ifdef VALGRIND
+#if VALGRIND
 __attribute__((destructor)) static void cleanup_pools(void) {
         _cleanup_free_ char *t = NULL;
         int r;
index 4be4a3d38eb4b0f38937d9275812951a3ea37e15..2e55639e829bce475c9cef8313a3cb6761a2af29 100644 (file)
@@ -76,7 +76,7 @@ void mempool_free_tile(struct mempool *mp, void *p) {
         mp->freelist = p;
 }
 
-#ifdef VALGRIND
+#if VALGRIND
 
 void mempool_drop(struct mempool *mp) {
         struct pool *p = mp->first_pool;
index 5322fd480d39668952dd4e6854ecb11fb0bdf1b6..68249cd88118c8011d045db9196938bcb96bb7c1 100644 (file)
@@ -30,6 +30,6 @@ static struct mempool pool_name = { \
 }
 
 
-#ifdef VALGRIND
+#if VALGRIND
 void mempool_drop(struct mempool *mp);
 #endif
index ec241d2f36d2c90bbf494272be85fc1d87d265f9..ff194dd95176c472458e0c61c3cc29ec5ac36aa8 100644 (file)
@@ -315,11 +315,11 @@ uint32_t jenkins_hashlittle( const void *key, size_t length, uint32_t initval)
      * then masks off the part it's not allowed to read.  Because the
      * string is aligned, the masked-off tail is in the same word as the
      * rest of the string.  Every machine with memory protection I've seen
-     * does it on word boundaries, so is OK with this.  But VALGRIND will
+     * does it on word boundaries, so is OK with this.  But valgrind will
      * still catch it and complain.  The masking trick does make the hash
      * noticeably faster for short strings (like English words).
      */
-#if !defined(VALGRIND) && !defined(__SANITIZE_ADDRESS__)
+#if !VALGRIND && !defined(__SANITIZE_ADDRESS__)
 
     switch(length)
     {
@@ -500,11 +500,11 @@ void jenkins_hashlittle2(
      * then masks off the part it's not allowed to read.  Because the
      * string is aligned, the masked-off tail is in the same word as the
      * rest of the string.  Every machine with memory protection I've seen
-     * does it on word boundaries, so is OK with this.  But VALGRIND will
+     * does it on word boundaries, so is OK with this.  But valgrind will
      * still catch it and complain.  The masking trick does make the hash
      * noticeably faster for short strings (like English words).
      */
-#if !defined(VALGRIND) && !defined(__SANITIZE_ADDRESS__)
+#if !VALGRIND && !defined(__SANITIZE_ADDRESS__)
 
     switch(length)
     {
@@ -676,11 +676,11 @@ uint32_t jenkins_hashbig( const void *key, size_t length, uint32_t initval)
      * then shifts out the part it's not allowed to read.  Because the
      * string is aligned, the illegal read is in the same word as the
      * rest of the string.  Every machine with memory protection I've seen
-     * does it on word boundaries, so is OK with this.  But VALGRIND will
+     * does it on word boundaries, so is OK with this.  But valgrind will
      * still catch it and complain.  The masking trick does make the hash
      * noticeably faster for short strings (like English words).
      */
-#if !defined(VALGRIND) && !defined(__SANITIZE_ADDRESS__)
+#if !VALGRIND && !defined(__SANITIZE_ADDRESS__)
 
     switch(length)
     {
index 98e8a7e25a2cc15c717bebacfabcba88fe1ee9ad..7aa121b85c875687fb7980384ca879a3be8e9bef 100644 (file)
@@ -539,7 +539,7 @@ int main(int argc, char *argv[]) {
         test_discover_message(e);
         test_addr_acq(e);
 
-#ifdef VALGRIND
+#if VALGRIND
         /* Make sure the async_close thread has finished.
          * valgrind would report some of the phread_* structures
          * as not cleaned up properly. */