build: make address sanitizer options configurable with cmake 02/27202/3
authorDamjan Marion <damarion@cisco.com>
Thu, 21 May 2020 17:09:13 +0000 (19:09 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 27 May 2020 18:46:27 +0000 (18:46 +0000)
Type: improvement
Change-Id: I9ee0407e0634f773862dd65ff5d5594814294c2c
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/CMakeLists.txt
src/vpp/CMakeLists.txt
src/vpp/vnet/config.h.in [new file with mode: 0644]
src/vpp/vnet/main.c

index 59c7512..e2937c9 100644 (file)
@@ -110,6 +110,12 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
 ##############################################################################
 
 option(VPP_ENABLE_SANITIZE_ADDR "Enable Address Sanitizer" OFF)
+set(VPP_SANITIZE_ADDR_ARGS
+  "unmap_shadow_on_exit=1:disable_coredump=0:abort_on_error=1:detect_leaks=0"
+  CACHE
+  STRING "Address sanitizer arguments"
+)
+
 if (VPP_ENABLE_SANITIZE_ADDR)
   set(CMAKE_C_FLAGS "-fsanitize=address --param asan-stack=0 -DCLIB_SANITIZE_ADDR ${CMAKE_C_FLAGS}")
   set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address ${CMAKE_EXE_LINKER_FLAGS}")
index 8f7c2cf..f045836 100644 (file)
@@ -33,6 +33,11 @@ add_custom_target(vpp_version_h
 ##############################################################################
 option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON)
 
+configure_file(
+  ${CMAKE_SOURCE_DIR}/vpp/vnet/config.h.in
+  ${CMAKE_BINARY_DIR}/vpp/vnet/config.h
+)
+
 set(VPP_API_FILES
   api/vpe_types.api
   api/vpe.api
diff --git a/src/vpp/vnet/config.h.in b/src/vpp/vnet/config.h.in
new file mode 100644 (file)
index 0000000..8eee6da
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef included_vpp_vnet_config_h
+#define included_vpp_vnet_config_h
+
+#define VPP_SANITIZE_ADDR_OPTIONS "@VPP_SANITIZE_ADDR_OPTIONS@"
+
+#endif
index a95d6a7..f4cc504 100644 (file)
@@ -24,6 +24,7 @@
 #include <vnet/plugin/plugin.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vpp/app/version.h>
+#include <vpp/vnet/config.h>
 #include <vpp/api/vpe_msg_enum.h>
 #include <limits.h>
 
@@ -512,8 +513,7 @@ VLIB_CLI_COMMAND (show_bihash_command, static) =
 const char *
 __asan_default_options (void)
 {
-  return
-    "unmap_shadow_on_exit=1:disable_coredump=0:abort_on_error=1:detect_leaks=0";
+  return VPP_SANITIZE_ADDR_OPTIONS;
 }
 #endif /* CLIB_SANITIZE_ADDR */