[llvm] r309483 - [OCaml] Pass -D/-UNDEBUG through to ocamlc

Michal Gorny via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 29 01:10:24 PDT 2017

Author: mgorny
Date: Sat Jul 29 01:10:24 2017
New Revision: 309483

URL: http://llvm.org/viewvc/llvm-project?rev=309483&view=rev
[OCaml] Pass -D/-UNDEBUG through to ocamlc

Detect [/-][DU]NDEBUG in CMAKE_C_FLAGS* and pass them through to ocamlc.
This is necessary because their value might affect visibility of dump
functions in LLVM and ocamlc uses its own compiler and flags by default.

Differential Revision: https://reviews.llvm.org/D35898


Modified: llvm/trunk/cmake/modules/AddOCaml.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddOCaml.cmake?rev=309483&r1=309482&r2=309483&view=diff
--- llvm/trunk/cmake/modules/AddOCaml.cmake (original)
+++ llvm/trunk/cmake/modules/AddOCaml.cmake Sat Jul 29 01:10:24 2017
@@ -87,6 +87,11 @@ function(add_ocaml_library name)
   foreach( include_dir ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR} )
     set(c_flags "${c_flags} -I${include_dir}")
+  # include -D/-UNDEBUG to match dump function visibility
+  # regex from HandleLLVMOptions.cmake
+  string(REGEX MATCH "(^| )[/-][UD] *NDEBUG($| )" flag_matches
+         "${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${CMAKE_C_FLAGS}")
+  set(c_flags "${c_flags} ${flag_matches}")
   foreach( ocaml_file ${ARG_OCAML} )
     list(APPEND sources "${ocaml_file}.mli" "${ocaml_file}.ml")

More information about the llvm-commits mailing list