[Openmp-commits] [PATCH] D55952: [libomptarget] Introduce LIBOMPTARGET_ENABLE_DEBUG cmake option.

Michael Kruse via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 20 13:06:45 PST 2018


Meinersbur created this revision.
Meinersbur added reviewers: hfinkel, sdmitriev, grokos, Hahnfeld.
Herald added a subscriber: mgorny.

At the moment, support for runtime debug output using the OMPTARGET_DEBUG=1 environment variable is only available with CMAKE_BUILD_TYPE=Debug builds. The patch allows setting it independently using the LIBOMPTARGET_ENABLE_DEBUG option, which is enabled by default depending on CMAKE_BUILD_TYPE. That is, unless this option is set explicitly, nothing changes. This is the same mechanism used by LLVM for LLVM_ENABLE_ASSERTIONS.

This patch also remove adding `-g -O0` in debug builds, it should be handled by cmake.

Idea by @hfinkel


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D55952

Files:
  libomptarget/CMakeLists.txt
  libomptarget/test/CMakeLists.txt
  libomptarget/test/lit.site.cfg.in


Index: libomptarget/test/lit.site.cfg.in
===================================================================
--- libomptarget/test/lit.site.cfg.in
+++ libomptarget/test/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.libomptarget_all_targets = "@LIBOMPTARGET_ALL_TARGETS@".split()
 config.libomptarget_system_targets = "@LIBOMPTARGET_SYSTEM_TARGETS@".split()
 config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
-config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
+config.libomptarget_debug = @LIBOMPTARGET_ENABLE_DEBUG@
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
Index: libomptarget/test/CMakeLists.txt
===================================================================
--- libomptarget/test/CMakeLists.txt
+++ libomptarget/test/CMakeLists.txt
@@ -6,12 +6,6 @@
   return()
 endif()
 
-if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
-  set(LIBOMPTARGET_DEBUG True)
-else()
-  set(LIBOMPTARGET_DEBUG False)
-endif()
-
 add_openmp_testsuite(check-libomptarget "Running libomptarget tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omptarget omp)
 
 # Configure the lit.site.cfg.in file
Index: libomptarget/CMakeLists.txt
===================================================================
--- libomptarget/CMakeLists.txt
+++ libomptarget/CMakeLists.txt
@@ -41,13 +41,14 @@
 # the list of supported targets in the current system.
 set (LIBOMPTARGET_SYSTEM_TARGETS "")
 
-# If building this library in debug mode, we define a macro to enable
-# dumping progress messages at runtime.
+# Check whether using debug mode. In debug mode, allow dumping progress
+# messages at runtime by default. Otherwise, it can be enabled
+# independently using the LIBOMPTARGET_ENABLE_DEBUG option.
 string( TOLOWER "${CMAKE_BUILD_TYPE}" LIBOMPTARGET_CMAKE_BUILD_TYPE)
-if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
-  add_definitions(-DOMPTARGET_DEBUG)
-  add_definitions(-g)
-  add_definitions(-O0)
+if( NOT LIBOMPTARGET_CMAKE_BUILD_TYPE STREQUAL "debug" )
+  option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" OFF)
+else()
+  option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" ON)
 endif()
 
 include_directories(include)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55952.179136.patch
Type: text/x-patch
Size: 2283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20181220/91d4f586/attachment.bin>


More information about the Openmp-commits mailing list